3

I am working on a Java application that will move files and folders to box.com. I am consuming the REST API V2 and was able to upload a single file by making a multpart post to the endpoint: https://upload.box.com/api/2.0/files/content.

Is it possible to upload multiple files to box.com by making a single post call? If so, what would the post call look like?

Here is a code snippet showing how I upload a single file:

Client client = Client.create();
File thefile = new File(PATH_TO_FILE/FILE_NAME.pdf);
WebResource webResource = client.resource("https://upload.box.com/api/2.0/files/content");
FormDataMultiPart form = new FormDataMultiPart();

form.bodyPart(new FileDataBodyPart("filename", thefile, MediaType.APPLICATION_OCTET_STREAM_TYPE));
form.field("filename", "test.pdf");
form.field("parent_id", parentId);

ClientResponse response = webResource.type(MediaType.MULTIPART_FORM_DATA).header(
"Authorization", "Bearer " + getBoxTokenProperty(GRANT_TYPE_ACCESS_VAL)).post(ClientResponse.class, form);

Thanks in advance!

1 Answer 1

2

Currently the Box API only supports uploading a single file per request.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the response, seanrose. Did the API handle multiple file uploads per request in the past? I looked at the following post on this site, which states that it does: stackoverflow.com/questions/10890973/…
Yes, it used to, but it was so infrequently used that it didn't make sense for us to maintain the separate code path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.