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.

Here is the latest list available (May 2021):

  1. global Boolean renameAlbum(String oldAlbumId, String newAlbumId) {
    • Renames an album.
  2. 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.
  3. global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId) {
    • Copies all images form a source album to a destination album.
  4.  global String duplicateAlbum(String sourceAlbumId, String destinationAlbumId, Boolean includeTags) {
    • Copies all images form a source album to a destination album. This method also allows the duplication of tags along with the images.
  5. global List<Object> getAlbumImages(String albumId) {
    • Gets all images from an album.
  6. global Map<String, Object> getImageDetails(String imageId) {
    • Gets image details.
  7.  global static string duplicateImage(string imageId, string albumId, map<string, object> options) {
    • Duplicates an image to a specified album. The options parameter can be used to enable tag and image sync while duplicating the image. An example on how to call this method has been given at the end of this article.
  8. global List<Object> duplicateImages(List<String> imageIds, String destinationAlbumId) {
    • Duplicates one or more images to another album.
  9. global String getImageUrl(String imageId, Map<String, Object> sharinpix, List<Object> transformations) {
    • Gets the URL of a transformed image.
  10. global String croppedImageUrl(String imageId, String cropStyle, Integer width, Integer height) {
    • Crops or resizes images.
  11. global Map<String, Object> getImageExternalUrl(Map<String, Object> imageTransformation) {
    • Applies transformations on an image and get an external URL.
  12. global List<Object> getImageExternalUrls(List<Map<String, Object>> imageTransformations) {
    • Applies transformations on images and get external images URLs.
  13. global List<Object> getOrgTags() {
    • Retrieves all tags present in your Organization.
  14. global List<Object> getAlbumTagImages(String albumId) {
    • Retrieves the list of images having tags from an album.
  15. global List<Object> getAlbumTagImages(String albumId, String tagName) {
    • Retrieves all tagged images having a specific tag name from an album.
  16. global List<Object> getTagsOnImage(String imageId) {
    • Retrieves all tags applied to an image.
  17. global List<String> getTagNamesOnImage(String imageId) {
    • Retrieves all tag names available on an image.
  18. global Object addTag(String imageId, String tagName) {
    • Adds a tag on an image.
  19. global Boolean removeTags(String imageId, String[] tags) {
    • Removes tags from a tagged image.
  20. global Boolean clearTags(String imageId) {
    • Clears all tags applied to an image.
  21. global Object uploadAttachment(Id attachmentId, String albumId) {
    • Uploads Salesforce attachments to SharinPix albums.
  22. global Object uploadAttachment(Id attachmentId, String albumId, Map<String, Object> userMetadatas) {
    • Uploads Salesforce attachments to SharinPix albums.
  23. global Object uploadContentDocument(Id contentDocumentId, String albumId) {
    • Uploads Salesforce ContentDocuments to SharinPix albums.
  24. global Object uploadContentDocument(Id contentDocumentId, String albumId, Map<String, Object> userMetadatas) {
    • Uploads Salesforce ContentDocuments to SharinPix albums.
  25. 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 list of tags to be applied on every image.
  26. global Object uploadFromUrl(String imageUrl, String albumId, String filename){
    • Uploads an image to SharinPix using an URL.
  27. global Object uploadFromUrl(String imageUrl, String albumId, String filename, map<string, object> metadatas){
    • Uploads an image to SharinPix using an URL.
  28.  global Object uploadWebshot(String url, String albumId) {
    • Captures screenshot from website URL and uploads to SharinPix.
  29. 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'}});
  30. global String generateMobileAppUrl(String albumId, Map<String, Object> options) {
    • Generates the SharinPix URL used to launch the mobile application.
  31. global String generateMobileAppUrl(String albumId, String name, Map<String, Object> options, Integer linkExpiration) {
    • Generates the SharinPix URL used to launch the mobile application.
  32. global static List<String> splitToken(String token, Integer sizeLimit) {
    • Method used to split a token.
  33. global List<String> getAlbumImageIds(Id albumId){
    • Retrieves all image IDs found in an album.
  34.  global List<String> deleteImage(String imageId) {
    • Deletes image corresponding to the given ID
  35. 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});
  36. global List<String> deleteImages(List<String> imageIds) {
    • Deletes images corresponding to the given IDs
  37. 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.

Example

The following example demonstrates how to call the duplicateImage method.

The duplicateImage method is used to duplicate an image to another album and has options to enable tag and image sync while performing the duplication.

global static string duplicateImage(string imageId, string albumId, map<string, object> options) 

The method parameters are:

  • imageIdThe image public ID.
  • albumIdThe ID of the target album, that is, the album on which the duplicated image will be uploaded. Note: 18 Chars ID is required for Salesforce ID.
  • options: A map accepting keys tags and sync. The keys tags and sync should be set to true for the method to perform tag duplication and image sync.

The method returns a String containing the duplicated image ID.

sharinpix.Utils.duplicateImage('a95f9022-3d4a-456c-aadc-9e25d350b70b', '00324000004GUxhAAG', new map<string, object>{ 'tags' => true, 'sync' => true});

Tip:

The SharinPix package also include the Image class which includes useful methods for image management such as a method to move images. For more information about the Image class, please refer to the article below:

Image methods

2 Comments

Dobias van Buuren

I have a question about the various uploadContentDocument methods in the API. What is the behavior when dealing with multiple ContentVersions? Is only the latest version uploaded to SharinPix? Or do I end up with multiple images? And what if the provided ContentDocumentId refers to some unsupported file format?

Azhar Beebeejaun

Hi Dobias,

When there are multiple content versions available for a document, the latest content version only will be uploaded to SharinPix. This will be identified by searching for the ContentVersion where IsLatest is true.

If the ContentDocument is not an image or of an unsupported file format, it will still be uploaded to SharinPix but no preview will be available for it.

Hope that answers your questions.

Regards
Azhar

Add your comment

E-Mail me when someone replies to this comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.