Upload a file to server and have it password-protected for download

Hi all,

bear with me for posting this under “General” but I could not find a better category.
I would like to get some hints on how to achieve the following:

We need to upload certain files to a nextCloud server in an unattended way, so by using a command-line client - and this is no problem in itself, and those files must be shared (whoever has the link is allowed to download them). At the same time, we need those files to be password protected, so that one has to know the correct password to be able to download them. We do not need that password to be different for each uploaded file: a static password would be fine, but we need those file to get automatically protected as soon as they are uploaded to the server.

Is it possible to achieve this?

Thank you in advance for any suggestions.
Adriano

You can password protect share links.

I know that, but AFAIK it requires creating the sharing link by hand (i.e. interactively), and password-protect the same way (i.e. interactively).
The point is, we need to do these things in an unattended way, i.e. via some command-line client and related arguments, or via some API.

I think this is not possible with Nextcloud. I also think Nextcloud is not the correct software for you.

Maybe you can use client side encryption. Maybe not necessary but at least meets your requirements.

  • you have got file “filename.txt”
  • zip file with e.g. command line 7z and aes256 password
  • compute sha256sum from filename.7z (for name, not encryption)
  • rename filename.7z to sha256sum-filename.7z
  • alternative is to use e.g. time for individual names
  • upload to a normal webserver (no authentication needed)
  • share link: https://server.tld/sha256sum-filename.7z
    […]
  • download https://server.tld/sha256sum-filename.7z (no authentication needed)
  • unzip with aes256-password

Because of sha256sum there never problems with same file name.
Also you can use other mechanisms e.g. time.
Use additional time and date for possibility to delete all files from one day, …

Thank you, but we had already considered that option, and it’s not what we would like to do.

I take your word that our goal cannot be achieved with nextCloud.
Thank you.

Maybe you can read Clients and Client APIs.

Some ideas can be found at Batch mode link sharing - #10 by tazinblack