Open softboy99 opened 5 years ago
I am not sure, what you are trying to do here..
You can look at the DiskStorageService implementation.
what i want is just to move the upload to another disk location when the upload completed. so i need to check ui.isUploadInProgress()
you should extend the DiskStorageService class and override the update method.
public void update(UploadInfo info) throws IOException, UploadNotFoundException {
super.update(info);
if (!info.isUploadInProgress()) {
logger.debug("upload completed ");
// Do your stuff here..
}
}
and make sure while initializing TusFileUploadService set the storageService as your extended class/object -- withUploadStorageService()
Hi,
The library assumes that the upload is part of some web form. This means that FileUploadController
will indeed only see "in progress" uploads as it will process the upload when the user is filling in the rest of the form.
After the user submits the form, a FormSubmissionController
will then see all the completed uploads. You can take a look at the Dropwizard example here. I'll try to also extend my Spring Boot example with a form submission flow.
However, this indeed does not cover use cases where the file upload might happen without any web form (e.g. pure file transfers). I'm thinking about adding some kind of TusEvent
callback system that would allow users of the library to add custom callbacks/code when certain type of Tus events happen like UPLOAD_CREATED
, UPLOAD_COMPLETED
, UPLOAD_FAILED
, UPLOAD_CHUNK_PROCESSED
, UPLOAD_DELETED
...
For your use case, you could then add your own TusEventCallback
implementation that listens to the UPLOAD_COMPLETED
event. It can then do some custom processing on every completed upload like moving the file.
I'll see if I can work something out for this in the code in the coming days/weeks.
You can also take a look at this example: https://github.com/ralscha/blog2019/blob/51374dd/uploadtus/server/src/main/java/ch/rasc/upload/UploadController.java#L50
This developer seems to be doing something similar as you without the need for a separate form controller.
Hi,
The library assumes that the upload is part of some web form. This means that
FileUploadController
will indeed only see "in progress" uploads as it will process the upload when the user is filling in the rest of the form.After the user submits the form, a
FormSubmissionController
will then see all the completed uploads. You can take a look at the Dropwizard example here. I'll try to also extend my Spring Boot example with a form submission flow.However, this indeed does not cover use cases where the file upload might happen without any web form (e.g. pure file transfers). I'm thinking about adding some kind of
TusEvent
callback system that would allow users of the library to add custom callbacks/code when certain type of Tus events happen likeUPLOAD_CREATED
,UPLOAD_COMPLETED
,UPLOAD_FAILED
,UPLOAD_CHUNK_PROCESSED
,UPLOAD_DELETED
...For your use case, you could then add your own
TusEventCallback
implementation that listens to theUPLOAD_COMPLETED
event. It can then do some custom processing on every completed upload like moving the file.I'll see if I can work something out for this in the code in the coming days/weeks.
Hi Tom, We would welcome this functionality in the standard library. In our current project, we capture these events by extending few methods on the DiskStorageService class and do some custom processing as we needed.
@Controller @RequestMapping("/upload") public class FileUploadController { @Value("${tus.server.data.directory}") protected String tusDataPath;
}