Mailing List Archive

How to check if a media file with a particular URI exists
How do I check whether a media file (or story) with a particular URI exists? I ask because I can't republish a particular story on our site, getting the following error:

---
Story "May 1980 - Issue 087" saved and checked in to "Publish".

The URI "/issues/1980/05/01/110px_087-mag-cover.jpg" is not unique. Please change the cover date, output channels, category, or file name as necessary to make the URIs unique.
---

Here's the code in the template for that story which seems to be responsible this, which I'm guessing I need to execute only after checking that media file doesn't exist:

$m->comp('/util/alt_media.mc',
file_prefix=>"110px_",
newmedia_title_prefix=>"110px for ",
geom_x=>"110");
Re: How to check if a media file with a particular URI exists [ In reply to ]
Hi Tom,

If you're using the find_or_create_alternate() method to make
thumbnails, you shouldn't need to bother, because that method itself
first looks for a media asset based on the desired URI, and only makes a
fresh one if there is not one in the library.

But you can search on URI for both media and story assets, using the
list() method, like this:


my ($media_asset) = Bric::Biz::Asset::Business::Media->list({
active => 1,
unexpired => 1,
uri => $your_uri_goes_here
});

Use Bric::Biz::Asset::Business::Story to search for stories, but the
idea is the same.

I imagine your alt_media.mc template is trying to re-create an asset
that already exists, and that's the source of the problem. So probably
that template is the one that needs a change.



Hope this helps,

Bret


On Mon, 2011-07-11 at 15:27 +0100, Tom Ash wrote:
> How do I check whether a media file (or story) with a particular URI exists? I ask because I can't republish a particular story on our site, getting the following error:
>
> ---
> Story "May 1980 - Issue 087" saved and checked in to "Publish".
>
> The URI "/issues/1980/05/01/110px_087-mag-cover.jpg" is not unique. Please change the cover date, output channels, category, or file name as necessary to make the URIs unique.
> ---
>
> Here's the code in the template for that story which seems to be responsible this, which I'm guessing I need to execute only after checking that media file doesn't exist:
>
> $m->comp('/util/alt_media.mc',
> file_prefix=>"110px_",
> newmedia_title_prefix=>"110px for ",
> geom_x=>"110");

--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret@pectopah.com
www.pectopah.com