tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
2.93k stars 465 forks source link

Keep old metadata after modifying it in pre-create hook #1068

Closed Arahman-Khayat closed 2 weeks ago

Arahman-Khayat commented 5 months ago

We are using tusd v2 with s3 object storage, we used to face the large metadata error. However, this seems to be solved by enabling bi-directional communication in tusd v2, which allowed us to modify the metadata before sending it to the s3 storage.

The problem is, if we modified the metadata in the pre-create hook, it will be lost, and we don't want to create the object (that holds the metadata and other attributes) in our api prematurely (i.e. in pre-create hook).

So, the question is, is there a way to keep the old metadata after modifying and sending it to object storage? or is there any other hook that can be used? or maybe another appraoch?

Acconut commented 5 months ago

Once the pre-create hook modifies the meta data object, future hooks will not receive the original hook object anymore. However, the post-create hook receives all request header fields that were included in the upload creation request. This also includes the Upload-Metadata header as sent by the client without any modifications. You can parse this header on your own and therefore read the original meta data. I think that should allow you to do what you are asking for.