How to find where content is located based on url

Vote:
 

I have a pdf document somewhere hidden in my filestructure. The search in Media doesn't return it. But I do have the public url, which contains an ID: /contentassets/539a7275ce4540dda9b5388aefb26ae5/laptopspecificaties-cmi-opleidingen.pdf. How can I find this file under Media to be able to delete this, since there's no EPiServer ID, only the contentasset ID?

#224694
Jun 24, 2020 11:50
Vote:
 

I would start by getting the getting the content link

            var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
            IContent contentData = urlResolver.Route(new UrlBuilder("/contentassets/539a7275ce4540dda9b5388aefb26ae5/laptopspecificaties-cmi-opleidingen.pdf"));
            var contentLinkID = contentData.ContentLink.ID;

Then you can load the parents and figure out where thy are.

#224764
Jun 25, 2020 10:51
Vote:
 

Thanks Johan. But we do have this problem on a more regular basis, so I was hoping there is something in EPi itself that an editor can use to find items like these.

#224767
Jun 25, 2020 11:50
Vote:
 

Create an admin tool that calls the code snippet privided by Johan.

Input: public URL

Output: link to edit mode URL

#224803
Jun 26, 2020 9:26
Vote:
 

Thanks for the tip. Would be an option, but the user wouldn't be able to delete the file, because he doesn't know where it's located. The edit mode doesn't show that path. So we would need the actual folder. And... it's strange that it doesn't come out of the box. Surely we aren't the only ones who have this issue of not being able to locate files in the epi filesystem based on the url. 

#224806
Jun 26, 2020 9:56
Tomas Hensrud Gulla - Jun 26, 2020 10:07
You could add a delete button to the admin tool, but I would not suggest doing that. You want users to get the warning of any incoming links before deleting.

If you provide an link to edit mode for the pdf, i.e something like: domain.com/EPiServer/CMS/?language=no#context=epi.cms.contentdata:///42&viewsetting=viewlanguage:///no you will see the actual location at the top left, above the file name.
Tomasz Madeyski - May 07, 2021 8:31
This is true, but in case of assets created with "for this page" location seen above file name is not much of use: all it says is "For this page > fileName.jpg"
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.