Thread tagged as: Question, Problem, Suggestions

No easy way to replace a document / asset?

Unless I'm missing something, there is no simple way to replace a linked pdf.

Common use case: We have a list of PDF documents available for download. We have them set to upload into a "bucket" at /resources/docs. We would like to simply update one, without changing the file name or title.

What perch does: If you go into Perch assets and upload the replacement, it does not respect the bucket location of the original. It simply places the new document into the root /resources file. If you instead go into the page editor for the page with the downloads template (with the "docs" bucket specified) it does not replace the original file. Instead it creates a new file by appending a "-1" on the file name.

Why this is a problem: We do not wish to change the file name. We want it to be simple, readable, and more importantly we want existing links to the document (both internal and external) to remain working.

Even if you first delete the document/asset before attempting to replace it, perch doesn't actually delete the original file. So it seems if you want to replace a document, the only recourse is to FTP. But I would really prefer a simple "replace document" feature so that any content editor can easily handle this recurring task.

Dominic Tocci

Dominic Tocci 0 points

  • 1 week ago
Drew McLellan

Drew McLellan 2564 points
Perch Support

If you had an image, say, photo.jpg in use on the site, and then 6 months later, someone else uploads a completely different file called photo.jpg, would you expect the first to be replaced?

I see your dilemma, but surely if I edit an asset directly and upload another with the same name, I would expect it to be replaced.

The issue remains that there seems to be no possible way in Perch to simply replace a pdf with another one without changing the name or living with the "-1" at the end. Perhaps a checkbox option "replace this asset with the new one?" or something and/or some warning text "this document will be renamed blahblahblah-1.pdf because blahblahblah.pdf already exists and will not be deleted at this time". Or "a file with the same name already exists. replace it?".

What I've resorted to doing for the clients who need it is providing them with FTP access to a documents folder and instructions to overwrite the old documents. Otherwise, as I mentioned, all existing links internally and externally that must point to the document would break. It just seems like the CMS that I provide to them should handle this situation.

Drew McLellan

Drew McLellan 2564 points
Perch Support

Something like a checkbox to overwrite could work for some types of resource bucket. Of course if you're uploading to a bucket that is distributed via a CDN, the file names need to be unique or the file won't get replicated.

Out of interest, what's the scenario where there are links to a specific file? Links from within your site are under your control, and more commonly external links would go to a page on the site that supplies the file rather than the asset itself.

This mostly affects PDF downloads. Most of the time there is a resources section of the site which lists the various PDF files available for download. Then, throughout the site's content, any mention of one of these documents would be directly linked to the file. I would not link back to the resources page as that introduces an extra click and force visitors to scan a separate page to find the desired document. Furthermore, there may be subdomains or external sites that link directly to the file, which are not under the control of the CMS.

A generalized example: Imagine a government website that has a PDF download to apply for some sort of license. If I were integrating Perch into this site, I would first create a resources page with the various license application forms, using a multiple region. Then, throughout the dozens of pages of the site there may be references to "apply for your license" or "download the license application form", and in each of these instances the text would be linked back to the appropriate license application form, not the resources page. In my experience, most of these links end up in textareas, so Perch would not easily be able to track and update these automatically if the file name changes.

Each time the content editor updates the file, the file name changes, all of those links must be manually searched and updated. This is somewhat of a burden, but even worse are the subdomains or external sites that may be linking to these documents directly. With Perch, the old document is not removed, so the external links would be providing users with the old file. And if the old file is manually deleted from the server, those external links would then break.

The easiest thing from a maintenance perspective is to simply upload a new file in place of the old one. Then there is no need to search-up and replace any links to the old file, and no risk of external links still accessing the old file. The only other solution I can think of would be to use redirects for specific assets, so that the link to the file would remain the same based on the asset ID but the server would then deliver the latest version of the PDF, whatever it happened to be named.