www.dextsolution.com
DEXTUPLOAD
X5
menu toggleProduct description > NCP Object Storage file upload

NCP Object Storage file upload

DEXTUploadX5 provides the ability to upload files using the NCP(NAVER CLOUD PLATFORM) Object Storage service.

In order for the DEXTUploadX5 product to upload files to a bucket in NCP Object Storage, it needs to allow communication between different sources, so the bucket must be CORS configured. To use the multipart upload feature, you must allow the PUT request method and ETag response header, and be careful not to set the AllowedOrigins property to the value '*' at production time.

# CORS configuration
{
	"CORSRules": [
		{
			"AllowedHeaders": ["*"],
			"AllowedMethods": ["HEAD", "GET", "PUT", "POST", "DELETE"],
			"AllowedOrigins": ["*"],
			"ExposeHeaders": ["ETag"]
		}
	]
}
Uploading using DEXTUploadX5 and the browser AWS SDK

DEXTUploadX5 uses the AWS SDK internally to upload files directly to the NCP Object Storage service. To upload using the SDK, you need the following information: region, bucket, accesskey, and secret accesskey. The following code shows how to set this information.

// Set up the NCPOS method	
dx.setUploadMode("NCPOS");
// Set the type property of the configuration object to “NON-SECRET”, then set the rest of the values.
dx.setNCPOSUploadConfig({
    type: "NON-SECRET",
    accessKeyId: "ABCD...1234",
    secretAccessKey: "ABCD...1234",
    region: "ap-northeast-2",
    bucket: "abc-bucket"
});

The files that go into a bucket are identified by a key. Typically, the key value is the filename, but to avoid the problem of files with the same name overwriting each other, the key value needs to be more specific. The product defaults to using the key value as the filename, and if you want to set the key in a format other than filename, you can set a function to generate the key in the makeKey property.

dx.setNCPOSUploadConfig({
    ...
    // key: component-name/filename  
    makeKey: item => `${item.controlId}/${item.name}`
});

* By including a '/' character in the key value, the bucket can distinguish between files as if they had a folder structure.

Other than setting the upload method to NCPOS and configuring it using setNCPOSUploadConfig, uploading files is the same as using OROF or EXTS.

Uploading using a Presigned URL

Uploading files to the Object Storage service directly from a browser using the AWS SDK is not recommended for security reasons. Information such as access keys and secret passwords are not supposed to be exposed to the outside world, so it is dangerous to use them in public. To upload without exposing your AWS credentials, you can create a pre-signed address (presigned url) on the backend and use it to upload files. The signed address is only valid for a certain amount of time, and it implicitly authorizes the upload. The following code shows how to set this information

// Set up the NCPOS method	
dx.setUploadMode("NCPOS");
// Set the type attribute of the settings object to “SECRET” or omit it.
dx.setNCPOSUploadConfig({
    //type: "SECRET",
    initURL: "https://domain/path/ncpos-upload-init",
    signedURL: "https://domain/path/ncpos-upload-geturl",
    completeURL: "https://domain/path/ncpos-upload-complete" 
});

The initURL, signedURL, and completeURL addresses do the following things, which you'll need to implement yourself

  • initURL: Initialize the upload
  • signedURL: Generate the Presigned URL
  • completeURL: Handle upload completion

By implementing the steps required for the upload process on the server side using the appropriate AWS SDK for your platform, you can let DEXTUploadX5 handle the file upload process without exposing information such as credentials.

Examples are provided for Java Web Application, so please refer to the provided examples for implementation.

  • How to get the AWS SDK if your environment is using Java and Maven

    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>s3</artifactId>
        <version>2.x.x</version>
    </dependency>
  • How to get the AWS SDK if your environment is using Java and Gradle

    implementation 'software.amazon.awssdk:s3:2.x.x'
Features
  • DEXTUploadX5 uses the multi-part upload method supported by the NCP Object Storage service, allowing you to upload large files.
  • If you are using the Browser AWS SDK, there may be additional time to download the SDK when you start uploading files.
  • When uploading files to the Object Storage, the progress shown in the progress window may not be as natural as other upload methods.
  • Metadata is also uploaded. However, the values are BASE64 encoded.