Uploading files to NAVER CLOUD PLATFORM Object Storage (secured)

Home > NAVER CLOUD PLATFORM Object Storage > Example 02

Explanation

This is an example of uploading a file to NAVER CLOUD PLATFORM Object Storage. To upload a file to Object Storage, you need to know the region/bucket/exec/secret executable information in advance. However, information such as 'accesskey/secret' should not be exposed to the outside world, so it is dangerous to use it in public. To upload without exposing your 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 the NCPOS method.	
dx.setUploadMode("NCPOS");
// Set the type attribute of the configuration object to “SECRET” or omit it.
dx.setAWSS3UploadConfig({
    //type: "SECRET",
    initURL: dx5.canonicalize("../service/ncpos-upload-helper.do?step=0"),
    signedURL: dx5.canonicalize("../service/ncpos-upload-helper.do?step=1"),
    completeURL: dx5.canonicalize("../service/ncpos-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 the 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.

Refer to the NCPOSUpload servlet and NCPOSMultipartUploadHelper classes for details on generating signed addresses using the AWS SDK.

Example

To test, you need to set ACESSKEY_ID, SECRET_ACCESSKEY, REGION, and BUCKET_NAME in the NCPOSMultipartUploadHelper class.

Result