NHN Cloud Object Storage provides API compatible with S3 API of AWS object storage. Therefore, you can use applications developed to use the Amazon S3 API as is, with only a few configuration changes.
The following Amazon S3 compatible API is provided.
S3 API Method | Usage |
---|---|
PUT Bucket | Create bucket |
HEAD Bucket | Query bucket information |
DELETE Bucket | Delete bucket |
PUT Bucket ACL | Set bucket ACL |
GET Bucket ACL | Get bucket ACL |
GET Bucket Location | Get region with bucket |
GET Bucket List Objects | List bucket objects |
GET Object | Download object |
HEAD Object | Query object information |
PUT Object | Upload object |
PUT Object Copy | Copy object |
DELETE Object | Delete object |
Initiate Multipart Upload | Initialize multipart upload |
Upload Part | Upload part |
Upload Part Copy | Copy part |
Complete Multipart Upload | Complete multipart upload |
Abort Multipart Upload | Abort multipart upload |
List Parts | List multipart objects |
List Multipart Uploads | List multipart objects under uploading |
DELETE Multiple Objects | Delete multipart objects |
This document describes only the basic usage of API. To use advanced features, it is recommended that you see Amazon S3 API Guide or use AWS SDK.
To use Amazon S3 compatible API, you must first obtain S3 API credentials in the form of AWS EC2. Credentials can be issued using the web console or API. To obtain credentials using the web console, refer to S3 API Credentials.
To obtain credentials using the API, an authentication token is required. To obtain the authentication token, refer to Object Storage API Guide.
POST https://api-identity-infrastructure.nhncloudservice.com/v2.0/users/{api-user-id}/credentials/OS-EC2
Content-Type: application/json
X-Auth-Token: {token-id}
Name | Type | Format | Required | Description |
---|---|---|---|---|
X-Auth-Token | Header | String | O | Issued token ID |
api-user-id | URL | String | O | API user ID, which can be found on the API Endpoint setting dialog box |
tenant_id | Body | String | O | Tenant ID, which can be found on the API Endpoint setting dialog box |
[Note]
<api-user-id>
can be found in the API User ID item in the API Endpoint settings dialog box on the console or in the access.user.id field in the response body of the Authentication Token Issuance API. To use the Authentication Token Issuance API, refer to Authentication Token Issuance in the API guide.S3 API credentials have no expiration date, and up to 3 credentials can be issued per project for each user.
[Caution] If the S3 API credentials key is leaked, anyone can access the object using the leaked key. If the key is leaked, it is recommended to delete the leaked credentials and obtain a new one.
If the user account issued with S3 API credentials loses access to the project or is deleted by leaving NHN Cloud, the credentials will immediately expire and cannot be used.
{
"tenant_id": "84c9e9a51aea402e95389c08ac562ac5"
}
Name | Type | Format | Description |
---|---|---|---|
access | Body | String | S3 API credentials access key |
secret | Body | String | S3 API credentials secret key |
{
"credential": {
"access": "253a3c7ca27f4731a9c757addfac29ca",
"tenant_id": "84c9e9a51aea402e95389c08ac562ac5",
"secret": "be057f235abf45ee8e2ba14edc5fb253",
"user_id": "84db0c80-3c39-11e7-b29c-005056ac1497",
"trust_id": null
}
}
Retrieves the issued S3 API credentials.
[Method, URL]
GET https://api-identity-infrastructure.nhncloudservice.com/v2.0/users/{user-id}/credentials/OS-EC2
X-Auth-Token: {token-id}
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
X-Auth-Token | Header | String | O | Issued token ID |
user-id | URL | String | O | User ID, included in the authentication token |
Name | Type | Format | Description |
---|---|---|---|
access | Body | String | S3 API credentials access key |
secret | Body | String | S3 API credentials secret key |
{
"credentials": [
{
"access": "253a3c7ca27f4731a9c757addfac29ca",
"tenant_id": "84c9e9a51aea402e95389c08ac562ac5",
"secret": "be057f235abf45ee8e2ba14edc5fb253",
"user_id": "84db0c80-3c39-11e7-b29c-005056ac1497",
"trust_id": null
}
]
}
Deletes the issued S3 API credentials.
[Method, URL]
DELETE https://api-identity-infrastructure.nhncloudservice.com/v2.0/users/{user-id}/credentials/OS-EC2/{access}
X-Auth-Token: {token-id}
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
X-Auth-Token | Header | String | O | Issued token ID |
user-id | URL | String | O | User ID, included in the authentication token |
access | URL | String | O | S3 API credentials access key |
This API does not return request body. When the request is appropriate, return status code 204.
To use S3 API, you must create a signature use credentials. Regarding how to sign, see AWS signature V4.
The following information is required to create a signature.
Name | Value |
---|---|
Algorithm | AWS4-HMAC-SHA256 |
Signed Time | In the ZssmmhhTDDMMYYYY format |
Service Name | s3 |
Region Name | KR1 - Korea (Pangyo) region KR2 - KOREA (Pyeongchon) Region KR3 - KOREA (Gwangju) Region JP1 - JAPAN (Tokyo) Region US1 - USA (California) Region |
Secret Key | S3 API credentials secret key |
Creates a bucket. Bucket names must follow Amazon S3's naming rules.
For more details, see Bucket restrictions and limitations.
PUT /{bucket}
Date: 22:22:22 +0000, Sat, 22 Feb 2020
Authorization: AWS {access}:{signature}
[Note] If a container name made via web console or object storage API violates any bucket naming rules, it cannot be accessed with S3 compatible API.
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
bucket | URL | String | O | Bucket name |
Date | Header | String | O | Request time |
Authorization | Header | String | O | Comprised of S3 API credentials access key and signature |
This API does not return a response body. It returns a status code of 200 if the request is valid.
Name | Type | Format | Description |
---|---|---|---|
Location | Header | String | Path for created bucket |
Retrieves bucket lists.
GET /
Date: 22:22:22 +0000, Sat, 22 Feb 2020
Authorization: AWS {access}:{signature}
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
Date | Header | String | O | Request Time |
Authorization | Header | String | O | Comprised of S3 API credentials access key and signature |
If the request is valid, returns a status code of 200 and a bucket list in XML format.
<?xml version='1.0' encoding='UTF-8'?>
<ListAllMyBucketsResult
xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Owner>
<ID>user:panther</ID>
<DisplayName>user:panther</DisplayName>
</Owner>
<Buckets>
<Bucket>
<Name>log</Name>
<CreationDate>2009-02-03T16:45:09.000Z</CreationDate>
</Bucket>
<Bucket>
<Name>snapshot</Name>
<CreationDate>2009-02-03T16:45:09.000Z</CreationDate>
</Bucket>
</Buckets>
</ListAllMyBucketsResult>
Retrieves the information of the specified bucket and the list of objects that are stored in the bucket.
GET /{bucket}
Date: 22:22:22 +0000, 22 Feb 2020
Authorization: AWS {access}:{signature}
[Note] If a bucket name made via web console or object storage API violates any bucket naming rules, it cannot be accessed with S3 compatible API.
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
bucket | URL | String | O | Bucket name |
Date | Header | String | O | Request time |
Authorization | Header | String | O | Comprised of S3 API credentials access key and signature |
If the request is valid, returns a status code of 200 and a object list in XML format.
<?xml version='1.0' encoding='UTF-8'?>
<ListBucketResult
xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>snapshot</Name>
<Prefix/>
<Marker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>cheetah</Key>
<LastModified>2023-02-01T04:49:52.995Z</LastModified>
<ETag>"7d793037a0760186574b0282f2f435e7"</ETag>
<Size>5</Size>
<Owner>
<ID>user:panther</ID>
<DisplayName>user:panther</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>leopard</Key>
<LastModified>2023-02-01T04:49:52.685Z</LastModified>
<ETag>"5d41402abc4b2a76b9719d911017c592"</ETag>
<Size>5</Size>
<Owner>
<ID>user:panther</ID>
<DisplayName>user:panther</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
</ListBucketResult>
Deletes the specified bucket. The bucket to be deleted must be empty.
DELETE /{bucket}
Date: 22:22:22 +0000, Sat, 22 Feb 2020
Authorization: AWS {access}:{signature}
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
bucket | URL | String | O | Bucket name |
Date | Header | String | O | Request time |
Authorization | Header | String | O | Comprised of S3 API credentials access key and signature |
This API does not return a response body; it returns status code 204 if the request is valid.
Uploads an object to the specified bucket.
PUT /{bucket}/{obj}
Date: 22:22:22 +0000, Sat, 22 Feb 2020
Authorization: AWS {access}:{signature}
This API does not return a response body. It returns status code 204 if the request is valid.
Name | Type | Format | Required | Description |
---|---|---|---|---|
bucket | URL | String | O | Bucket name |
obj | URL | String | O | Object name |
Date | Header | String | O | Request time |
Authorization | Header | String | O | Comprised of S3 API credentials access key and signature |
This API does not return a response body. It returns a status code of 200 if the request is valid.
Name | Type | Format | Description |
---|---|---|---|
ETag | Header | String | MD5 hash value of the object |
Last-Modified | Header | String | The object's last modified date (e.g. Wed, 01 Mar 2006 12:00:00 GMT) |
Downloads an object.
GET /{bucket}/{obj}
Date: 22:22:22 +0000, Sat, 22 Feb 2020
Authorization: AWS {access}:{signature}
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
bucket | URL | String | O | Bucket name |
obj | URL | String | O | Object name |
Date | Header | String | O | Request time |
Authorization | Header | String | O | Comprised of S3 API credentials access key and signature |
If the request is valid, returns the status code of 200.
Name | Type | Format | Description |
---|---|---|---|
Last-Modified | Header | String | The object's last modified date (e.g. Wed, 01 Mar 2006 12:00:00 GMT) |
ETag | Header | String | MD5 hash value of the obejct |
Delete the specified object.
DELETE /{bucket}/{obj}
Date: 22:22:22 +0000 Sat, 22 Feb 2020
Authorization: AWS {access}:{signature}
This API does not require a request body.
Name | Type | Format | Required | Description |
---|---|---|---|---|
bucket | URL | String | O | Bucket name |
obj | URL | String | O | Object name |
Date | Header | String | O | Requested time |
Authorization | Header | String | O | Comprised of S3 API credentials access key and signature |
This API does not return a response body. It returns status code 204 if the request is valid.
You can use NHN Cloud Object Storage with AWS Command Line Interface using the S3 compatible API.
The AWS Command Line Interface (CLI) is provided as a Python package, which can be installed by using the Python package manager (pip).
$ sudo pip install awscli
To use AWS CLI, you must set up S3 API credentials and environment first.
$ aws configure
AWS Access Key ID [None]: {access}
AWS Secret Access Key [None]: {secret}
Default region name [None]: {region name}
Default output format [None]: json
Name | Description |
---|---|
access | S3 API credentials access key |
secret | S3 API credentials secret key |
region name | KR1 - Korea (Pangyo) Region KR2 - Korea (Pyeongchon) Region KR3 - KOREA (Gwangju) Region JP1 - Japan (Tokyo) Region US1 - US (California) Region |
aws --endpoint-url={endpoint} s3 {command} s3://{bucket}
Name | Description |
---|---|
endpoint | https://kr1-api-object-storage.nhncloudservice.com - Korea (Pangyo) region https://kr2-api-object-storage.nhncloudservice.com - Korea (Pyeongcheon) region https://kr3-api-object-storage.nhncloudservice.com - Korea(Gwangju) region https://jp1-api-object-storage.nhncloudservice.com - Japan (Tokyo) region https://us1-api-object-storage.nhncloudservice.com - US (California) region |
command | Command for AWS Command Line Interface |
bucket | Bucket name |
[Note] Since AWS CLI is provided to use AWS, it is configured to use AWS domain. Therefore, to use NHN Cloud Object Storage, it is required to specify endpoint for every command. Regarding commands for AWS Command Line Interface, see Using high-level (s3) commands with the AWS CLI.
$ aws --endpoint-url=https://kr1-api-object-storage.nhncloudservice.com s3 mb s3://example-bucket
make_bucket: example-bucket
$ aws --endpoint-url=https://kr1-api-object-storage.nhncloudservice.com s3 ls
2020-07-13 10:07:13 example-bucket
$ aws --endpoint-url=https://kr1-api-object-storage.nhncloudservice.com s3 ls s3://example-bucket
2020-07-13 10:08:49 104389 0428b9e3e419d4fb7aedffde984ba5b3.jpg
2020-07-13 10:09:09 74448 6dd6d48eef889a5dab5495267944bdc6.jpg
$ aws --endpoint-url=https://kr1-api-object-storage.nhncloudservice.com s3 rb s3://example-bucket
remove_bucket: example-bucket
$ aws --endpoint-url=https://kr1-api-object-storage.nhncloudservice.com s3 cp ./3b5ab489edffdea7bf4d914e3e9b8240.jpg s3://example-bucket/3b5ab489edffdea7bf4d914e3e9b8240.jpg
upload: ./3b5ab489edffdea7bf4d914e3e9b8240.jpg to s3://example-bucket/3b5ab489edffdea7bf4d914e3e9b8240.jpg
[Note] If the object is larger than 8 MB, the AWS Command Line Interface splits the object into multiple parts and uploads them. The part object is stored in a bucket called{bucket}+segments
It is saved in the form of part-number{object-name}/{upload-id}/{part-number}
, and when all parts are uploaded, an object linked to the part object is created in the bucket requested for upload. The{bucket}+segments
bucket where the part object is stored cannot be accessed through the S3 compatible API, but can be accessed through the Object Storage API or the console. The ETag of a multipart object is an MD5 hashed value by converting the ETag values of each part object into binary data and concatenating them in order.
[Caution] If you delete some or all parts of an object uploaded as multipart, the object cannot be accessed.
$ aws --endpoint-url=https://kr1-api-object-storage.nhncloudservice.com s3 cp s3://example-bucket/3b5ab489edffdea7bf4d914e3e9b8240.jpg ./3b5ab489edffdea7bf4d914e3e9b8240.jpg
download: s3://example-bucket/0428b9e3e419d4fb7aedffde984ba5b3.jpg to ./0428b9e3e419d4fb7aedffde984ba5b3.jpg
$ aws --endpoint-url=https://kr1-api-object-storage.nhncloudservice.com s3 rm s3://example-bucket/3b5ab489edffdea7bf4d914e3e9b8240.jpg
delete: s3://example-bucket/3b5ab489edffdea7bf4d914e3e9b8240.jpg
AWS provides SDKs for many types of programming languages. By using the S3 compatible API, you can use NHN Cloud Object Storage with AWS SDK.
[Note] For more information, see AWS SDK.
The following are the major parameters required to use AWS SDK.
Name | Description |
---|---|
access | S3 API credentials access key |
secret | S3 API credentials secret key |
region name | KR1 - Korea (Pangyo) region KR2 - Korea (Pyeongchon) region KR3 - Korea (Gwangju) region JP1 - Japan (Tokyo) region US1 - US (California) region |
endpoint | https://kr1-api-object-storage.nhncloudservice.com - Korea (Pangyo) region https://kr2-api-object-storage.nhncloudservice.com - Korea (Pyeongchon) region https://kr3-api-object-storage.nhncloudservice.com - Korea (Gwangju) region https://jp1-api-object-storage.nhncloudservice.com - Japan (Tokyo) region https://us1-api-object-storage.nhncloudservice.com - US (California) region |
[Note] For more information, see AWS SDK for Python (Boto3).
# boto3example.py
from boto3 import client
from boto3.s3.transfer import TransferConfig
from botocore.exceptions import ClientError
class Boto3Example(object):
_REGION = '{region name}'
_ENDPOINT = '{endpoint}'
_ACCESS = '{access}'
_SECRET = '{secret}'
def __init__(self):
self.s3 = client(service_name='s3',
region_name=self._REGION,
endpoint_url=self._ENDPOINT,
aws_access_key_id=self._ACCESS,
aws_secret_access_key=self._SECRET)
def create_bucket(self, bucket_name):
try:
return self.s3.create_bucket(Bucket=bucket_name)
except ClientError as e:
raise RuntimeError(e)
def list_buckets(self):
try:
return self.s3.list_buckets().get('Buckets')
except ClientError as e:
raise RuntimeError(e)
def list_objs(self, bucket_name):
try:
return self.s3.list_objects_v2(Bucket=bucket_name).get('Contents')
except ClientError as e:
raise RuntimeError(e)
def delete_bucket(self, bucket_name):
try:
return self.s3.delete_bucket(Bucket=bucket_name)
except ClientError as e:
raise RuntimeError(e)
[Note] The number of part objects is determined by the size of the object being uploaded and the part size you set. The default part size is 8MiB, and you can specify an object size as small as 5MiB. The maximum number of part objects is 1000.
def upload(self, bucket_name, key, filename, part_size):
config = TransferConfig(multipart_chunksize=part_size)
try:
self.s3.upload_file(Filename=filename,
Bucket=bucket_name,
Key=key,
Config=config)
except ClientError as e:
raise RuntimeError(e)
def download(self, bucket_name, key, filename):
try:
response = self.s3.get_object(Bucket=bucket_name, Key=key)
with io.FileIO(filename, 'w') as fd:
for chunk in response['Body']:
fd.write(chunk)
response.pop('Body')
except ClientError as e:
raise RuntimeError(e)
except OSError as e:
raise RuntimeError(e)
return response
def delete(self, bucket_name, key):
try:
return self.s3.delete_object(Bucket=bucket_name, Key=key)
except ClientError as e:
raise RuntimeError(e)
[Note] For more information, see AWS SDK for Java.
// AwsSdkExample.java
public class AwsSdkExample {
private static final String access = "{access}";
private static final String secret = "{secret}";
private static final String region = "{region name}";
private static final String ednpoint = "{endpoint}";
private AmazonS3 s3Client;
public AwsSdkExample() {
BasicAWSCredentials awsCredentials =
new BasicAWSCredentials(access, secret);
s3Client = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(ednpoint, region)
)
.withCredentials(
new AWSStaticCredentialsProvider(awsCredentials)
)
.enablePathStyleAccess()
.disableChunkedEncoding()
.build();
}
}
public String createBucket(String bucketName) throws RuntimeException {
try {
return s3Client.createBucket(bucketName).toString();
} catch (AmazonServiceException e) {
throw new RuntimeException(e);
} catch (SdkClientException e) {
throw new RuntimeException(e);
}
}
public List<Bucket> listBuckets() throws RuntimeException {
try {
return s3Client.listBuckets();
} catch (AmazonServiceException e) {
throw new RuntimeException(e);
} catch (SdkClientException e) {
throw new RuntimeException(e);
}
}
public ListObjectsV2Result listObjects(
String bucketName
) throws RuntimeException {
try {
return s3Client.listObjectsV2(bucketName);
} catch (AmazonServiceException e) {
throw new RuntimeException(e);
} catch (SdkClientException e) {
throw new RuntimeException(e);
}
}
public void deleteBucket(String bucketName) throws RuntimeException {
try {
s3Client.deleteBucket(bucketName);
} catch (AmazonServiceException e) {
throw new RuntimeException(e);
} catch (SdkClientException e) {
throw new RuntimeException(e);
}
}
[Note] The number of part objects is determined by the size of the object being uploaded and the part size you set. The default part size is 5MiB, and you can specify an object size as small as 5MiB. The maximum number of part objects is 1000.
public void uploadObject(String bucketName, String objectKey, String filePath, long partSize) {
TransferManager tm = TransferManagerBuilder.standard()
.withS3Client(s3Client)
.withMinimumUploadPartSize(partSize)
.build();
Upload upload = tm.upload(bucketName, objectKey, new File(filePath));
try {
upload.waitForCompletion();
} catch (AmazonServiceException e) {
upload.abort();
} catch (AmazonClientException e) {
upload.abort();
} catch (InterruptedException e) {
upload.abort();
}
}
public String downloadObject(
String bucketName, String objKeyName, String filePath
) throws RuntimeException {
try {
return s3Client.getObject(
new GetObjectRequest(bucketName, objKeyName),
new File(filePath)
).getETag();
} catch (NoSuchKeyException e) {
throw new RuntimeException(e);
} catch (InvalidObjectStateException e) {
throw new RuntimeException(e);
} catch (S3Exception e) {
throw new RuntimeException(e);
} catch (AwsServiceException e) {
throw new RuntimeException(e);
} catch (SdkClientException e) {
throw new RuntimeException(e);
}
}
public void deleteObject(
String bucketName, String objKeyName
) throws RuntimeException {
try {
s3Client.deleteObject(bucketName, objKeyName);
} catch (AmazonServiceException e) {
throw new RuntimeException(e);
} catch (SdkClientException e) {
throw new RuntimeException(e);
}
}
[Note] For more information, see AWS SDK for .NET.
class S3SDKExample
{
private static string endpoint = "{endpoint}";
private static string regionName = "{region name}";
private static string accessKey = "{access}";
private static string secretKey = "{secret}";
private static AmazonS3Client GetS3Client()
{
var amazonS3Config =
new AmazonS3Config
{
ServiceURL = endpoint,
AuthenticationRegion = regionName,
ForcePathStyle = true,
};
var basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
return new AmazonS3Client(basicAWSCredentials, amazonS3Config);
}
}
static async Task<PutBucketResponse> CreateBucketAsync(
AmazonS3Client s3Client,
string bucketName)
{
try
{
if (!(await AmazonS3Util.DoesS3BucketExistAsync(s3Client, bucketName)))
{
var putBucketRequest =
new PutBucketRequest
{
BucketName = bucketName,
UseClientRegion = true
};
return await s3Client.PutBucketAsync(putBucketRequest);
}
throw new Exception("Bucket already exist.");
}
catch (AmazonS3Exception e)
{
throw e;
}
}
static async Task<ListBucketsResponse> ListBucketsAsync(AmazonS3Client s3Client)
{
try
{
return await s3Client.ListBucketsAsync();
}
catch (AmazonS3Exception e)
{
throw e;
}
}
static async Task<List<ListObjectsV2Response>> ListBucketContentsAsync(
AmazonS3Client s3Client,
string bucketName)
{
try
{
List<ListObjectsV2Response> responses =
new List<ListObjectsV2Response>();
var request =
new ListObjectsV2Request
{
BucketName = bucketName,
MaxKeys = 5,
};
var response = new ListObjectsV2Response();
do
{
responses.Add(await s3Client.ListObjectsV2Async(request));
request.ContinuationToken = response.NextContinuationToken;
}
while (response.IsTruncated);
return responses;
}
catch (AmazonS3Exception e)
{
throw e;
}
}
static async Task<DeleteBucketResponse> DeleteBucketAsync(
AmazonS3Client s3Client,
string bucketName)
{
try
{
return await s3Client.DeleteBucketAsync(
new DeleteBucketRequest
{
BucketName = bucketName
});
}
catch (AmazonS3Exception e)
{
throw e;
}
}
[Note] The number of part objects is determined by the size of the object being uploaded and the part size you set. The default part size is 5MiB, and you can set the object size as small as 5MiB. The maximum number of part objects is 1000.
private static async Task UploadObjectAsync(
AmazonS3Client s3Client,
string bucketName,
string keyName,
string filePath,
int partSize)
{
try
{
TransferUtility uploader = new TransferUtility(s3Client);
TransferUtilityUploadRequest uploadRequest = new TransferUtilityUploadRequest()
{
FilePath = filePath,
BucketName = bucketName,
Key = keyName,
PartSize = partSize
};
uploader.Upload(uploadRequest);
}
catch (AmazonS3Exception e)
{
throw e;
}
}
static async Task ReadObjectDataAsync(
AmazonS3Client s3Client,
string bucketName,
string keyName,
string filePath)
{
try
{
GetObjectRequest request =
new GetObjectRequest
{
BucketName = bucketName,
Key = keyName
};
ResponseHeaderOverrides responseHeaders =
new ResponseHeaderOverrides();
responseHeaders.CacheControl = "No-cache";
request.ResponseHeaderOverrides = responseHeaders;
var appendToFile = false;
using (var response = await s3Client.GetObjectAsync(request))
await response.WriteResponseStreamToFileAsync(
filePath, appendToFile, CancellationToken.None);
}
catch (AmazonS3Exception e)
{
throw e;
}
}
static async Task<DeleteObjectResponse> DeleteObjectNonVersionedBucketAsync(
AmazonS3Client s3Client,
string bucketName,
string keyName)
{
try
{
var deleteObjectRequest =
new DeleteObjectRequest
{
BucketName = bucketName,
Key = keyName
};
return await s3Client.DeleteObjectAsync(deleteObjectRequest);
}
catch (AmazonS3Exception e)
{
throw e;
}
}