Skip to content

Latest commit

 

History

History
115 lines (83 loc) · 3.84 KB

weblinks.md

File metadata and controls

115 lines (83 loc) · 3.84 KB

Web Links

Web links are objects that point to URLs. These objects are also known as bookmarks within the Box web application. Web link objects are treated similarly to file objects.

Create Web Link

Calling BoxFolder.createWebLink(String name, URL url, String description) will let you create a new web link with a specified name and description.

BoxFolder folder = new BoxFolder(api, id);
URL url = new URL("https://www.example.com");
folder.createWebLink("Link to Example", url, "This goes to an example page");

Name and description params are optional, so it is possible to create web link with only one of them or with URL only: BoxFolder.createWebLink(URL url)

BoxFolder folder = new BoxFolder(api, id);
URL url = new URL("https://www.example.com");
BoxWebLink.Info webLinkInfo = folder.createWebLink(url);

Get Web Link

A web link info can be retrieved by calling the getInfo(String... fields) method. Optional parameters can be used to retrieve specific fields of the Device Pin object.

BoxWebLink webLink = new BoxWebLink(api, id);
BoxWebLink.Info webLinkInfo = webLink.getInfo();

Update Web Link

A web link can be updated by calling the updateInfo(BoxWebLink.Info fieldsToUpdate) method.

BoxWebLink webLink = new BoxWebLink(api, id);
BoxWebLink.Info webLinkInfo = webLink.new Info();
webLinkInfo.addPendingChange("name", "new name for weblink");
webLink.updateInfo(webLinkInfo);

Create a Shared Link

You can create a shared link for a web link by calling the createSharedLink(BoxSharedLink.Access accessLevel, Date expirationDate, BoxSharedLink.Permissions permissions) method.

BoxWebLink webLink = new BoxWebLink(api, "id");
SharedLink link = webLink.createSharedLink(BoxSharedLink.Access.OPEN, null,
    permissions);

Remove a Shared Link

You can remove a shared link for a web link by calling the removeSharedLink method.

BoxWebLink webLink = new BoxWebLink(api, "12345");
BoxWebLink.Info webLinkInfo = webLink.getInfo();
info.removeSharedLink()
webLink.updateInfo(info)

Delete Web Link

A web link can be deleted by calling the delete() method.

BoxWebLink webLink = new BoxWebLink(api, id);
webLink.delete();