0
votes

I am using the Box Java SDK to upload a file to a folder and create a shared link and send the download URL via email to a customer who has no Box account. I need to ensure that the access to the file is password protected.

Here is my code:

...             
BoxFileUploadRequestObject requestObj = BoxFileUploadRequestObject.uploadFileRequestObject(folderEntry.getId(), fileList[j], file, JSON_PARSER);
BoxFile bFile = boxClient.getFilesManager().uploadFile(requestObj);

// create a link to this file                       
BoxSharedLinkPermissions permissions = new BoxSharedLinkPermissions(true);                  
BoxSharedLinkRequestObject slo = BoxSharedLinkRequestObject.createSharedLinkRequestObject(BoxSharedLinkAccess.OPEN).setPermissions(permissions);
BoxFileRequestObject bfro = BoxFileRequestObject.createSharedLinkRequestObject(slo);                    
BoxFile newFile = boxClient.getFilesManager().createSharedLink(bFile.getId(), bfro);
BoxSharedLink link = newFile.getSharedLink();

// get the download URL
String downloadUrl = link.getDownloadUrl();
logger.debug("== BOX_DEBUG_MESSAGE: DownloadUrl = " + downloadUrl);

This all works well but how can I ensure that the link is password protected?

1

1 Answers

1
votes

Editing of passwords via the API is not currently supported.

http://developers.box.com/docs/#files-create-a-shared-link-for-a-file

The API response includes whether a password on the link exists or does not (is_password_enabled:true/false), but it does not allow you to set or edit it via the API. Setting shared link passwords can only be done via the web app, not within the admin console. When creating or viewing a link in the web app, you can select to set a password on either a folder or a file.