Skip to main content

Working With Public Albums

The CloudikePhotos SDK provides functions for working with public albums.

import CLPhotos from 'web_photos';
let photosApp;
const options = {    logLevel: 'error' // 'trace' | 'debug' | 'info' | 'warn' | 'error'};
const config = {    authToken: '', // user auth token     baseUrl: '', // api base url required    userAgent: '' // user agent name required}
try {    photosApp = CLPhotos.init(options, config);} catch (e) {    // catch photo sdk InternalError}

Get information about a Share2 of an Album1#

The following code example demonstrates how to get information about a Share2 by the Album's1 id.

const albumId = 'id';photosApp.publicLink.getAlbumShare(albumId)    .then(({data}) => {        const shareData = data; // IMyShareSchema    })

The following code example demonstrates how to get information about a Share2 by the Album's1 'sharing link'.

const shareLink = 'shareLink';photosApp.publicLink.getAlbumShareByLink(shareLink)    .then(({data}) => {        const shareData = data; // IMyShareSchema    })

Create Share for the Album#

The following code example demonstrates how to create a Share2 for an Album1 by its id.

const albumId = 'id';const shareSettings = {}; // IShareSettingsSchemaphotosApp.publicLink.createAlbumShare(albumId, shareSettings)    .then(({data}) => {        const shareData = data; // IMyShareSchema    })

The following code example demonstrates how to create a Share2 for an Album1 by its 'sharing link'.

const shareLink = 'shareLink';const shareSettings = {}; // IShareSettingsSchemaphotosApp.publicLink.createAlbumShareByLink(shareLink, shareSettings)    .then(({data}) => {        const shareData = data; // IMyShareSchema    })

Update Share2 for the Album1#

The following code example demonstrates how to update a Share2 for an Album1 by its id.

const albumId = 'id';const shareSettings = {    permission: 'write'}; // IShareSettingsSchemaphotosApp.publicLink.updateAlbumShare(albumId, shareSettings)    .then(({data}) => {        const shareData = data; // IMyShareSchema    })

The following code example demonstrates how to update a Share2 for an Album1 by its 'sharing link'.

const shareLink = 'shareLink';const shareSettings = {    permission: 'write'}; //IShareSettingsSchemaphotosApp.publicLink.updateAlbumShareByLink(shareLink, shareSettings)    .then(({data}) => {        const shareData = data; // IMyShareSchema    })

Delete Share for the resource#

The following code example demonstrates how to delete a Share2 for an Album1 by its id.

const albumId = 'id';photosApp.publicLink.deleteAlbumShare(albumId)    .then(() => {        // share is deleted    })

The following code example demonstrates how to delete a Share2 for an Album1 by its 'sharing link'.

const shareLink = 'shareLink';photosApp.publicLink.deleteAlbumShareByLink(shareLink)    .then(() => {        // share is deleted    })

Get collaborators#

The following code example demonstrates how to get a list of collaborators4 of User's3 Album1.

const albumId = 'id';const params = {}; // IGetEmbeddedSchemaphotosApp.publicLink.getCollaboratorsForOwnerAlbum(albumId, params)    .then(({data}) => {        const {_embedded: {collaborators}} = data;    })

The following code example demonstrates how to get a list of collaborators4 of any Album1 by the User's3 id and the Album's id.

const userId = 'id';const albumId = 'id';const params = {}; // IGetEmbeddedSchemaphotosApp.publicLink.getCollaboratorsForAlbum(userId, albumId, params)    .then(({data}) => {        const {_embedded: {collaborators}} = data;    })

Add collaborator to the shared Album1#

The following code example demonstrates how to add Collaborator4 for any Album1 by the User's3 id and the Album's id.

const description = 'new Album';const newAlbum = {    type: 'simple',    description};photosApp.albums.createAlbum(newAlbum)    .then(({data}) => {        const {_links: {set_share: {href}}} = data;        const shareSettings = {access_type: 'collaborators', permission: 'read'};        return photosApp.publicLink.createAlbumShareByLink(href, shareSettings);    })    .then(({data}) => {        const {_links: {collaborators: {href: collaboratorsLink}}} = data;        const newCollaborator = {phone_or_email: 'test@test.com', permission: 'read'}; // ICreateCollaboratorSchema        return photosApp.publicLink.addCollaboratorsForAlbum(collaboratorsLink, newCollaborator);    });

Get the collaborator's information of the shared Album1#

The following code example demonstrates getting data on a Collaborator4 of an Album1 by the Collaborator's id and Album's id.

const collaboratorId = 'id';const albumId = 'id';photosApp.publicLink.getCollaboratorForAlbum(collaboratorId, albumId)    .then(({data}) => {        const collaborator = data; // ICollaboratorSchema    })

Delete the Collaborator4 for the shared Album1#

The following code example demonstrates removing a Collaborator4 FROM an Album1 by the Collaborator's id and Album's id.

const collaboratorId = 'id';const albumId = 'id';photosApp.publicLink.deleteCollaboratorForAlbum(collaboratorId, albumId)    .then(() => {        // collaborator is deleted    })

Update the Collaborator's4 settings#

The following code example demonstrates updating the Collaborator's4 settings of an Album1 by the Collaborator's id and the Album's id.

const collaboratorId = 'id';const albumId = 'id';const collaboratorSettings = {    permission: 'read'}; // IPatchCollaboratorSchemaphotosApp.publicLink.updateCollaboratorForAlbum(collaboratorId, albumId, collaboratorSettings)    .then(() => {        // collaborator is deleted    })

Get shared with user list of albums#

The following code example demonstrates getting a list of albums1 which are shared with an User3.

const params = {}; // IGetSharedWithMeAlbumsSchemaphotosApp.publicLink.getSharedWithMeAlbums(params)    .then(({data}) => {        const {_embedded: {albums}} = data; // IAlbumsSchema    })

The following code example demonstrates getting a list of shared albums of a User3.

const shareId = 'id';photosApp.publicLink.getPublicShare(shareId)    .then(({data}) => {        const {_links: {not_my_resource: {href: sharedWithMeUrl}}} = data;        const accessToken = null; // 'null' only for none protected by password albums        return photosApp.publicLink.getSharedWithMeAlbumByLink(sharedWithMeUrl, accessToken);    })    .then(({data}) => {        const album = data; // IAlbumSchema    });

Get not owner's shared albums#

The following code example demonstrates getting data of not owner's but shared with owner Album1 by Share's3 id.

const shareId = 'id';photosApp.publicLink.getNotMyAlbumShare(shareId)    .then(({data}) => {        const notMyShare = data; // INotMyAlbumSchema    });

The following code example demonstrates getting data of not owner's but shared with owner Album1 by Share's3 link.

const shareLink = 'shareLink';photosApp.publicLink.getNotMyAlbumShareByLink(shareLink)    .then(({data}) => {        const notMyShare = data; // INotMyAlbumSchema    });

Update not owner's shared Album1#

The following code example demonstrates updating data of not owner's but shared with owner Album1 by Share's3 id.

const shareId = 'id';const options = {    description: "new album name"}photosApp.publicLink.updateNotMyAlbumShare(shareId, options)    .then(({data}) => {        const notMyShare = data; // INotMyAlbumSchema    });

The following code example demonstrates updating data of not owner's but shared with the owner’s Album1 by Share's3 link.

const shareLink = 'shareLink';const options = {    description: "new album name"}photosApp.publicLink.updateNotMyAlbumShareByLink(shareLink, options)    .then(({data}) => {        const notMyShare = data; // INotMyAlbumSchema    });

Delete not owner's shared Album1#

The following code example demonstrates deleting data of not owner's but shared with owner Album1 by Share's3 id.

const shareId = 'id';photosApp.publicLink.deleteNotMyAlbumShare(shareId)    .then(() => {        // album is deleted    });

The following code example demonstrates deleting data of not owner's but shared with owner Album1 by Share's3 id.

const shareLink = 'shareLink';photosApp.publicLink.deleteNotMyAlbumShareByLink(shareLink)    .then(() => {        // album is deleted    });

Get owner's Share2#

The following code example demonstrates getting data of owner's Share2 by Share's id.

const shareId = 'id';photosApp.publicLink.getOwnPublicShare(shareId)    .then(({data}) => {        const share = data; // IPublicShareSchema    });

The following code example demonstrates getting data of a Share2 by share's id.

const shareId = 'id';const accessToken = 'token'; // if share is protected with password it is needed to create access token by 'creatShareAccessToken' methodphotosApp.publicLink.getAnonymousPublicShare(shareId, accessToken)    .then(({data}) => {        const share = data; // IPublicShareSchema    });

The following code example demonstrates getting data of a Share2 by share's id and User's3 id.

const shareId = 'id';const userId = 'id';photosApp.publicLink.getPublicShare(shareId, userId)    .then(({data}) => {        const share = data; // IPublicShareSchema    });

Create access token for getting protected shared Album1#

The following code example demonstrates how to create access token to get data of Share2 by the share’s ID and a password.

const sharedId = 'id';const password = '123456';photosApp.publicLink.creatShareAccessToken(sharedId, password)    .then(({data}) => {        const {token: accessToken} = data;    });

The following code example demonstrates how to create an access token to get data of a Share2 by the token’s link and a password.

const tokenLink = 'tokenLink';const password = '123456';photosApp.publicLink.creatShareAccessTokenByLink(tokenLink, password)    .then(({data}) => {        const {token: accessToken} = data;    });

Get protected by password shared Album1#

The following code example demonstrates getting Share2 data protected by a password by Share's id and an access token for anonymous users.

const shareId = '';const accessToken = 'token'; // if share is protected with password it is needed to create access token by 'creatShareAccessToken' methodphotosApp.publicLink.getPasswordProtectedAnonymousPublicShare(shareId, accessToken)    .then(({data}) => {        const share = data; // IPublicShareSchema    });

The following code example demonstrates getting Share2 data protected by Share's id and an access token for known/or existing users.

const shareId = 'id';const accessToken = 'token'; // if Share is protected with a password it is needed to create an access token by the 'creatShareAccessToken'methodphotosApp.publicLink.getPasswordProtectedOwnPublicShare(shareId, accessToken)    .then(({data}) => {        const share = data; // IPublicShareSchema    });

Get not owner's shares#

The following code example demonstrates getting data of not owner's Share2 by Share's2 id.

const shareId = 'id';photosApp.publicLink.getNotMyShare(shareId)then(({data}) => {    const share = data; // INotMyShareSchema})

  1. Share - the piece of information of sharing of the Album.↩
  2. Album - the list of photos or videos files↩
  3. Collaborator - user which has access to shared album↩
  4. User - the owner of the cloud↩