Open tim3trick opened 4 years ago
I hope this pull request fulfills the requirements. I'm a go as well as a github beginner
@tim3trick Interesting. I have a very similar requirement; interested to see what happens to your PR.
Separately, can you share whether in your Docker scenario you are actually storing the uploaded files outside of the container? I would need to and haven't been able to figure out how to get that accomplished.
Hi @netaisllc, couldn't you do that with a volume bount to the containers files directory? I'm currently planning to create a (cron)job for regular cleanup of the files directory, and my first idea was to use a volume to be able to access the files from the outside and either use a cronjob on the host or setup another container with the single purpose of cleaning up the files
Is there a possibility to return data (e.g. via headers) to client from hook?
Just to quickly answer that question: No, such a way does not exist right now. Application-specific communication from the server to the client must be handled outside of tusd for now.
Yes, that would be the easiest solution, I second that, but that would also require me to either open the hook service to the outside world (including the setup for the proxy, including load balancing etc) or bring another service into play that handles this. And finally I would have to include a storage that keeps the relation between source file and my application-specific data persistent, even though I neither need that relation nor the source file any longer, once the workflow is completed.
I hope that by just adding the "bypass" in tusd for passing data from the hook to the client, I keep the changes to tusd as generic as possible and do not violate it's purpose.
I'm not sure to follow what's the advancement stage of this issue, but just to confirm, there is absolutely no way of sending any custom data to the client right now? Not even Through headers?
I need to make a shortened URL for the image, the only possible thing is to make another request by the client when the upload is finished?
but just to confirm, there is absolutely no way of sending any custom data to the client right now?
No, there is currently no easy way to do this. The only possible approach is to implement your own middleware which catches the responses from tusd and adds application-specific headers to it. But that is very error-prone and might break easily.
@Acconut , Is this issue in plan in near future? We @zulip thinking of integrating TusD for chunk upload support. The problem we are facing is we are moving files to a different location after upload finishes using pre-finish hook, and want to send the new location of the file. If we can send using hook(or in response), than it would be much easier to handle things at client side.
It would be great if we can add custom headers to all the blocking hooks.
Yes, there is a new hook system in v2 (https://github.com/tus/tusd/pull/672), which allows you to customize the responses from inside the blocking hooks. It's not yet released, but feel free to try it out. Documentation is lacking so far, but the examples might help you to get started: https://github.com/tus/tusd/tree/v2/examples
Also, it's nice to hear that Zulip is interested. I used your services frequently in the past :)
Thank you @Acconut, Can you tell when(estimated) the next release will come out?
There is no clear release date but we hope to finish v2 in the next two months.
Any update on this issue? The Zulip implementation for this is almost complete, and this issue is the main thing that's ugly about the implementation, so if v2 is on track to be ready for production use in the next month or so, we'll probably want to hold off on merging our tusd integration until this is merged.
The v2 release is shaping up well and is already feature-complete. It is mostly documentation that has to be added at this point. The release will be finished soon and I would recommend you to try out tusd v2. Once it is released, we will not be able to support tusd v1 anymore.
Question Is there a possibility to return data (e.g. via headers) to client from hook?
Details My current setup is a client sending a file to tusd inside a docker-container and a hook service inside a docker container. Hook service checks if the user is authenticated and authorized on pre-create, and finally calls an API on post-finish (that could be changed to pre-finish for blocking). The API generates a unique id for further handling of the given file. Can I somehow transfer the unique id back to the client, for example by setting a custom header "X-id" in the hooks response to tusd and tusd passing it to the client?