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 Answers1

2

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

seanrose
  • 8,185
  • 3
  • 20
  • 21
  • 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: http://stackoverflow.com/questions/10890973/box-api-v2-uploading-multiple-files-per-single-request-is-limited-to-20 – user2777914 Sep 16 '13 at 15:46
  • Yes, it used to, but it was so infrequently used that it didn't make sense for us to maintain the separate code path – Peter Sep 18 '13 at 19:12