Skip to content

Commit

Permalink
feat: allow setting contentEncoding during compose (#2431)
Browse files Browse the repository at this point in the history
* feat: allow setting contentEncoding during compose

* 馃 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
zuozp8 and gcf-owl-bot[bot] committed Apr 15, 2024
1 parent 261d119 commit 6e81e05
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
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

0 comments on commit 6e81e05

Please sign in to comment.