Reputation: 31
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!
Upvotes: 3
Views: 2166
Reputation: 8695
Currently the Box API only supports uploading a single file per request.
Upvotes: 2