Skip Menu |

This queue is for tickets about the Flickr-Upload CPAN distribution.

Report information
The Basics
Id: 117085
Status: resolved
Priority: 0/
Queue: Flickr-Upload

People
Owner: SSEVERIN [...] cpan.org
Requestors: cpan [...] kensaku-yamaguchi.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.51
Fixed in: (no value)



Subject: accept array as photo argument
I find it useful to pass an array as the photo argument to Flickr::Upload so that I do not have to write the image data to a file and so that I can supply the file name separately, however the check (-f $args{'photo'}) in upload() does not allow this.
Subject: 0001-accept-array-as-photo-argument.patch
From 0be510ec9331341b464a3d57ca0da76ef34bb65b Mon Sep 17 00:00:00 2001 From: Kensaku Yamaguchi <cpan@kensaku-yamaguchi.org> Date: Sun, 21 Aug 2016 10:24:59 +0900 Subject: [PATCH] accept array as photo argument --- lib/Flickr/Upload.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Flickr/Upload.pm b/lib/Flickr/Upload.pm index 0d7746e..6c42324 100644 --- a/lib/Flickr/Upload.pm +++ b/lib/Flickr/Upload.pm @@ -125,7 +125,7 @@ sub upload { my %args = @_; # these are the only things _required_ by the uploader. - die "Can't read photo '$args{'photo'}'" unless $args{'photo'} and -f $args{'photo'}; + die "Can't read photo '$args{'photo'}'" unless $args{'photo'} and (ref $args{'photo'} eq "ARRAY" or -f $args{'photo'}); die "Missing 'auth_token'" unless $self->is_oauth or defined $args{'auth_token'}; # create a request object and execute it -- 2.1.4
Hi, Kensaku. I might be misunderstanding, but I'm not sure why your data would be in an array, as opposed to just being stored in a variable. I realize then you wouldn't be able to use 'ref' to decide how to handle the argument, but I think it might be better to just have a separate function in that case. It does sound like a useful capability, though, so I am interested in supporting it in some form. Regards, -Steve On Sun Aug 21 01:37:40 2016, https://me.yahoo.co.jp/a/.s1jk4sXP4Xi_0fY7OJ2.u240qM0mg--#7c583 wrote: Show quoted text
> I find it useful to pass an array as the photo argument to > Flickr::Upload so that I do not have to write the image data to a file > and so that I can supply the file name separately, however the check > (-f $args{'photo'}) in upload() does not allow this.
Subject: Re: [rt.cpan.org #117085] accept array as photo argument
Date: Mon, 22 Aug 2016 14:22:29 +0900
To: bug-Flickr-Upload [...] rt.cpan.org
From: Kensaku Yamaguchi <cpan [...] kensaku-yamaguchi.org>
Hi, Show quoted text
> I might be misunderstanding, but I'm not sure why your data would be in an array, as opposed to just being stored in a variable.
The purpose of the array is to re-use the interface provided by the HTTP::Request::Common POST function called in Flickr::Upload to create multipart/form-data content: If one of the values in the $form_ref is an array reference, then it is treated as a file part specification with the following interpretation: [ $file, $filename, Header => Value...] [ undef, $filename, Header => Value,..., Content => content ] The code in make_upload_request (which converts a scalar argument to an array ref so that it gets treated as a file part by POST) appears to anticipate that the "photo" argument might already be an array reference, although it considers it unlikely: # unlikely that the caller would set up the photo as an array, # but... if( defined $photo ) { $photo = [ $photo ] if ref $photo ne "ARRAY"; $args{photo} = $photo; } The only code prohibiting an array in "photo" is the check in upload(). It can be circumvented by calling make_upload_request and upload_request separately, but that should not be necessary. Best regards, Kensaku Yamaguchi
Thanks so much for clarifying. I've included this patch in the 1.6 release, which should show up on CPAN in the next hour or so.