Needing help with accessing box metadata and downloading files via API

New post

Comments

6 comments

  • Chris Dascalos

    Hey Jonas Abersbach,

    What type of work are you looking to have completed specifically, do you have a workflow that you could share so that the community could assist in providing some feedback on design?

    We could then potentially point you to a contract house or two that might have experience with the Box API and where to host your tools / utilities, OR you could look for an existing Box App that accomplishes close to what you are looking to do and reach out directly to the developer.

    Hopefully this helps!

    0
    Comment actions Permalink
  • Jonas Abersbach

    Hi Chris,

    We have a box folder that contains files and sub-folders.  The files have metadata attached (5 text fields that the external collaborator populates when uploading files to us).

    We need to programmatically download the files from box to our local file server. The metadata fields can be embedded in the downloaded file name, by renaming the downloaded file with the original file name, and the metadata fields postfixed to the file name, perhaps "-" delimitted.

    The script would run every 10 minutes and perform this download. Then delete or archive the files located on box.com.

    We could just use the box provided synch tool for the files, but I don't think that downloads the metadata. Yes, a contract house would be great or even just an individual developer who is familiar with box API.

    Jonas

    0
    Comment actions Permalink
  • Chris Dascalos

    Hey Jonas Abersbach,

    What you are trying to accomplish sounds simple enough in nature. The largest benefit you have is that your high level folder is fixed so not too much complex logic involved. Below is the chain of events that needs to happen. I am ignoring the authentication piece assuming you are going to have a Box Application with JWT authentication so that it is not tied to any one user.

    1. List Items in Folder (Folder ID in Web URL) [https://developer.box.com/reference/get-folders-id-items/]
    2. Loop Through Items (For / While Loop)
    3. Capture File ID [Reference - https://developer.box.com/reference/resources/file/]
    4. Capture File Metadata [https://developer.box.com/reference/get-files-id-metadata/]
    5. Download File [https://developer.box.com/reference/get-files-id-content/]
    6. Rename File (mv "FILE" "FILE - META1 - META2 - META3 - META4 - META5")
    7. Delete File (Caution! Deleting is dangerous) [https://developer.box.com/reference/delete-files-id/]

    This could very easily be accomplished with a CRON job and if you do not want to expose your server to other services or additional internal authentication I would suggest running the CRON job from the same server you would like the files to wind up on.

    Most of my scripting is written with CURL when interacting with APIs and JQ for handling the JSON responses.

    Not sure if this helps, but for someone with experience might take a day worth of dedicated programming and then some additional consideration for how to manage the deletion of files which I would suggest against. I would point you in the direction of a retention policy and moving the content into a folder where the policy applies so that if for some reason you did not get the content you are looking for there is a chance it will still exist somewhere just as an insurance policy.

    I would also throw in a request to the Get File Information API so that you can compare the SHA-1 of the file once it is downloaded (https://developer.box.com/reference/get-files-id/) as another step for good measure if you are going to be deleting content.

    Hopefully this helps get you started and if you have any questions on the above information let me know and I will do what I can to assist!

    0
    Comment actions Permalink
  • Jonas Abersbach

    Hi Chris,

    Yes that's what we want to do. Are you or someone you can refer able to implement this for a fee? You could contact us directly at jabersbach@cci-cic.org

    Best regards,

    Jonas

     

    0
    Comment actions Permalink
  • Chris Dascalos

    Hey Jonas Abersbach,

    Unfortunately I do not have the bandwidth along with my full time job to assist otherwise I would be happy to! I will see if I can circulate this around with a few others I know and see if anyone else has time to assist. How quickly are you looking for a turnaround on this?

    Just to confirm my assumption, I imagine this would be running on a Windows server?

    Have a great day!

    0
    Comment actions Permalink
  • Jonas Abersbach

    Hi Chris,

    Yes it's for windows and we would like to implement as soon as possible. Please share my e-mail jabersbach@cci-cic.org and have them reach out directly to me. That would be great.

    Jonas

    0
    Comment actions Permalink

Post is closed for comments.