Download files from share with ansible

Discussion in 'LiquidFiles General' started by Romu, Jul 12, 2019.

  1. Romu

    Romu New Member

    Joined:
    Jul 12, 2019
    Messages:
    4
    Likes Received:
    0
    Hello !

    I'm trying to download files with ansible, using the share feature, and a user API.
    I'm not developper at all and I'm struggling.

    Please any one tried this already (with success ;-) ) ?

    Thank you !
     
  2. David

    David Administrator
    Staff Member

    Joined:
    Dec 1, 2015
    Messages:
    684
    Likes Received:
    15
    Ansible is using usually shell scripts to performs some operations on the machine which is being automatically administered.
    So from this point of view it does not matter if that required tasks in a script are driven by Ansible or by any other SW.

    If you need to download files from a Share on a LF server you will need to use Download Share API together with Curl added in the shell script.
    The script you can test on any linux box if it works and then transfer it to your Ansible.

    A simple row which downloads a specific file from a Share looks like this:
    curl -X GET -H "Content-Type: application/json" --user nkpIxMK9ucUUE7FvfNpdAf:x https://test.host/shares/project-alpha/folders/goals/files/goals-2017-docx/download
    (API key of a user who has permission to this Share is required)

    To download all files from a folder in a Share you will need to list the content of the folder first and then download the files inside one by one in a loop.
     
  3. Romu

    Romu New Member

    Joined:
    Jul 12, 2019
    Messages:
    4
    Likes Received:
    0
    Thank you David,
    All clear but I must have problem, as the following command works :

    curl -X GET -H "Content-Type: application/json" --user xxxxx:x https://url/shares/sources/folders/MyFolder/files/files_19-2_2019-07-11-zip/


    -> reponse :

    {"file":{"id":"files_19-2_2019-07-11-zip","folder_id":"19-2","name":"files_19-2_2019-07-11.zip","size":208233799,"size_to_human":"199 MB","content_type":"application/zip","checksum":"078a6f292d8a6d87ea7fe903d11b8dbb7bb1e0b076d25d62c61e7c27d59e83ba","crc32":"ee6081a2","av_scanned":true,"av_infected":false,"deleted":false,"created_at":"2019-07-11T12:07:52.760+02:00","updated_at":"2019-07-11T12:07:54.715+02:00"}}


    But the following (just adding /download) fails :

    curl -X GET -H "Content-Type: application/json" --user xxxxx:x https://url/shares/sources/folders/MyFolder/files/files_19-2_2019-07-11-zip/download

    -> reponse
    {"error":{"path_not_found":"/shares/sources/folders/MyFolder/files/files_19-2_2019-07-11-zip/download"}}


    Did I miss something ?

    Kind Regards

    Romuald
     
  4. Romu

    Romu New Member

    Joined:
    Jul 12, 2019
    Messages:
    4
    Likes Received:
    0
  5. Romu

    Romu New Member

    Joined:
    Jul 12, 2019
    Messages:
    4
    Likes Received:
    0
    Using -L for following the SAML redirection, and --output file.zip makes the job.
     

Share This Page