develooper Front page | perl.beginners | Postings from May 2019

Re: can I use some kind of binary string?

Thread Previous | Thread Next
From:
Shlomi Fish
Date:
May 11, 2019 09:32
Subject:
Re: can I use some kind of binary string?
Message ID:
20190511120718.4f5ed18e@telaviv1.shlomifish.org
Hi hwilmer,

On Fri, 10 May 2019 19:09:50 +0200
hwilmer <hw@gc-24.de> wrote:

> Hi,
> 
> I would like to use curl to retrieve an image from a web server which I 
> want to store in a table in a mariadb database without downloading the 
> image to a file.  For this application, I do not want to store 
> references to files stored in some file system instead.
> 
> So I would want to use something like
> 
> 
> my $binary_data = `curl -k "https://www.example.com/some.jpg"`;
> 

Perl distinguishes between 8-bit/binary strings and unicode ones. See
https://perldoc.perl.org/perlunitut.html .

Note however that you should see https://perl-begin.org/uses/web-automation/
and use a module instead of trapping curl.exe's output. Perl has bindings to
libcurl too if that is what you want.

> 
> The image then needs to be inserted into a LONGBLOB field via DBI in 
> such a way that the image can be restored as it was.
> 
> Will string conversions or something prevent this from working?
> 
> What is the usual way to do this?  It is certainly not ideal to have no 
> check on the amount of data that might be retrieved from the web server, 
> regardless whether I save it to an intermediate file or not.
> 
> To make things more difficult, the web server is using a self-signed 
> certificate.
> 



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/New-versions-of-the-GPL/

He who reinvents the wheel will likely design a square wheel and spend a year
trying to figure out why it doesn’t work properly.
    — Nadav Har’El, http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About