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

Allow for the server to respond with metadata #164

Open
rockwotj opened this issue Sep 15, 2020 · 9 comments
Open

Allow for the server to respond with metadata #164

rockwotj opened this issue Sep 15, 2020 · 9 comments

Comments

@rockwotj
Copy link

Hello, I just stumbled across TUS today, and I think it's awesome! Thanks for working on this.

I'd like to use this for my company's uploads, but the server does some post processing after uploading to add some metadata (think things like image dimensions, exif data, video length, etc). I don't see a place in the protocol to allow for responding with extra information upon completion, and the client's don't seem to expose the final server response in order to extract information like this.

Would a maintainer accept an extension to the protocol to allow for such server-based postprocessing?

@Acconut
Copy link
Member

Acconut commented Sep 16, 2020

Thanks for the kind words!

the server does some post processing after uploading to add some metadata (think things like image dimensions, exif data, video length, etc)

The server can always add additional metadata to the upload that the client can fetch using a HEAD request. Using that workaround that is already possible.

client's don't seem to expose the final server response in order to extract information like this

That depends on the clients, of course. tus-js-client, for example, allows to obtain the responses from the server to inspect them for additional data.

Would a maintainer accept an extension to the protocol to allow for such server-based postprocessing?

We're always open a discussion, yes. You might also want to look into #159 where the topic of post-processing also appears.

@rockwotj
Copy link
Author

The server can always add additional metadata to the upload that the client can fetch using a HEAD request. Using that workaround that is already possible.

This means it has to be a header yes? We have just enough metadata I'm not super comfortable sticking it in a header, because certain proxies have limits on how long headers can be (I believe NGINX is such an example), but I guess we could break it up between lots of different headers, which may work... Or I guess I could return a 200 from a PATCH request (instead of the 204 tusd responds with) and set the metadata there on the final upload.

We're always open a discussion, yes. You might also want to look into #159 where the topic of post-processing also appears.

I'll hop into that discussion and see if I can be helpful.

@Acconut
Copy link
Member

Acconut commented Sep 16, 2020

This means it has to be a header yes?

Yes, metadata is transported using the Upload-Metadata header.

I'll hop into that discussion and see if I can be helpful.

👍

@smatsson
Copy link

@Acconut

The server can always add additional metadata to the upload that the client can fetch using a HEAD request. Using that workaround that is already possible.

Should we clarify this in the spec? The only mention of client/server that I can find right now is this which gives the impression that only the client can supply metadata.

The Client MAY supply the Upload-Metadata header to add additional metadata to the upload creation request. The Server MAY decide to ignore or use this information to further process the request or to reject it. If an upload contains additional metadata, responses to HEAD requests MUST include the Upload-Metadata header and its value as specified by the Client during the creation.

@Acconut
Copy link
Member

Acconut commented Sep 18, 2020

Should we clarify this in the spec? The only mention of client/server that I can find right now is this which gives the impression that only the client can supply metadata.

Good point, yes we should do that!

@smatsson
Copy link

After reading the spec a couple of more times, I'm wondering if the server can actually change the metadata? It seems that this is explicitly forbidden in the current spec:

The Client MAY supply the Upload-Metadata header to add additional metadata to the
upload creation request. The Server MAY decide to ignore or use this information to
further process the request or to reject it. If an upload contains additional
metadata, responses to HEAD requests MUST include the Upload-Metadata header
and its value as specified by the Client during the creation.

"As specified by the Client during the creation" being the key part. If the Server changes the metadata it is no longer "as specified by the Client" unless the Server's changes are not included in the HEAD response. But then again, the Client can't access it. Any input @Acconut?

@RubenGarcia
Copy link
Contributor

RubenGarcia commented Sep 28, 2020

I would have expected that after a successful upload, the server would send a Location header. Then the client could use this Location header to inquire about relevent metadata, possibly at a different endpoint, as this additional metadata looks to me to be outside of the tus protocol. For example: "Location https://service/uploads/path" -> "GET https://service/metadata?location=uploads/path"

@Acconut
Copy link
Member

Acconut commented Sep 28, 2020

@smatsson: After reading the spec a couple of more times, I'm wondering if the server can actually change the metadata? It seems that this is explicitly forbidden in the current spec

You are right, I forgot about that wording. IIRC, we added this sentence so that servers cannot change metadata keys that were sent by the client. For example, the client sets filename hello.txt and the server later responds with filename hello.TXT. From this perspective my last comments are wrong and the current metadata system cannot be used to send values back to the client.

@RubenGarcia I would have expected that after a successful upload, the server would send a Location header. Then the client could use this Location header to inquire about relevent metadata, possibly at a different endpoint, as this additional metadata looks to me to be outside of the tus protocol.

This would also be a possible approach we have thought about. Maybe you want to take a look at the discussion at #159 and especially the comment at #159 (comment).

@smatsson
Copy link

smatsson commented Sep 30, 2020

@Acconut I think it's a fair trade off so I'll just skip the PR for clarifying the spec and leave it to the upcoming post processing extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants