Utils methods
Utils methods
Utils are available for you to avoid direct access to our rest API and an integrated usage directly from the SharinPix package in Apex from Salesforce.
Methods
Utils Method Example
renameAlbum
global Boolean renameAlbum(String oldAlbumId, String newAlbumId)
Renames an album.
renameAlbum
global Boolean renameAlbum(String oldAlbumId, String newAlbumId, Boolean mergeAlbum)
Renames an album. The mergeAlbum parameter is used to specify whether to merge the old and new albums or not.
Image below shows the albums before using the renameAlbum method.

After using the method renameAlbum with mergeAlbum parameter 'true', all the images from the old Album have been merged in the new Album as shown below.

duplicateAlbum
duplicateAlbum without existing tags on images
global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId)
Copies all images from a source album to a destination album.
The code below shows the code without tags.
Image below shows the source record where the album an image with the tag "object".

The image below shows the destination record where the image from the source record has been populated without the tags because in the code snippet we have not mentioned if "Tags" is true or false.

duplicateAlbum with existing tags on images
global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId, Boolean includeTags)
Copies all images from a source album to a destination album. This method also allows the duplication of tags along with the images.
The image below shows the code where tags is true.
Image below shows the source record where the album an image with the tag "object".

The image below shows the destination record where the image from the source record has been populated and has been assign the tag "object" when the code snippet was executed.

