Get file name from file url | Community
Skip to main content
Level 3
September 20, 2021

Get file name from file url

  • September 20, 2021
  • 3 replies
  • 1399 views

Hello,

I have a field on Content fragment to add files. What returns to me is the file path. But, I should display the file name. Should I create an API for this, or there is already an API, where I can send the path so I can get the file and its name? Thanks!

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

3 replies

Kishore_Kumar_
Level 9
September 20, 2021

Hi @ad-engineer ,

 

Are you refering to "Content Reference" datatype field ?

Level 3
September 20, 2021

Hi @kishore_kumar_ yes exactly

Kishore_Kumar_
Level 9
September 20, 2021

May i know how you are using the content fragment ? Referring it in page using Content Fragment component ?

 

or exposing it as an API via graphql/HTTP assets api

Fanindra_Surat
Community Advisor
Community Advisor
September 20, 2021

Hi @ad-engineer - You can follow the same approach as in https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/get-page-description-from-page-url/td-p/423955

 

The response of .json call with contain the page name in the field jcr:title, pageTitle based on context of usage.

 

Thanks,

Fani

arunpatidar
Community Advisor
Community Advisor
September 20, 2021

Hi,

I am not sure of this is feasible because the reference generally used to read/fetch further content, so having path there make sense. Probably from front end/consumer API side you can trim the path and just use it file name as needed.

Arun Patidar