Import media files in bulk
On this page
When you have a batch of images or other media to bring into StoreConnect, you don’t have to add them one at a time in the store editor. This article covers two ways to import them in bulk.
Both routes end with your files served from StoreConnect’s Cloudinary CDN, but they produce different things — and that is the main thing to get right before you start:
- Prepare media in a Google Sheet imports media attached to products. It runs through the product importer, so each file is matched to a product as it comes in. Choose this when you are loading product images alongside the products they belong to.
- Import media using an AI agent creates standalone media records in your media library, not tied to any product. Choose this when you just need the files in StoreConnect — to reference in templates, or to attach to products later.
How bulk media import works
StoreConnect serves all storefront media from a single Cloudinary CDN, and templates reference media by URL — you cannot place a binary file directly into a template. Every file lives in the same store bucket; to keep your library organized, you can sort media into subfolders in the media manager (see Uploading media).
However your media is organized, every bulk import comes down to the same two steps:
- You create a media record for each file, giving StoreConnect an Import URL and a file type (image, video, document, or file). The Import URL is the file’s original source URL, and it must be publicly reachable — StoreConnect fetches the file over the internet with no login.
- StoreConnect ingests the file on a schedule: it fetches the file from the Import URL, pushes it to Cloudinary, and fills in the final CDN URL on the record. Because ingestion runs asynchronously, the CDN URL appears a short time after the record is created — seconds for a small image, longer for a large file — not the instant you save it.
:::note You only ever supply the Import URL. The CDN URL is populated by StoreConnect once it has ingested the file — never set or edit it yourself. :::
The two routes build those records in different ways:
| Route | Produces | Best when your files are… | How you work |
|---|---|---|---|
| Prepare media in a Google Sheet | Media attached to products | in Google Drive | In a spreadsheet, no code |
| Import media using an AI agent | Standalone media records | in a folder on your computer | With an AI assistant or the Salesforce CLI |
Both routes finish the same way — see Verify successful import of media.
Prepare media in a Google Sheet
Use this route when your media is in Google Drive and you want a no-code method. You build a spreadsheet of public Drive download URLs, then import it to create your media records.
This procedure assumes you keep your media files in Google Drive, and that you have authorization to share the file URLs as public links.
Build the spreadsheet of URLs
- Open a Google Sheet.
- Go to Extensions > App Scripts.
- Paste in the code below.
- Give the file a name, such as Get Folder Details.
- Then Save.
```javascript
function onOpen() { var ui = SpreadsheetApp.getUi(); ui.createMenu(‘Get Folder Details’) .addItem(‘Retrieve Files’, ‘retrieveFiles’) .addToUi(); }
function retrieveFiles() { var folderLink = SpreadsheetApp.getUi().prompt(‘Enter the folder link’).getResponseText(); var folder = DriveApp.getFolderById(getFolderIdFromLink(folderLink)); var files = folder.getFiles(); var data = [ [‘Name’, ‘Import Url’, ‘Type’, ‘ProductCode’] ];
while (files.hasNext()) { var file = files.next(); var fileUrl = ‘https://drive.google.com/uc?export=download&id=’ + file.getId(); var filename = file.getName(); var filenameWithoutExt = filename.slice(0,filename.lastIndexOf(‘.’)); data.push([filenameWithoutExt, fileUrl, ‘Image’, ‘’]); }
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); sheet.getDataRange().clearContent(); sheet.getRange(1, 1, data.length, data[0].length).setValues(data);
SpreadsheetApp.getUi().alert(‘Files retrieved successfully.’); }
function getFolderIdFromLink(link) { var regex = /\/folders\/([^/?]+)/; var match = link.match(regex);
if (match && match[1]) { return match[1]; }
return null; } ```
The new function is added as a menu in the spreadsheet.

