Skip to content

Commit

Permalink
@tus/gcs-store: correctly pass content type (tus#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
Murderlon authored Jan 20, 2025
1 parent c970858 commit 8217f5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-terms-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tus/gcs-store": patch
---

Correctly pass the content type from upload.metadata to GCS.
7 changes: 5 additions & 2 deletions packages/gcs-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -35,14 +35,17 @@ 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,
...this.#stringifyUploadKeys(file),
},
},
}
if (file.metadata?.contentType) {
options.contentType = file.metadata.contentType
}
const fake_stream = new stream.PassThrough()
fake_stream.end()
fake_stream
Expand Down

0 comments on commit 8217f5e

Please sign in to comment.