ファイル全体をアップロードする前に、ファイルがBoxで受け入れられるかどうかをチェックします。
curl -i -X OPTIONS "https://api.box.com/2.0/files/content" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
-H "content-type: application/json" \
-d '{"name":"Contract.pdf", "parent":{"id":"11446498"}}'
String fileName = "My Doc.pdf";
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
try {
folder.canUpload(fileName, 98734576);
// If the file upload would not have succeeded, it will not be attempted
folder.uploadFile(fileContents, fileName);
} catch (BoxAPIException ex) (
)
// Verify that uploading a 200MB file named "Preso.ppt" to folder 12345 would succeed
client.files.preflightUploadFile(
'12345',
{
name: 'Preso.ppt',
size: 200000000
},
null,
callback
);
{
"upload_token": "Pc3FIOG9vSGV4VHo4QzAyg5T1JvNnJoZ3ExaVNyQWw6WjRsanRKZG5lQk9qUE1BVQP",
"upload_url": "https://upload-las.app.box.com/api/2.0/files/content?upload_session_id=1234"
}