Want to get the content of YAML files instead of downloading them (AEM 6.5) | Community
Skip to main content
Level 2
December 20, 2024
Solved

Want to get the content of YAML files instead of downloading them (AEM 6.5)

  • December 20, 2024
  • 3 replies
  • 1266 views

  Hi,
  I have some yaml files loaded as dam assets and some of yaml files are directly uploaded under the /content/project/page/jcr:content/root/myComponent/file with the help of cq/gui/components/authoring/dialog/fileupload. When I try to get the content of the files(for example /content/dam/project/file.yaml) I got the response with the header Content-Disposition: attachment; filename="file.yaml" and download window opens.
  I tried to change some OSGI configs, tried to write servlet and got no success.
  What can I do to get the content of the yaml files?

Best answer by MukeshYadav_

Hi @agyrki ,

If you want to have the functionality on dispatcher you can set content disposition inline.

Else you can create a filter for /content/dam pattern and check if extension of resource path contains .yaml set header to inline accordingly.

In the below post you may replace pdf with yaml and it should works

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/content-disposition-on-aem-as-cloud/m-p/435636

Thanks

3 replies

anupampat
Community Advisor
Community Advisor
December 20, 2024

Hi @agyrki ,

 

I wonder if you can downlaod the file, usually when you hit http://localhost:4502/content/dam/project/file.yaml in your browser (replace the necessary paths ) the file gets downloaded and then you can read it as a text file on your computer, unless you need to programatically read the yaml file and extract the content to use it for another purpose ?

 

Regards,

Anupam Patra

agyrkiAuthor
Level 2
December 22, 2024

Hello @anupampat,
there will be calls to this yaml files from 3rd party service and it will need to get the content of these files

MukeshYadav_
Community Advisor
MukeshYadav_Community AdvisorAccepted solution
Community Advisor
December 20, 2024

Hi @agyrki ,

If you want to have the functionality on dispatcher you can set content disposition inline.

Else you can create a filter for /content/dam pattern and check if extension of resource path contains .yaml set header to inline accordingly.

In the below post you may replace pdf with yaml and it should works

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/content-disposition-on-aem-as-cloud/m-p/435636

Thanks

agyrkiAuthor
Level 2
December 22, 2024

@mukeshyadav_ thanks, I will try

agyrkiAuthor
Level 2
December 23, 2024

By the way I solved my problem with the help of the org.apache.sling.commons.mime.internal.MimeTypeServiceImpl.cfg.json.
I added to default values of the config my mimetype:
{
  "mime.types": ""text/x-yaml yaml yml"
}
and the response header "Content-Type" changed from "application/octet-stream" to the "text/x-yaml" and now request to the /content/dam/project/file.yaml is showing file content.