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

feat: allow setting contentEncoding during compose #2431

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
json: {
destination: {
contentType: destinationFile.metadata.contentType,
contentEncoding: destinationFile.metadata.contentEncoding,
},
sourceObjects: (sources as File[]).map(source => {
const sourceObject = {
Expand Down
5 changes: 2 additions & 3 deletions src/nodejs-common/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ export class Service {
};

if (reqOpts[GCCL_GCS_CMD_KEY]) {
reqOpts.headers[
'x-goog-api-client'
] += ` gccl-gcs-cmd/${reqOpts[GCCL_GCS_CMD_KEY]}`;
reqOpts.headers['x-goog-api-client'] +=
` gccl-gcs-cmd/${reqOpts[GCCL_GCS_CMD_KEY]}`;
}

if (reqOpts.shouldReturnStream) {
Expand Down
5 changes: 2 additions & 3 deletions src/resumable-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,8 @@ export class Upload extends Writable {
// `Content-Length` for multiple chunk uploads is the size of the chunk,
// not the overall object
headers['Content-Length'] = bytesToUpload;
headers[
'Content-Range'
] = `bytes ${this.offset}-${endingByte}/${totalObjectSize}`;
headers['Content-Range'] =
`bytes ${this.offset}-${endingByte}/${totalObjectSize}`;
} else {
headers['Content-Range'] = `bytes ${this.offset}-*/${this.contentLength}`;
}
Expand Down
5 changes: 2 additions & 3 deletions src/transfer-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ class XMLMultiPartUploadHelper implements MultiPartUploadHelper {

// Prepend command feature to value, if not already there
if (!value.includes(GCCL_GCS_CMD_FEATURE.UPLOAD_SHARDED)) {
headers[
key
] = `${value} gccl-gcs-cmd/${GCCL_GCS_CMD_FEATURE.UPLOAD_SHARDED}`;
headers[key] =
`${value} gccl-gcs-cmd/${GCCL_GCS_CMD_FEATURE.UPLOAD_SHARDED}`;
}
} else if (key.toLocaleLowerCase().trim() === 'user-agent') {
userAgentFound = true;
Expand Down
6 changes: 3 additions & 3 deletions test/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,13 +745,13 @@ describe('Bucket', () => {
});

it('should make correct API request', done => {
const sources = [bucket.file('1.txt'), bucket.file('2.txt')];
const destination = bucket.file('destination.txt');
const sources = [bucket.file('1.foo'), bucket.file('2.foo')];
const destination = bucket.file('destination.foo');

destination.request = (reqOpts: DecorateRequestOptions) => {
assert.strictEqual(reqOpts.uri, '/compose');
assert.deepStrictEqual(reqOpts.json, {
destination: {contentType: mime.contentType(destination.name)},
destination: {contentType: undefined, contentEncoding: undefined},
sourceObjects: [{name: sources[0].name}, {name: sources[1].name}],
});

Expand Down
Loading