diff --git a/.changeset/proud-terms-swim.md b/.changeset/proud-terms-swim.md new file mode 100644 index 00000000..9d20b0ad --- /dev/null +++ b/.changeset/proud-terms-swim.md @@ -0,0 +1,5 @@ +--- +"@tus/gcs-store": patch +--- + +Correctly pass the content type from upload.metadata to GCS. diff --git a/packages/gcs-store/src/index.ts b/packages/gcs-store/src/index.ts index b14f48c7..f38c6319 100644 --- a/packages/gcs-store/src/index.ts +++ b/packages/gcs-store/src/index.ts @@ -1,4 +1,4 @@ -import type {Bucket} from '@google-cloud/storage' +import type {Bucket, CreateWriteStreamOptions} from '@google-cloud/storage' import stream from 'node:stream' import type http from 'node:http' import debug from 'debug' @@ -35,7 +35,7 @@ export class GCSStore extends DataStore { file.storage = {type: 'gcs', path: file.id, bucket: this.bucket.name} - const options = { + const options: CreateWriteStreamOptions = { metadata: { metadata: { tus_version: TUS_RESUMABLE, @@ -43,6 +43,9 @@ export class GCSStore extends DataStore { }, }, } + if (file.metadata?.contentType) { + options.contentType = file.metadata.contentType + } const fake_stream = new stream.PassThrough() fake_stream.end() fake_stream