Skip Menu |

This queue is for tickets about the CGI-Uploader CPAN distribution.

Report information
The Basics
Id: 14602
Status: open
Priority: 0/
Queue: CGI-Uploader

People
Owner: Nobody in particular
Requestors: diona [...] modernflow.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Metadata support for multiple file uploads
Hi Mark, I've set up multiple file uploads using this module. My form elements look like: img_1 img_2 img_3 I'd like to add img_1_description, img_1_caption, img_2_description, img_2_caption...and have the values of the field inserted into a column called 'description', 'caption'. These columns exist in the file table with all the other metadata. I'm thinking of looking into extending store_uploads (if possible) to do this. Or is there another way to do this? I looked over the cookbook, docs and code without anything jumping out at me.
Date: Thu, 15 Sep 2005 11:27:12 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-CGI-Uploader [...] rt.cpan.org>
Subject: Re: [cpan #14602] Metadata support for multiple file uploads
RT-Send-Cc:
On Thu, Sep 15, 2005 at 12:03:32PM -0400, Guest via RT wrote: Show quoted text
> > This message about CGI-Uploader was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=14602 > > > Hi Mark, > > I've set up multiple file uploads using this module. My form elements look like: > > img_1 > img_2 > img_3 > > I'd like to add img_1_description, img_1_caption, img_2_description, img_2_caption...and have the values of the field inserted into a column called 'description', 'caption'. These columns exist in the file table with all the other metadata. > > I'm thinking of looking into extending store_uploads (if possible) to do this. Or is there another way to do this? I looked over the cookbook, docs and code without anything jumping out at me.
Diona, This may already supported by passing $shared_meta to store_uploads(). However, it's poorly documented I see now. [ looks further ]... and only works if you want the same extra meta data for each image. It's something I would like to support and it needs some help now. However, this project is lower in my personal interest queue now, so patches or other collaboration are welcome. Mark
Mark, I found a quick way to do it that works for my numbered form element scheme of img_n_columnname. I defined in the table map: description => undef caption => undef then later in the code... my $result = $u->store_uploads($form_data); my $meta; for(1..10) { my $img_id_field = 'img_'.$_.'_id'; if($result->{$img_id_field}) { # if id is returned, then file was uploaded # now store description and caption $meta->{description} = $result->{"img_${_}_description"}; $meta->{caption} = $result->{"img_${_}_caption"}; $u->store_meta(undef, $meta,$result->{$img_id_field}); } } Granted, it's a hack but it works thanks to the store_uploads method returning the transformed hash. Maybe useful for the cookbook until the feature exists?