Skip to content

Commit

Permalink
chore: add S3MultipartUpload page
Browse files Browse the repository at this point in the history
  • Loading branch information
heitortsergent committed Jan 4, 2024
1 parent f09ca81 commit 84b38ea
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: 'S3MultipartUpload'
description: 'S3MultipartUpload is returned by the S3Client.createMultipartUpload method when creating a multipart upload.'
weight: 20
---

# S3MultipartUpload

S3MultipartUpload is returned by the [`createMultipartUpload(bucketName, objectKey)`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/s3client/createmultipartupload) method when creating a [multipart upload](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html).

| Name | Type | Description |
| :--------------------------- | :----- | :---------------------------- |
| `S3MultipartUpload.key` | string | The S3 Multipart object's key |
| `S3MultipartUpload.uploadId` | Date | The S3 Multipart upload Id |

### Example

{{< code >}}

```javascript
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
sessionToken: __ENV.AWS_SESSION_TOKEN,
});

const s3 = new S3Client(awsConfig);

const testBucketName = 'test-jslib-aws';
const testFileKey = 'multipart.txt';

export default async function () {
// Initialize a multipart upload
const multipartUpload = await s3.createMultipartUpload(testBucketName, testFileKey);
console.log(multipartUpload.uploadId);

// Abort multipart upload
await s3.abortMultipartUpload(testBucketName, testFileKey, multipartUpload.uploadId);
}
```

_A k6 script that will create a multipart upload and log the multipart `uploadId` and abort the multipart upload_

{{< /code >}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'S3Part'
head_title: 'S3Part'
slug: 's3part'
description: 'S3Part is returned by the S3Client.uploadPart method when uploading a part to a multipart upload.'
weight: 10
weight: 20
---

# S3Part
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: 'S3MultipartUpload'
description: 'S3MultipartUpload is returned by the S3Client.createMultipartUpload method when creating a multipart upload.'
weight: 20
---

# S3MultipartUpload

S3MultipartUpload is returned by the [`createMultipartUpload(bucketName, objectKey)`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/s3client/createmultipartupload) method when creating a [multipart upload](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html).

| Name | Type | Description |
| :--------------------------- | :----- | :---------------------------- |
| `S3MultipartUpload.key` | string | The S3 Multipart object's key |
| `S3MultipartUpload.uploadId` | Date | The S3 Multipart upload Id |

### Example

{{< code >}}

```javascript
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
sessionToken: __ENV.AWS_SESSION_TOKEN,
});

const s3 = new S3Client(awsConfig);

const testBucketName = 'test-jslib-aws';
const testFileKey = 'multipart.txt';

export default async function () {
// Initialize a multipart upload
const multipartUpload = await s3.createMultipartUpload(testBucketName, testFileKey);
console.log(multipartUpload.uploadId);

// Abort multipart upload
await s3.abortMultipartUpload(testBucketName, testFileKey, multipartUpload.uploadId);
}
```

_A k6 script that will create a multipart upload and log the multipart `uploadId` and abort the multipart upload_

{{< /code >}}

0 comments on commit 84b38ea

Please sign in to comment.