コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.
解決済み

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

Avatar

Level 2

  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?

トピック

トピックはコミュニティのコンテンツの分類に役立ち、関連コンテンツを発見する可能性を広げます。

1 受け入れられたソリューション

Avatar

正解者
Community Advisor

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...

Thanks

元の投稿で解決策を見る

5 返信

Avatar

Community Advisor

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

Avatar

Level 2

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

Avatar

正解者
Community Advisor

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...

Thanks

Avatar

Level 2

@MukeshYadav_ thanks, I will try

Avatar

Level 2

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.