1

I am using cURL successfully to upload files to box.com storage:

::   send file to Box.com
::
::   Syntax: sb.bat <username> <password> <filename> [<destination filename>]

@setlocal enabledelayedexpansion

@set OutFile=https://dav.box.com/dav/%~4
@if "%~4" equ "" set OutFile=https://dav.box.com/dav/%~nx3

@echo Sending file: "%~dpnx3" 
@echo Destination : "%OutFile%"
@set replace=%%20
@set OutFile=%OutFile: =!replace!%
curl --insecure -u %1:%2 -T "%~3" "%OutFile%"
@if %ErrorLevel% neq 0 echo CURL returned error code of %ErrorLevel%
@exit /b  %ErrorLevel%

The command fails however if the destination folder doesn't already exist, and I can't find any examples or documentation of how you might use cURL to create a folder in Box.com storage.

** UPDATE **

Here's the resulting batch routine, based on the accepted answer from Anaksunaman.

::   create a folder at Box.com
::
::   Syntax: cf.bat <username> <password> <pathname>    

@setlocal enabledelayedexpansion

@set NewPath=https://dav.box.com/dav/%~3

@echo Creating folder: "%NewPath%"
@set replace=%%20
@set NewPath=%NewPath: =!replace!%
@set replace=/
@set NewPath=%NewPath:\=!replace!%
curl --insecure -u %1:%2 -X MKCOL "%NewPath%"
@if %ErrorLevel% neq 0 @echo cURL returned error code of %ErrorLevel%
@exit /b  %ErrorLevel%

1 Answer 1

2

The URL you are accessing (https://dav.box.com/dav/) is the URL for WebDAV support from Box. Therefore, you should be able to use normal WebDAV requests with it.

In your case, to create a folder, you would use -X MKCOL with cURL (where MKCOL is the WebDAV request method to create a "collection" i.e. a directory). Try e.g.:

curl --insecure -u %1:%2 -X MKCOL "https://dav.box.com/dav/test-folder"

Where %1:%2 are email:password, as in the rest of your script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .