Skip to main content

I have a requirement to copy files from a source folder to target folder/sub-folders based on certain file types and conditions on a given schedule or when a file is placed in the source folder. The source folder and target folder exists within Box with different user permissions. The source files must always exits in the source folder and never be moved, only a copy of it will be copied to the target folder based on the type/criteria. Can you please suggest me an approach on how I could accomplish this requirement? I am thinking that I should use Box APIs, but suggestion or approach would be much appreciated. 

 

Thanks

Sentha


Hello Sentha,


 


The Box API would be a good solution to your issue. You can use the copy file endpoint, which allows you to copy a file to any folder. If you want to do this every time a file is uploaded to a specific folder, I would look into the webhook endpoint. You can set a webhook on a folder, so every time a file is uploaded to the folder, an HTTP request with information on the file uploaded is sent to your server. On your server, you can implement logic that calls the copy endpoint on the file if it meets your criteria. The documentation for these endpoints can be found here: https://developer.box.com/reference


 


I also recommend taking a look at our SDKs, https://github.com/box/sdks. They can help you get up and running quickly. I hope this helps!



Hi,

 

Thank you for the details. Is there any examples that you can point. I am new to BOX APIs and would like to have this in place as quick as possible. I have been hearing about Relay, will that be of use for this requirement?

 

Sentha



If you have access to Relay, that is the easier option. If you have access, it will show on your side pane (picture below). Using Relay is very intuitive. Once you click on Relay, click on New Workflow. This will take you through the steps of creating a workflow for your use case.


BOX_kw82wrnqgsxgr4i6dv5tt6varslc19sb.png



Hi,

 

I have access to relay, however it only allows to move files across folders. Is there an option to Copy, schedule and write criteria's for copying files. 

 

Can you please share examples of file operations using APIs? 

 

Thanks

Sentha



You can write metadata to the copied files or assign tasks with Relay. For more custom editing of the files, you would have to use the API. You can make API requests in multiple coding languages. We have SDKs to make it easy to make these requests in multiple languages. For each SDK we have documentation on how to make calls with it. If you go to any of our SDKs on github (https://github.com/box/sdks) and click docs in the SDK github repository, you will find the documentation. For example, this is the file commands documentation for the Python SDK: https://github.com/box/box-python-sdk/blob/master/docs/usage/files.md#copy-a-file. If there is a specific language you have in mind, I can point you to the documentation.


 


 


 



Reply