9

I have build processes which are built around Windows batch files, and when successful, I want to upload the results to a Box.com account. Is there a way of doing this via the command line? Although the drag and drop interface of Box.com is OK, it remains the one manual step in the chain.

7

Box supports WebDAV, FTP (only for business and enterprise customers) and has an API.

So you could either use a tool to mount the WebDAV entry as a drive, use FTP from the command line or install something like cURL and use the API from the command line. Note that the main support for the API is listed as being via StackOverflow!

Obviously, if you have Box sync installed, you can simply copy files into the sync folder as well.

In Windows \\dav.box.com@SSL\DavWWWRoot\dav is the URN to connect.

If you express a preference in the comments, I'll try to add more detail but I have to run now.

  • Thanks for your comments. I don't have a business account so webdav or FTP is out. I'm thinking that maybe using a packet sniffer to watch what happens when I upload a file using the web interface is the way to go. – rossmcm May 27 '14 at 0:56
  • 1
    Have a look at the api, since CURL is listed as an "interface", it should be possible to do what you want. – Julian Knight May 27 '14 at 10:53
  • 1
    Thanks. Just tried it with a 12 Mb file (got cURL from confusedbycode.com/curl) and it went without a hitch using the command line example provided by @phobic: curl -u me@email.com:mypassword -T local_file_path https://dav.box.com/dav/remote_file_name – rossmcm May 28 '14 at 13:22
  • Fab! I saw that there is also a WinCURL if you need to use IE settings as well. Clearly, in this case, you don't. – Julian Knight May 28 '14 at 20:45
9

Sorry, I cannot comment (needs 50 Reputation). As Julian mentioned, you can use WebDAV. This is also enabled for non business accounts; use the URL https://dav.box.com/dav. The folder can not seem to be mounted in windows: http://www.onemetric.com.au/Documentation/Mounting-A-WebDAV-Share-Windows-7 I think this is a Web Server problem. But you can use curl:

curl -u me@email.com:mypassword -T local_file_path  https://dav.box.com/dav/remote_file_name
curl -u me@email.com:mypassword  https://dav.box.com/dav/remote_file_name --output download_file_path
  • For mounting WebDAV in Windows, you need to use the format I've shown in my answer. Alternatively, there are 3rd party tools that will help. – Julian Knight May 28 '14 at 20:44
  • +1 for this working out of the box on linux/osx/*nix machines – PressingOnAlways Jul 12 '16 at 15:21
  • Also, if there are spaces in the remote_file_name or folder, you would need to encode it with %20 eg: remote%20file%20name. – Rekovni Jan 5 '18 at 15:12
1

I wrote PrintToBox to solve this need for enterprises using Linux/Unix. It uses Box's Java SDK so you must have JDK 7 or JDK 8 installed. I intend to port it to Windows and to Box Platform (to take advantage of App Auth/App Users) but it's not there yet (help wanted, heh).

1

If you have worked with R language, there is a nice package at https://github.com/brendan-r/boxr for interacting with box via commandline.

0

You may find Couchdrop useful for this. Couchdrop allows you to SCP, Rsync and SFTP to Box from your terminal. It uses the native termianl applications, therefore you do not need to install new software. All with the standard syntax you already know.

https://couchdrop.io

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.