Add media to the spreadsheet
- Select Get Folder Details > Retrieve Files.
- Follow the prompts to navigate to your media drive.
- Select the relevant folder and add files.
- This bulk adds media as URLs in the spreadsheet.
- Repeat for each folder of media you want to add.
Each row holds a media file’s public download link in the Import Url column, ready to import into StoreConnect as a media record.
Import the spreadsheet into StoreConnect
The spreadsheet doesn’t import itself — you bring it in through the product importer, which reads the Import Url column into each media record’s Import URL and links the media to a product using the ProductCode column.
- Save the sheet as a CSV.
- Import it through Product Setup > Import Products, mapping the columns as prompted. For the full walkthrough, see Upload and update multiple products via CSV.
StoreConnect then imports each file from its Import URL, as described above.
Import media using an AI agent
Use this route when your media files are on your computer and you want a technical, fully scriptable method for adding them to StoreConnect — for example, a large batch you’d rather not click through. You point an AI coding assistant (such as Claude Code, or any assistant that can run the Salesforce CLI) at the folder, and it creates the media records for you.
Before you start
You need:
- An AI coding assistant that can run shell commands and the Salesforce CLI (
sf). - The Salesforce CLI authenticated to the org that runs your store.
- A local folder containing the media files you want to import.
- Salesforce Files (content) space available in your org — this route uses it as staging. It is available in most orgs.
:::warning Run this against a test store or Salesforce sandbox first, and review what the agent does before you run it against your live org. :::
What the agent does for each file
Because your files are local rather than already on a public URL, the agent first stages each one in Salesforce Files to get a public link, then creates the media record:
- Upload to Salesforce Files — the local file is uploaded as a
ContentVersionrecord. - Create a public link — a
ContentDistributionrecord is created for that file, which returns a public, no-login download URL. - Create the media record — an
s_c__Media__crecord is created withs_c__Import_Url__cset to that public URL ands_c__File_Type__cset to the correct type.
From there, ingestion is the same shared pipeline described above: StoreConnect fetches the file and fills in the final CDN URL.
Give your agent the instruction
Give your agent access to the media folder and an instruction like the one below. It names the objects and fields the agent needs, so you don’t have to spell out each API call.
If your files are already referenced somewhere by an existing URL — for example, images pointing at an old host that you are moving onto the CDN — give the agent that old URL for each file as well, and have it return an old-to-new mapping. You then use that mapping to update the references in your templates and records.
```
Import every file in
- Create a ContentVersion (Title = the file name, VersionData = the file contents, PathOnClient = the file name).
- Create a ContentDistribution for that ContentVersion with public download enabled, and read back its public download URL.
- Create an s_c__Media__c record with:
- s_c__Import_Url__c = the public download URL from step 2
-
s_c__File_Type__c = image video document file (based on the file) - s_c__Identifier__c = the file name without its extension
- StoreConnect ingests media asynchronously. Poll each s_c__Media__c record until s_c__Url__c is populated (StoreConnect fills this in — do not set it yourself), then record the file’s final s_c__Url__c.
Process the files in batches and keep going until every file has a s_c__Url__c. At the end, give me a mapping table of old URL -> new CDN URL (s_c__Url__c), with the file name, so I can update every reference to the old URL. ```
Adjust the folder path, org alias, and file-type rules to suit your files.
Once s_c__Url__c is populated, Cloudinary is serving the file and you can delete the staging ContentDistribution record to close its public link.
Verify successful import of media
Whichever method you used, check the following after import.
- The new media appears in your media library in the store editor, ready to attach to products or reference in templates. You can move it into a subfolder from there — see Uploading media.
- Any CDN URL you were given should load the file from
res.cloudinary.comin a browser. When you reference media in a template, use the exact CDN URL StoreConnect returned — images, video, and other files sit under different Cloudinary paths, so don’t assemble the URL by hand. - If a file’s CDN URL never appears, its Import URL probably wasn’t reachable. StoreConnect retries a failed import a few times and then stops, so check the link is public and downloadable before trying again.
- If you were replacing existing media, use the old-to-new URL mapping to update every reference to the old URL in your templates and records, then confirm those pages now load the CDN version.
- To attach media to products, see Add media to products.
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.