Explanation
This is an example of uploading a file to Amazon S3. To upload files to S3, you need to know the region, bucket, access key, and secret access key. However, it is dangerous to use information such as "AccessKey/SecretAccessKey" in public because it should not be exposed to the outside world. To upload without exposing your AWS credentials, you can create a pre-signed address on the backend and use that address to upload files. The signed address is only valid for a certain amount of time and implicitly authorizes the upload. The following code shows how to set up this information
// Set up the AWSS3 method
dx.setUploadMode("AWSS3");
// Set the type attribute of the settings object to "SECRET" or omit it.
dx.setAWSS3UploadConfig({
//type: "SECRET",
initURL: dx5.canonicalize("../service/awss3-upload-helper.do?step=0"),
signedURL: dx5.canonicalize("../service/awss3-upload-helper.do?step=1"),
completeURL: dx5.canonicalize("../service/awss3-upload-helper.do?step=2")
});
The three backend addresses are responsible for generating and returning the signed addresses required for each step of the file upload. To return signed addresses from the backend, you must use the SDK provided by AWS. In the sample project, we put the required AWS SDK JAR files in the WEB-INF/lib directory.
For details on generating signed addresses using the AWS SDK, see the AWSS3Upload servlet and the AWSS3MultipartUploadHelper class.
Example
|
|