How to show a warning before every file upload?

Hello everyone,

I would like to develop an app which asks the user to confirm every upload they do (both drag&drop and by the upload button) in a dialog as like this:

“Are you sure you want to upload this file into folder [foldername]?”

How can I accomplish that in my app’s JavaScript? Is there an event for file uploads that can be consumed?
Am I supposed to use the package nextcloud/event-bus? If so, which event can I subscribe to?
The targeted NextCloud version is 17 and above.

I couldn’t find any information about this in the docs, so I hope someone could kindly help me :slight_smile:

Thank you very much!

Alex

There aren’t many events on the event bus right now and there is certainly none for uploads on Nextcloud 17

Thanks for your reply. Any other idea how I could solve this issue?

@PVince81 maybe you have an idea?

I don’t think there is any event for this.
Also what you’d need is not only an event but also a way to block the normal flow of uploads, basically “cancelling” the upload from your event handler.

In any case, you could have a look at server/file-upload.js at master · nextcloud/server · GitHub which is the file that handles uploads.
For drag and drop, see server/filelist.js at master · nextcloud/server · GitHub and server/filelist.js at master · nextcloud/server · GitHub. You’ll likely need to patch that code somehow.

1 Like

@alberto93
Do you really need a warning for uploading to cloud on a cloud platform?
You also do not have an info on cow milk packages that it is cow breast milk normally for a calf from mixed of hundreds breastfeeding female cows.

@PVince81 Thank you for your help! I will check it out.