duplicateAlbum with additional tags
global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId, Map<String, Object> params)
Copies all images from a source album to a destination album. Use
new_tagsto add tags to every duplicated image.
The new_tags parameter accepts up to five tags. If more than five tags are provided, only the first five are applied.
duplicateAlbum with Einstein Boxes (DEPRECATED)
global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId, Map<String,Object> params)
Copies all images from a source album to a destination album if einstein_boxes equals to true. This method also allows the duplication of labels along with the images.
getAlbumImages
global List<Object> getAlbumImages(String albumId)
Gets all images from an album.
Below code shows how to get the details from an image (e.g: brightness, color, contrast, created_at,...)
getImageDetails
global Map<String, Object> getImageDetails(String imageId)
Gets image details.
duplicateImageToAlbum
global string duplicateImageToAlbum(string imageId, string albumId, map<string, object> options)
Duplicates an image to a specified album. The options parameter can enable tag and image sync. Use
new_tagsto add up to five tags to the duplicated image.
See duplicateAlbum with additional tags for the new_tags option format.
duplicateImages
duplicateImages while excluding existing tags
global List<Object> duplicateImages(List<String> imageIds, String destinationAlbumId)
Duplicates one or more images to another album.
duplicateImages including existing tags or applying new tags
global List<Object> duplicateImages(List<String> imageIds, String destinationAlbumId, Map<String, Object> options)
Duplicates one or more images to another album. This method also allows the duplication of tags along with the images. Use
new_tagsto add up to five tags to every duplicated image.
See duplicateAlbum with additional tags for the new_tags option format.
getImageUrl
global String getImageUrl(String imageId, Map<String, Object> sharinpix, List<Object> transformations)
Gets the URL of a transformed image.
Get the original url of an image (This url is a direct expiring url to the storage)
getImageEndpoint
global String getImageEndpoint (String imageId, Map<String, Object> sharinpix, List<Object> transformations)
Get endpoint of transformed image
croppedImageUrl
global String croppedImageUrl(String imageId, String cropStyle, Integer width, Integer height)
Crops or resizes images.
getImageExternalUrl
global Map<String, Object> getImageExternalUrl(Map<String, Object> imageTransformation)
Applies transformations on an image and get an external URL.
getImageExternalUrls
global List<Object> getImageExternalUrls(List<Map<String, Object>> imageTransformations)
Applies transformations on images and get external images URLs.
getOrgTags
global List<Object> getOrgTags()
Retrieves all tags present in your Organization.
getAlbumTagImages
global List<Object> getAlbumTagImages(String albumId)
Retrieves the list of images having tags from an album.
getAlbumTagImages
global List<Object> getAlbumTagImages(String albumId, String tagName)
Retrieves all tagged images having a specific tag name from an album.
getTagsOnImage
global List<Object> getTagsOnImage(String imageId)
Retrieves all tags applied to an image.
getTagNamesOnImage
global List<String> getTagNamesOnImage(String imageId)
Retrieves all tag names available on an image.
addTag
global Object addTag(String imageId, String tagName)
Adds a tag on an image.
removeTags
global Boolean (String imageId, String[] tags)
Removes tags from a tagged image.
clearTags
global Boolean clearTags(String imageId)
Clears all tags applied to an image.
uploadAttachment
global Object uploadAttachment(Id attachmentId, String albumId)
Uploads Salesforce attachments to SharinPix albums.
uploadAttachment
global Object uploadAttachment(Id attachmentId, String albumId, Map<String, Object> userMetadatas)
Uploads Salesforce attachments to SharinPix albums.
uploadAttachment
global Object uploadAttachment(Id attachmentId, String albumId, Map<String, Object> userMetadatas, List<String> tags)
Uploads Attachments to SharinPix albums with tags. Using this method, you can also provide a list of tags to be applied to every image.
uploadContentDocument
global Object uploadContentDocument(Id contentDocumentId, String albumId)
Uploads Salesforce ContentDocuments to SharinPix albums.
uploadContentDocument
global Object uploadContentDocument(Id contentDocumentId, String albumId, Map<String, Object> userMetadatas)
Uploads Salesforce ContentDocuments to SharinPix albums.
uploadContentDocument
global Object uploadContentDocument(Id contentDocumentId, String albumId, Map<String, Object> userMetadatas, List<String> tags)
Uploads Salesforce ContentDocuments to SharinPix albums. Using this method, you can also provide a title and description within the userMetadatas parameter and a list of tags within the tags parameter to be applied to every image.
uploadFromUrl
global Object uploadFromUrl(String imageUrl, String albumId, String filename)
Uploads an image to SharinPix using an URL.
uploadFromUrl
global Object uploadFromUrl(String imageUrl, String albumId, String filename, map<string, object> metadatas)
Uploads an image to SharinPix using a URL. Use the metadatas parameter to provide image metadata such as title, description, and contentDocumentId. To apply tags during import, use the five-argument overload.
uploadFromUrl with tags
global Object uploadFromUrl(String imageUrl, String albumId, String filename, Map<String, Object> metadatas, Map<String, Object> options)
Uploads an image from a URL to a SharinPix album and applies the tags supplied in options. This overload handles the import and tagging in the same method call, without creating a Media Import record or making a separate addTag call.
imageUrl
String
URL of the image to import, for example an image hosted on Amazon S3.
albumId
String
Destination SharinPix album ID. For an album associated with a Salesforce record, use that record's ID.
filename
String
Filename for the imported image, including its extension.
metadatas
Map<String, Object>
Image metadata. Pass an empty map when no additional metadata is needed.
options
Map<String, Object>
Import options. Set tags to a List<String> containing the tags to apply to this image.
Example: import an image with tags
Replace the sample URL and album ID with your image URL and destination record ID.
The tags belong in the fifth argument, options. The fourth argument, metadatas, remains dedicated to metadata. Passing a tags entry in the metadata map of the four-argument overload does not apply tags to the image.
For an existing integration with a List<String> photoTags, pass it as new Map<String, Object>{ 'tags' => photoTags } in the fifth argument. When processing multiple files, call the method for each file with that file's URL, filename, and tag list.
Use uploadFromUrl to import an image file from its URL. Use uploadWebshot to capture a screenshot of a web page, or uploadContentDocument with tags when the source is a Salesforce File.
uploadWebshot
global Object uploadWebshot(String url, String albumId)
Captures screenshot from website URL and uploads to SharinPix.
uploadWebshot
global Object uploadWebshot(String url, String albumId, Map<string, object> options)
Captures screenshot from website URL and uploads to SharinPix. Using this method you can also provide a list of tags to be applied on every image. For e.g : sharinpix.Utils.uploadWebshot('https:/test/maps/test', '00324000004GUxhAAG', new Map<string, object>{ 'tags' => new List<string> {'mapTag'}});
generateMobileAppUrl
global String generateMobileAppUrl(String albumId, Map<String, Object> options)
Generates the SharinPix URL used to launch the mobile application.
generateMobileAppUrl
global String generateMobileAppUrl(String albumId, String name, Map<String, Object> options, Integer linkExpiration)
Generates the SharinPix URL used to launch the mobile application.
splitToken
global static List<String> splitToken(String token, Integer sizeLimit)
Method used to split a token.
getAlbumImageIds
global List<String> getAlbumImageIds(Id albumId)
Retrieves all image IDs found in an album.
deleteImage
global List<String> deleteImage(String imageId)
Deletes image corresponding to the given ID
deleteImage
global List<String> deleteImage(String imageId, map<string, object> payload)
Deletes image corresponding to the given ID taking into consideration parameters passed in payload. Available options:
purge
Set to true to completely delete image from SharinPix. This action cannot be undone and image cannot be restored. Example usage: (new sharinpix.Utils()).deleteImage('imageIdHere', new map<string,object>{'purge' => true});
deleteImages
global List<String> deleteImages(List<String> imageIds)
Deletes images corresponding to the given IDs
deleteImages
global List<String> deleteImages(List<String> imageIds, map<string, object> payload)
Deletes images corresponding to the given IDs taking into consideration parameters passed in payload. Available options:
purge
Set to true to completely delete images from SharinPix. This action cannot be undone and images cannot be restored.
updateSessionIdValidity
global Object updateSessionIdValidity(String id, Boolean valid)
Validates or invalidates a session (corresponding to the given session Id in the parameters)
Updates valid to true to validate a session or false to invalidate a session.
createContentDocumentFromUrl
You can utilize this method to transform a public URL into a content document. It's applicable for converting SharinPix Images into content documents using SharinPix public image URLs.
createContentDocumentFromUrl without the option to add custom filename
global static Id createContentDocumentFromUrl(String url)
Download a file at a URL to Content Document
createContentDocumentFromUrl with option to add custom filename
global static Id createContentDocumentFromUrl(String url, Map<String, Object> options)
Download a file at a URL to Content Document with custom filename
Note: The custom filename should be added with its extension (e.g. jpg, png, jpeg, and so on) and the key should be 'filename' as shown in the example below.

