Missing documentation on occ for `files:put`

Greetings, thank you for the wonderful work on NextCloud.
I got to a point where using occ on the command line to upload files is an option for a custom workflow script that I’m doing on my instance.
Just by looking at the cli help I could see occ files:put command.

php occ files:put --help
Description:
  Write contents of a file

Usage:
  files:put <input> <file>

Arguments:
  input                 Source local path, use - to read from STDIN
  file                  Target Nextcloud file path to write to or fileid of existing file

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --no-warnings     Skip global warnings, show command output only
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

This however is missing from the occ documentation along with the mechanism for file uploads. The command works and adds a file to the storage. However it does not support versioning for the uploaded files and it remains unclear why. Is this just a shorthand for files:scan or a different call?

Regards,
Daniel

However it does not support versioning for the uploaded files and it remains unclear why.

Interesting. I’d expect it to be covered since versioning gets picked up through the event listener.

Is this just a shorthand for files:scan or a different call?

You mean like is it just dropping a file via the underlying filesystem than running a scan? No, looks like it’s creating the file through the Node OCP\Files* API.

Not sure the specifics of your use case, but another option would be uploading via WebDAV API. Versioning definitely works there.

P.S. This is a a newer command (along with get and delete) added via this PR. I guess no one got around to adding it to the occ command list in the Admin Manual yet. If you happen to feel so inclined, feel free to submit a PR to the GitHub - nextcloud/documentation: 📘 Nextcloud documentation repository.

3 Likes

Thank you so much for the quick reply.
I ended up using the WebDAV as it correctly sets ownership of the file and creates revisions as opposed to the occ files:put .
I honestly do not feel confident yet in submitting PRs to the documentation as am yet to grasp the greater structure behind NextCloud’s codebase(which is vast).

Regards,
Daniel

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.