Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version .
uploadPart S3Client.uploadPart
uploads a part to multipart upload in a bucket.
Expand table
Parameter Type Description bucketName string Name of the bucket to upload the object to. objectKey string Name of the object to upload. uploadId string UploadId of the multipart upload. partNumber number The Part number of the Part to upload. data string | ArrayBuffer Content of the part to upload.
Returns Expand table
Type Description Promise<S3Part > A Promise that fulfills with a S3Part representing a S3 Part Upload.
Example Expand code
import crypto from 'k6/crypto' ;
import exec from 'k6/execution' ;
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 ( ) {
const bigFile = crypto. randomBytes ( 12 * 1024 * 1024 ) ;
const multipartUpload = await s3. createMultipartUpload ( testBucketName, testFileKey) ;
const firstPartData = bigFile. slice ( 0 , 6 * 1024 * 1024 ) ;
const firstPart = await s3. uploadPart (
testBucketName,
testFileKey,
multipartUpload. uploadId,
1 ,
firstPartData
) ;
const secondPartData = bigFile. slice ( 6 * 1024 * 1024 , 12 * 1024 * 1024 ) ;
const secondPart = await s3. uploadPart (
testBucketName,
testFileKey,
multipartUpload. uploadId,
2 ,
secondPartData
) ;
await s3. completeMultipartUpload ( testBucketName, testFileKey, multipartUpload. uploadId, [
firstPart,
secondPart,
] ) ;
const obj = await s3. getObject ( testBucketName, testFileKey) ;
await s3. deleteObject ( testBucketName, testFileKey) ;
}
A k6 script that will upload a part in a multipart upload to an S3 bucket