Mailing List Archive

simple media update
Hi,
I need to save some json code into a media file from a template.
All I find is
$image->upload_file( $fh, $fname );

How to store a string directly into $image file?

Regards, Zdravko
Re: simple media update [ In reply to ]
On Jan 10, 2012, at 11:48 PM, Zdravko Balorda wrote:

> Hi,
> I need to save some json code into a media file from a template.
> All I find is
> $image->upload_file( $fh, $fname );
>
> How to store a string directly into $image file?

Open a file handle on the JSON string:

open my $fh, '<', \$json;
$image->upload_file($fh, 'some.json');

HTH,

David
Re: simple media update [ In reply to ]
On Jan 10, 2012, at 11:48 PM, Zdravko Balorda wrote:

> Hi,
> I need to save some json code into a media file from a template.
> All I find is
> $image->upload_file( $fh, $fname );
>
> How to store a string directly into $image file?

Open a file handle on the JSON string:

open my $fh, '<', \$json;
$image->upload_file($fh, 'some.json');

HTH,

David
Re: simple media update [ In reply to ]
David E. Wheeler wrote:
> On Jan 10, 2012, at 11:48 PM, Zdravko Balorda wrote:
>
>> Hi,
>> I need to save some json code into a media file from a template.
>> All I find is
>> $image->upload_file( $fh, $fname );
>>
>> How to store a string directly into $image file?
>
> Open a file handle on the JSON string:
>
> open my $fh, '<', \$json;
> $image->upload_file($fh, 'some.json');
>

This works, too?! Well, all one needs to know in life, is Perl. :)
Thanks, Zdravko
Re: simple media update [ In reply to ]
David E. Wheeler wrote:
> On Jan 10, 2012, at 11:48 PM, Zdravko Balorda wrote:
>
>> Hi,
>> I need to save some json code into a media file from a template.
>> All I find is
>> $image->upload_file( $fh, $fname );
>>
>> How to store a string directly into $image file?
>
> Open a file handle on the JSON string:
>
> open my $fh, '<', \$json;
> $image->upload_file($fh, 'some.json');
>

This works, too?! Well, all one needs to know in life, is Perl. :)
Thanks, Zdravko