Changing the downloaded filename using Dynamic Media on AEM | Community
Skip to main content
pcardno
Level 2
March 9, 2022
Solved

Changing the downloaded filename using Dynamic Media on AEM

  • March 9, 2022
  • 1 reply
  • 1297 views

Hi all,

We get a lot of requests from our customers to deliver assets with different, customer specific filename conventions (e.g. PRODUCTID_SHOTCODE.jpg), which isn't the name we give the files in AEM Assets. This applies to images, files etc.

 

I've gone through the Image Serving API for dynamic media (https://experienceleague.adobe.com/docs/dynamic-media-developer-resources/image-serving-api/image-serving-api/http-protocol-reference/command-reference/c-command-reference.html?lang=en) but can't find anything in there that suggests how to do this. Essentially, I want to be able to do something like:

 

https://s7d1.scene7.com/is/image/3m/Cat?crop=100,100,300,300&downloadFilename=croppedcat.jpg

 

This would allow us to build other integrations with our product catalogue and data syndication tools to mass download assets with the right names by default, prior to sending to customers, rather than having to download everything and then run a rename script.

 

Does anyone know if this is possible?

 

Thanks!

 

 

Paul.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by vikram1285

Hi Paul,

Welcome to Adobe Community !!

URL transformation is possible when you have applied rulesets on that configured Dynamic Media account (on your AEM Assets Author)

Detailed information available here : https://experienceleague.adobe.com/docs/experience-manager-65/assets/dynamic/using-rulesets-to-transform-urls.html?lang=en

In case you need example for rulesets and how they are created, please refer to this document : https://experienceleague.adobe.com/docs/dynamic-media-developer-resources/image-serving-api/image-serving-api/rule-set-reference/c-rule-set-reference.html?lang=en

 

Note : Please test rulesets on a Dynamic Media Staging environment or a test account on your Dynamic Media Production environment.
Thanks,

Vikram Gaur

1 reply

vikram1285Adobe EmployeeAccepted solution
Adobe Employee
March 9, 2022

Hi Paul,

Welcome to Adobe Community !!

URL transformation is possible when you have applied rulesets on that configured Dynamic Media account (on your AEM Assets Author)

Detailed information available here : https://experienceleague.adobe.com/docs/experience-manager-65/assets/dynamic/using-rulesets-to-transform-urls.html?lang=en

In case you need example for rulesets and how they are created, please refer to this document : https://experienceleague.adobe.com/docs/dynamic-media-developer-resources/image-serving-api/image-serving-api/rule-set-reference/c-rule-set-reference.html?lang=en

 

Note : Please test rulesets on a Dynamic Media Staging environment or a test account on your Dynamic Media Production environment.
Thanks,

Vikram Gaur

pcardno
pcardnoAuthor
Level 2
March 11, 2022

Thank you @vikram1285 , that's really helpful! If I'm reading it correctly, this says that we could supply a specific URL parameter and use that to reformat the response URL, e.g. with the example

 

https://s7d1.scene7.com/is/image/3m/Cat?crop=100,100,300,300&downloadFilename=croppedcat.jpg

 

 

<rule>
   <expression>#CLEVER_REGEX_TO_FIND_"downloadFilename"_AND_PULL_QUERY_PARAMETER_"croppedcat.jpg"#</expression>
   <substitution>#REPLACE_FILENAME_WITH_"croppedcat.jpg"#</substitution>
</rule>

Is that right, i.e. we can program the rulesets to do something specific if we deliver a specific URL structure?

 

Thanks,

 

 

Paul.

Adobe Employee
March 11, 2022

Hi Paul

That looks good.

You just have to create a "CLEVER_REGEX" now.

For example myCat/myImage/small would translate to myCat/smallTemplate?src=myCat/myImage 

 

Using this rule : 

<rule>
   <expression>([^/]+)/(small|medium|large)$</expression>
   <substitution>$2Template?src=sample/$1</substitution>
</rule>

 

Thanks,

Vikram Gaur