tomdesair / tus-java-server

Library to receive tus v1.0.0 file uploads in a Java server environment
MIT License
128 stars 60 forks source link

how can i manage the content stored on server side #13

Closed sunnyjocker closed 5 years ago

sunnyjocker commented 5 years ago

thank u for sharing such a good project, I found the uploaded content is stored at uploads folder of a name like uuid. But how can I get the list of the data information, because I may want to manually delete some content like old images or files. is there an API i can get them?

tomdesair commented 5 years ago

Hi @endlessbest,

I've created a form-submission example here: https://github.com/tomdesair/tus-java-server-dropwizard-demo

The part of the codes that processes any uploaded files after form submission can be found here: https://github.com/tomdesair/tus-java-server-dropwizard-demo/blob/master/src/main/java/me/desair/dropwizard/resources/IndexResource.java#L50

So the key is to pass all upload URL endpoints to the backend. The backend can then use the method getUploadedBytes and getUploadInfo to retrieve the bytes and metadata of the upload. However, you should treat uploads as temporary and move them to a permanent location (e.g. another folder on a shared disk or a blob store).

Once you've stored the upload bytes in a new, proper location, you can remove the temporary upload using method deleteUpload.

It's also recommended to regularly execute the cleanup method (see CleanUploadsCommand) to remove any stale, out-dated uploads.

Does this answer your question?

sunnyjocker commented 5 years ago

Hi @endlessbest,

I've created a form-submission example here: https://github.com/tomdesair/tus-java-server-dropwizard-demo

The part of the codes that processes any uploaded files after form submission can be found here: https://github.com/tomdesair/tus-java-server-dropwizard-demo/blob/master/src/main/java/me/desair/dropwizard/resources/IndexResource.java#L50

So the key is to pass all upload URL endpoints to the backend. The backend can then use the method getUploadedBytes and getUploadInfo to retrieve the bytes and metadata of the upload. However, you should treat uploads as temporary and move them to a permanent location (e.g. another folder on a shared disk or a blob store).

Once you've stored the upload bytes in a new, proper location, you can remove the temporary upload using method deleteUpload.

It's also recommended to regularly execute the cleanup method (see CleanUploadsCommand) to remove any stale, out-dated uploads.

Does this answer your question?

That's a good solution, thanks again

tomdesair commented 5 years ago

OK, I'm closing this issues as the question has been answered.