How to get sitecore media item by a public URL ?
Background :
For one of my past projects, one of my Sitecore websites was displayed on mobile application WebView.
The user had the possibility to download pdf documents.
The mobile dev team wanted to create a new section “downloads” on application side to offer the possibility to the user to check its downloaded documents with its informations (title, size, thumbnail, etc..)
The idea was to create Rest API that to mobile application can consume for this need.
How to implement it ?
Mobile application ask Sitecore to get the document informations with in input the pdf public URL.
Example of pdf public URL :
https://assets.brand.com/fr/-/media/project/france/b2b/documentation/catalogues/001.pdf?la=fr-frGet pdf Item by Public URL :
Now, we have the pdf item. So, the next step is to retrieve document informations.
Get pdf informations :
Call application side :
https://mywebsite.com/sxa/api/GetPdfInfos?path=https://assets.brand.com/fr/-/media/project/france/b2b/documentation/catalogues/001.pdf?la=fr-frResult :
{
"result": {
"Title": "Brochure system",
"Description": "Brochure description",
"Extension": "pdf",
"size": "6586723",
"Thumbnail": "https://assets.brand.com/-/media/project/france/b2b/thumbnails/brochure.png"
}
}
Good one, good to check the spelling like,
application instead of appliaction
downloaded instead of downlowded
Hello Navan,
Thank you for your comment and support.
Good remark for spelling mistakes. Sorry for this.
I just did a review and made the corrections.