Update Shared Link

Update Shared Link

A shared link may be updated from a resource by calling the update file or update folder endpoint, specifying the ID of the resource to update with the new shared link values. See the create shared link guide for all available parameters.

If you update the shared link settings, the new settings will apply to any users who already have the URL.

To update a shared link on a file, specify the ID of the file with any optional shared link parameters.

.NET
string fileId = "11111";
var sharedLinkParams = new BoxSharedLinkRequest()
{
    Access = BoxSharedLinkAccessType.open
};
BoxFile file = client.FilesManager.CreateSharedLinkAsync(fileId, sharedLinkParams);
string sharedLinkUrl = file.SharedLink.Url;
Java
BoxFile file = new BoxFile(api, "id");
BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
Date unshareDate = new Date();
BoxSharedLink sharedLink = file.createSharedLink(BoxSharedLink.Access.OPEN, null, permissions);
Python
file_id = '11111'

url = client.file(file_id).get_shared_link()
print('The file shared link URL is: {0}'.format(url))
Node
client.files.update('93745', {shared_link: client.accessLevels.DEFAULT})
	.then(file => {
		var sharedLinkURL = file.shared_link.url;
		// ...
	});

To update a shared link on a folder, specify the ID of the folder with any optional shared link parameters.

.NET
var sharedLinkParams = new BoxSharedLinkRequest()
{
    Access = BoxSharedLinkAccessType.open
};
BoxFolder folder = await client.FoldersManager.CreateSharedLinkAsync("11111", sharedLinkParams);
string sharedLinkUrl = folder.SharedLink.Url;
Java
BoxFolder folder = new BoxFolder(api, "id");
SharedLink link = folder.createSharedLink(BoxSharedLink.Access.OPEN, null,
    permissions);
Python
url = client.folder(folder_id='22222').get_shared_link()
print('The folder shared link URL is: {0}'.format(url))
Node
client.folders.update('12345', {shared_link: client.accessLevels.OPEN})
    .then(folder => {
        /* folder -> {
            type: 'folder',
            id: '11111',
            sequence_id: '1',
            etag: '1',
            name: 'Pictures from 2017',
            created_at: '2012-12-12T10:53:43-08:00',
            modified_at: '2012-12-12T11:15:04-08:00',
            description: 'Some pictures I took',
            size: 629644,
            path_collection: 
            { total_count: 1,
                entries: 
                [ { type: 'folder',
                    id: '0',
                    sequence_id: null,
                    etag: null,
                    name: 'All Files' },
                  { type: 'folder',
                    id: '22222',
                    sequence_id: '3',
                    etag: '3',
                    name: 'Archives' } ] },
            created_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User'
                login: 'user@example.com' },
            modified_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User',
                login: 'user@example.com' },
            owned_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User',
                login: 'user@example.com' },
            shared_link: {
                url: 'https://app.box.com/s/31uw1b0dxr2swzbv1qu8d4ixz1v727dl',
                download_url: null,
                vanity_url: null,
                effective_access: 'open',
                is_password_enabled: false,
                unshared_at: null,
                download_count: 0,
                preview_count: 0,
                access: 'open',
                permissions: {
                    can_download: true,
                    can_preview: true
                },
            parent: 
            { type: 'folder',
                id: '22222',
                sequence_id: '3',
                etag: '3',
                name: 'Archives' },
            item_status: 'active',
            item_collection: 
            { total_count: 1,
                entries: 
                [ { type: 'file',
                    id: '33333',
                    sequence_id: '3',
                    etag: '3',
                    sha1: '134b65991ed521fcfe4724b7d814ab8ded5185dc',
                    name: 'tigers.jpeg' } ],
                offset: 0,
                limit: 100 } }
        */
    });