Work with a file upload and download controls2
2011-03-04 21:33
337 查看
Table of Contents
1 Restrict the size of uploaded files
2 Limiting file types for upload
3 How to process an uploaded file
4 How to enable large file uploads in Domino
Read details in Domino Designer Wiki
![](http://domino1.youatnotes.de/web/youatnotes/wiki-xpages.nsf/external.gif)
.
The file is in the "xspupload" directory on the Domino Server and has some crypting filename. You can get the original filename with fileData.getClientFileName().
For example, you can attach the file to some Notes document with code like this:
This snippet renames the temporary file to the orginal filename, attaches it to a RichText item and renames it back to the cryptic name (so that it will be deleted by Domino after processing).
Set the fields "Maximum size of request content" and "Maximum POST data" to the same value (for example 20.480 for a 20MB limit).
Then set this limit in your application in Application Properties -> XPage Properties -> File Upload max size.
1 Restrict the size of uploaded files
2 Limiting file types for upload
3 How to process an uploaded file
4 How to enable large file uploads in Domino
Restrict the size of uploaded files
Set in Application Properties -> XPage Properties -> File Upload max size .Limiting file types for upload
You can set define which file types are allowed to be uploaded in the upload control -> all properties -> basics -> accept.Read details in Domino Designer Wiki
![](http://domino1.youatnotes.de/web/youatnotes/wiki-xpages.nsf/external.gif)
.
How to process an uploaded file
Place code like this in the beforeRenderResponse event of an XPage to get a handle to a just-uploaded file:var con = facesContext.getExternalContext();
var request:com.sun.faces.context.MyHttpServletRequestWrapper = con.getRequest();
var map:java.util.Map = request.getParameterMap();
var fileDataName = "file"; //name of the POST request parameter that contains the file
var fileData:com.ibm.xsp.http.UploadedFile = map.get( fileDataName );
var tempFile:java.io.File = fileData.getServerFile();
The file is in the "xspupload" directory on the Domino Server and has some crypting filename. You can get the original filename with fileData.getClientFileName().
For example, you can attach the file to some Notes document with code like this:
var correctedFile = new java.io.File( tempFile.getParentFile().getAbsolutePath() + java.io.File.separator + fileData.getClientFileName() );
var success = tempFile.renameTo(correctedFile); //rtFiles is a rich text item on a notesdocument of your chosing rtFiles.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT, "", correctedFile.getAbsolutePath(), null);
correctedFile.renameTo(tempFile);
This snippet renames the temporary file to the orginal filename, attaches it to a RichText item and renames it back to the cryptic name (so that it will be deleted by Domino after processing).
How to enable large file uploads in Domino
Open the server document in the Domino Directory, go to Internet Protocols/HTTP and then to the "HTTP Protocol Limits" section.Set the fields "Maximum size of request content" and "Maximum POST data" to the same value (for example 20.480 for a 20MB limit).
Then set this limit in your application in Application Properties -> XPage Properties -> File Upload max size.
相关文章推荐
- Work with a file upload and download controls
- servletFileUploadAndDownload
- Upload and Download File using Java
- Upload and Download File using Java
- Spring MVC + Mybatis+MySQL File Upload and Download Example
- Decrypt file with GPG and Download m3u8 file
- Use DropzondJS and Spring to upload and download file
- Java_ftp_file upload and download
- If you whant to download SIS, JAR and JAD file from WAP you have to upload file (in the same catalog) with this: [小糊涂的灵感]
- Struts 2 File Upload and Save Tutorial with Example
- Ajax Upload; A file upload script with progress-bar, drag-and-drop
- Java SFTP Apache commons file download, upload and delete example
- CVE-2014-0050: Exploit with Boundaries, Loops without Boundaries、Apache Commons FileUpload and Apache Tomcat DoS
- C# SharpSsh Private-public a pair key to Upload and Download File
- Servlet JSP Tutorial -- 1.8 Servlet Upload File and Download File Example
- Struts2 下载 Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack
- upload files in rails with plugin and without plugin
- How to increase swap size with a swap file and Partition
- Manipulating Pages and Server Controls with JavaScript(使用JS处理页面和服务器控件)
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决