4 file
Markus Bergholz edited this page 2021-07-23 10:14:48 +00:00

markuman.nextcloud.file

The file module supports also access_token as an alias for api_token, to be closer on ansible S3 module.
The file module supports also check_mode: yes parameter.

overwrite: parameter is handling what happen when the file already exist.

overwrite: always is the default!

overwrite parameter value desc
always The file in destination will always be overwritten
different The file in destination will be overwritten when the md5sum differs from source
different_size The file in destination will be overwritten when its size differs from source
never The file in destination will never be overwritten

different is base on md5sum. In that case, the file will be downloaded, keep in memory for comparison and write to destination in case it's different.
Therefore it might be not practical for very large files!

mode: get

- name: fetch file from nextcloud
  markuman.nextcloud.file:
    mode: get
    src: anythingeverything.jpg
    dest: /tmp/anythingeverything.jpg

mode: delete

- name: delete file on nextcloud
  markuman.nextcloud.file:
    mode: delete
    src: bla.docx

To delete a folder (recursively), you can use the extra parameter delete_recursively: yes (default is no)

- name: delete file on nextcloud
  markuman.nextcloud.file:
    mode: delete
    src: Photos
    delete_recursively: yes

mode: put

Available overwrite parameters for put mode are: never, always, different_size

- name: upload file on nextcloud
  markuman.nextcloud.file:
    mode: put
    src: /tmp/testtt.jpg
    dest: testtt.jpg