Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multipart upload - move query parameters to HTTP request query object #47

Merged
merged 4 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/aws.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/aws.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/kms.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/s3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/s3.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/secrets-manager.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/signature.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/sqs.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/ssm.js.map

Large diffs are not rendered by default.

37 changes: 22 additions & 15 deletions src/internal/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class S3Client extends AWSClient {
// Prepare request
const method = 'PUT'
const host = `${this.host}`

const signedRequest = this.signature.sign(
{
method: method,
Expand Down Expand Up @@ -274,7 +274,7 @@ export class S3Client extends AWSClient {
* The uploadId returned can be used to upload parts to the object.
*
* @param {string} bucketName - The bucket name containing the object.
* @param {string} objectKey - Key of the object to delete.
* @param {string} objectKey - Key of the object to upload.
* @return {S3MultipartUpload} - returns the uploadId of the newly created multipart upload.
* @throws {S3ServiceError}
* @throws {InvalidSignatureError}
Expand All @@ -283,15 +283,15 @@ export class S3Client extends AWSClient {
// Prepare request
const method = 'POST'
const host = `${bucketName}.${this.host}`
const query = 'uploads'

const signedRequest = this.signature.sign(
{
method: method,
protocol: 'https',
protocol: this.scheme,
hostname: host,
path: `/${objectKey}?${query}`,
path: `/${objectKey}`,
headers: {},
query: { uploads: '' },
},
{}
)
Expand All @@ -312,7 +312,7 @@ export class S3Client extends AWSClient {
/**
* Uploads a part in a multipart upload.
* @param {string} bucketName - The bucket name containing the object.
* @param {string} objectKey - Key of the object to delete.
* @param {string} objectKey - Key of the object to upload.
* @param {string} uploadId - The uploadId of the multipart upload.
* @param {number} partNumber - The part number of the part to upload.
* @param {string | ArrayBuffer} data - The content of the part to upload.
Expand All @@ -329,15 +329,18 @@ export class S3Client extends AWSClient {
// Prepare request
const method = 'PUT'
const host = `${bucketName}.${this.host}`
const query = `partNumber=${partNumber}&uploadId=${uploadId}`
const signedRequest = this.signature.sign(
{
method: method,
protocol: 'https',
protocol: this.scheme,
hostname: host,
path: `/${objectKey}?${query}`,
path: `/${objectKey}`,
headers: {},
body: data,
query: {
partNumber: `${partNumber}`,
uploadId: `${uploadId}`,
},
},
{}
)
Expand Down Expand Up @@ -369,7 +372,6 @@ export class S3Client extends AWSClient {
// Prepare request
const method = 'POST'
const host = `${bucketName}.${this.host}`
const query = `uploadId=${uploadId}`
const body = `<CompleteMultipartUpload>${parts
.map(
(part) =>
Expand All @@ -379,11 +381,14 @@ export class S3Client extends AWSClient {
const signedRequest = this.signature.sign(
{
method: method,
protocol: 'https',
protocol: this.scheme,
hostname: host,
path: `/${objectKey}?${query}`,
path: `/${objectKey}`,
headers: {},
body: body,
query: {
uploadId: `${uploadId}`,
},
},
{}
)
Expand All @@ -408,14 +413,16 @@ export class S3Client extends AWSClient {
// Prepare request
const method = 'DELETE'
const host = `${bucketName}.${this.host}`
const query = `uploadId=${uploadId}`
const signedRequest = this.signature.sign(
{
method: method,
protocol: 'https',
protocol: this.scheme,
hostname: host,
path: `/${objectKey}?${query}`,
path: `/${objectKey}`,
headers: {},
query: {
uploadId: `${uploadId}`,
},
},
{}
)
Expand Down
Loading