Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
command: ..put( -local => "$fh", -url => "$url/$base_dir/$work_dir" + ) Reply..: put foo_Line_01 foo_Line_02 failed command: ..put( -local => \$fh, -url => "$url/$base_dir/$work_dir" + ) Reply..: put REF(0x274dc28) failed command: ..put( -local => $fhref, -url => "$url/$base_dir/$work_dir" + ) Reply..: put REF(0x274dc28) failed command: ..put( -local => "\$fh", -url => "$url/$base_dir/$work_dir" + ) Reply..: put $fh failed command: ..put( -local => "\$fhref",-url => "$url/$base_dir/$work_dir" + ) Reply..: put $fhref failed
Any idea how to handle the -local parameter of the HTTP::DAV put request for an InMemoryfile linehandler?

Yes, sure. As I wrote:

HTTP::DAV documents for the put method:

One can upload/put a string by passing a reference to a scalar in the -local parameter.

Of course, to access the scalar behind IO::Scalar, you need to pass a reference to a scalar to the constructor IO::Scalar->new(), see IO::Scalar. BTW: You would pass the same reference to HTTP::DAV's put() method.

# (untested) my $storage=''; my $handle=IO::Scalar->new(\$storage); # use $handle to write to $storage here my $dav=HTTP::DAV->new(); # set up $dav here $dav->put( -local => \$storage, -url => 'http://www.example.com/davdemo/scalar.txt', ) or die "Put failed: ",join("\n",$dav->message(),$dav->errors());

Stringifying references ("$fh", "\$fh", "\$fhref") can't work, put() needs a reference to a scalar to transfer the scalar's content. But stringifying creates a string like "SCALAR(0x1c34ac0)" that put() will treat as a file name.

Also taking a reference to a reference won't work, you would at best transfer the stringified inner reference. Passing a reference to a handle won't work, as put expects a reference to a scalar (or a plain scalar containing a file name).


Update:

Your -url parameter for put() seems to be a directory. From a quick look at the sources of HTTP::DAV and HTTP::DAV::Resource,the -url parameter must be a filename if -local is a scalar reference. Else, HTTP::DAV will try to upload something that looks like a file to the DAV server to a resource that is a directory, not a file. Most likely, no sane DAV server will accept that. If you use put() with a local filename and a URL that points to a directory, HTTP::DAV will append the local filename (without directories) to the URL behind the scenes. This does not happen when -local is a reference to a scalar. A scalar reference simply does not have a filename that could be extracted and appended to the URL.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^7: in memory files in 5.6.1 by afoken
in thread in memory files in 5.6.1 by mandog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-18 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found