Manage media files and PDF attachments with CSV
You will learn how to mass update media files in AI Commerce : categories, export/import, safe updates, and best practices.
Separate a file and its metadata row
The CSV tool is suitable for bulk management of media categories and metadata for media files associated with products. However, it does not download a PDF or image file from an external URL or upload the file to a storage service. Before importing, make sure that the referenced file is already in an approved storage location.
- Export and import media categories: manage category codes, order, and language-specific names.
- Export and import media files: manage the filenames, categories, order, and descriptions of your product media lines.
Always start with the export and use it as a base for editing. Change only the intended lines, preview the import, and make sure that the current file references, language texts, and categories are preserved before the execution phase.
CSV is suitable for managing metadata for a large number of media files and media categories at once. However, it does not prove the current functionality of uploads/ , uploads/products/manuals/ , uploads/products/images/ , Amazon S3 or AWS storage paths mentioned in the old instructions; these are confirmed in a separate storage agreement.
The work is done by exporting the current CSV file, editing it in a spreadsheet program, and importing it back in. The same file can handle multiple PDF manuals, images, and other media lines attached to products, but the actual files must be managed in an approved upload process.
Use two pairs of profiles: Media Categories Export/Import and Media Files Export/Import . Always export before editing. The export template includes the current tags, allowed headers, and columns for the installed data languages.
Export and edit media categories
Managing media files and PDF attachments with CSV uses the columns categories_code , sort , delete , and name[<kieli>] in media categories. For example, the columns for Finnish and Estonian are name[fi] and name[et] . categories_code is a mandatory header and row identifier for the import.
The existing code updates the category order and the included language names. The unknown code creates a new category. A language missing from the header will keep the existing name, but an included empty language cell will set that value to empty. Therefore, check the language columns in the export template before importing.
Delete media category via preview only
Managing media files and PDF attachments with CSV deletes an existing media category when delete column reads exactly CONFIRM . An empty value indicates creation or update; any other non-empty value is an error. An unknown category code cannot be deleted.
categories_code,sort,delete,name[fi],name[et]
manuals,10,,Käyttöohjeet,Juhendid
old-manuals,0,CONFIRM,,The impact of the deletion on the media rows associated with the category should be checked in the preview and in a separate ownership agreement. Do not conclude from a CSV row alone whether a file, a reference, or just a category is being deleted.
Export metadata for media files
Managing media files and PDF attachments with CSV uses the basic headers media_id , products_model , categories_code , filename , url , sort , media_type , media_size , and delete for media files. It also includes description[<kieli>] columns for available data languages, for example description[fi] .
The import file must contain at least the headers products_model and filename . Unknown or duplicate headers are not accepted. url is a valid export/import header, but the current processor does not use it to generate the change; the export leaves it blank.
Update an existing media row
Media file and PDF attachment management with CSV will primarily find an existing row with a positive media_id value. Without an ID, it can find a row with a combination of product and the exact same filename value. An unknown given media_id or products_model is an error.
filename header and non-empty value are also required for metadata updates. Do not leave the cell blank for description, order, or category updates. Keep the filename from the export and only change categories_code , sort , media_type , media_size , or description[<kieli>] values as intended.
Create a new media row
Managing media files and PDF attachments with CSV creates a new metadata row when media_id is missing and the product and filename combination does not match an existing row. products_model value must match the product and filename value must be non-empty.
The columns are in order media_id , products_model , categories_code , filename , url , sort , media_type , media_size , delete and description[fi] . The new row looks like this:
,SKU-123,manuals,manual-fi.pdf,,10,pdf,0.00,,Suomenkielinen käyttöohjeIf media_type is empty, the processor infers it from the filename suffix. media_size is normalized to a non-negative value of two decimal places and defaults to 0.00 . CSV does not check the actual MIME type or size of the file.
Do not use a remote URL as a file name
Managing media files and PDF attachments with CSV rejects filename value that starts with http:// or https:// . It will not fetch the remote file, save it to uploads/ folder, or overwrite a file with the same name. Writing to url column will also not trigger a fetch.
Upload a PDF or other permitted file first using your current File Manager or approved media process. For CSV, use only the filename that is consistent with your storage agreement. File types, size, malware scanning, permissions, and public URL are validated during the actual upload process.
Delete a media file metadata row
Managing media files and PDF attachments with CSV accepts deletion in two ways: delete=CONFIRM or filename=DELETE . Deletion requires an existing media row. The safest way is to use media_id value from the export and delete=CONFIRM annotation.
media_id,products_model,filename,delete
123,SKU-123,manual-fi.pdf,CONFIRMfilename=DELETE effectively requires media_id tag because the word DELETE cannot find an existing row with the combination of product and original filename. The current CSV delete deletes the media row from the database; the physical deletion of the object file is not reflected in this processor.
Preview and confirm the performance
Managing media files and PDF attachments with CSV is done in UTF-8 format without changing the export template separator and headers. Check the preview for rows to be created, updated, deleted, skipped, and invalid rows. Correct any errors before confirming the execution.
Start with a small sample. After execution, check media file rows, categories, order, language descriptions, and PDF link functionality in the storefront. Retain source material and execution report according to approved return and audit practices.
Column summary
Managing media files and PDF attachments with CSV uses the following conventions:
- Media categories:
categories_code,sort,delete,name[fi],name[et]and other available languages. - Media files:
media_id,products_model,categories_code,filename,url,sort,media_type,media_size,delete,description[fi]and other available languages. - Category deletion: existing
categories_codeanddelete=CONFIRM. - Media row deletion: existing row and
delete=CONFIRMorfilename=DELETE. - Remote file retrieval: not supported for CSV import of media files.
Keep the original export as a backup and restore point, don't change tags unnecessarily, and finally check both the metadata and the PDF link visible to the customer. When editing the file in Excel or another spreadsheet program, disable automatic formatting of product IDs, codes, and numbers. This way, large-scale CSV editing remains limited, auditable, and reversible.