Hi, I’ve got a nextcloud install working, but I have a bit of an odd usecase.
I need to disable file uploads from certain locations, but allow them from others.
Due to the situation, the location which should not be able to upload will be using a specific browser, and not have permissions to install the desktop app.
Thus, by either blacklisting uploads from the specific browser (Chrome), or blacklisting uploads from all browsers but allowing it from the desktop/mobile apps, I can accomplish what I need.
Is there any way to accomplish this?
---- EDIT ----
Didn’t want to zombie the thread, but figured I’d post the solution that I wound up on:
in the file ‘apps\files\templates\list.php’ in your root nextcloud folder, the lines 2-7:
<div class="actions creatable hidden">
<div id="uploadprogresswrapper">
</div>
</div>
<div id="file_action_panel"></div>
<div class="notCreatable notPublic hidden">
→
<div id="file_action_panel"><?php echo ""; ?></div>
<div>
will disable the upload button and cause the “You don’t have permission to upload or create files here” on line 9 to be displayed along with the alert icon.
Lines 75-77:
<div class="hiddenuploadfield">
<input type="file" id="file_upload_start" class="hiddenuploadfield" name="files[]" />
</div>
→ delete
will disable drag-and-drop uploading.
You can, of course, add any logic you wish to check username, browser user agent, client IP, etc, to apply these changes (or not) in order to selectively disable file uploading. It most certainly is not foolproof, as it doesn’t remove the backend code, and thus the user could simply inspect → inject the changed/removed parts back in (or evade any user agent matching, use a VPN, etc). However, as a method to prevent naive users from uploading via the browser, it’s worked great for me for the past year.