Download Zip - Using Customized Download Filenames to Build a Folder Structure
This article demonstrates how to build a folder structure when downloading a SharinPix zip file using a customized filename by means of:
Example: Building a Folder Structure Using Customized Filename Inside a Zip File
Let's suppose we have a list of grocery store branches registered as Account records. Each grocery store has multiple store locations registered as Location records.
Using a SharinPix Search component, we are retrieving all images from all stores irrespective of the branch and location and identifying each image using a SharinPix custom label displaying the branch name and the location as follows: branchName/storeLocation
Information:
The above SharinPix custom label has been configured using the following Formula field of type text on the SharinPix Image object: IF( ISNULL(Store__c), 'N/A', Store__r.Account__r.Name &'/'& Store__r.Name)
For more information on how to configure SharinPix custom labels, refer to this article: Thumbnail View - Display Infos
By using the same custom label as the download filenames in the downloaded zip, we achieve the following folder structure:
The following sections demonstrate how to customize the filename to achieve the above folder structure when downloading the zip.
Using Customized Filename in SharinPix Permission Record to Build a Folder Structure When Downloading a SharinPix Zip
To build a folder structure using a SharinPix Permission record, proceed as follows:
- Create a text field on the SharinPix Image object that will store the path, delimiting each folder and file by slash (/). For example: ObjectA/ObjectB/ImageFilename. Tip: Formula fields of type text can be used for this purpose.
- Copy the field API name of the field storing the path.
- Create/Edit the SharinPix Permission and paste the field API name in the Salesforce field on sObject SharinPixImage__c with custom image filename for zip download parameter as demonstrated below.
4. Ensure that the other zip abilities (Download Zip and Zip file name, for instance) are properly configured. For more information on the zip abilities, refer to this article: Multiple Images download (ZIP) - Out of the box
5. Configure the other SharinPix Permission abilities as desired and click on Save when done.
6. Assign the SharinPix Permission to the desired SharinPix component.
Tip:
For more information on how to create, edit, and assign a SharinPix Permission, refer to this article: SharinPix Permission object - How to create and assign custom permission?
7. Go to the SharinPix component and download the zip file. The defined path will be applied to the unzipped folder.
Using Customized Filename in an Apex Class to Build a Folder Structure When Downloading a SharinPix Zip
To build a folder structure in an Apex method, proceed as follows:
- Create a text field on the SharinPix Image object that will store the path delimiting each folder and file by slash (/). For example: ObjectA/ObjectB/ImageFilename. Tip: Formula fields of type text can be used for this purpose.
- Copy the field API name of the field storing the path.
- In your Apex method, use the field API name as the value for the download_custom_filename parameter. Tip: Do not forget to configure the zip filename using the download_filename parameter.
The two examples below demonstrate how the download_filename and download_custom_filename are configured in a custom Search and album component.
Code Snippet for Search Component
params = new Map<String, Object> {
'path' => '/search?search_bar=false&q=' + clientInstance.token(query),
'download' => true,
'download_filename' => 'Store Search',
'download_custom_filename' => 'CustomFilename__c'
};
Code Snippet for Album Component
Map<String, Object> params = new Map<String, Object> {
'download' => true,
'download_filename' => 'Store Search',
'download_custom_filename' => 'Store_Path__c'
'abilities' => new Map<String, Object> {
'download' => true,
albumId => new Map<String, Object> {
'Access' => new Map<String, Object> {
'see' => true,
'image_download' => true,
'image_list' => true,
'image_upload' => true,
}
}
},
'Id' => albumId
};
Tip:
For more information on how to customize download filenames, refer to this article:
Multiple Image download (ZIP) - How to personalize the download filenames
0 Comments
Add your comment