Downloading files from NAVER CLOUD PLATFORM Object Storage (secured)

Home > NAVER CLOUD PLATFORM Object Storage > Example 04

Explanation

This is an example of downloading a file from NAVER CLOUD PLATFORM Object Storage. If the file stored in Object Storage does not have 'Public-Read' permission, the credentialing process may be required, so the 'Region/Bucket/Accesskey/Secret Accesskey' information is required. However, information such as 'AccessKey/SecretAccessKey' is not supposed to be exposed to the outside world, so it is dangerous to use it in public. To download without exposing credentials, you can generate a pre-signed address on the backend and use that address to download the file.

// Set the NCPOS method.
dx.setDownloadMode("NCPOS");
dx.setNCPOSDownloadConfig({
    //type: "SECRET",
    signedURL: dx5.canonicalize("../service/ncpos-download-geturl.do"),
});

The backend address is responsible for generating and returning the signed address needed to download the file. To return a signed address from the backend, you need to use the SDK provided by AWS. In the sample project, we put the necessary AWS SDK JAR files in the WEB-INF/lib directory.

Refer to the NCPOSController and NCPOSDownloadHelper classes for details on generating signed addresses using the AWS SDK.

예제

Singe-file download

In the single-file download, when downloading with a signed address, the target is not from the same source, so the browser may not download the target and open it directly.

Multiple-files download

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