Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know if the HttpSocket class handles multipart Http requests. But you can create it manually. I've done this in my <a href="http://github.com/neilcrookes/CakePHP-GData-Plugin" rel="nofollow noreferrer">CakePHP GData Plugin</a> that includes functionality for uploading videos to YouTube. The save method in the <a href="http://github.com/neilcrookes/CakePHP-GData-Plugin/blob/master/models/you_tube_video.php" rel="nofollow noreferrer">YouTubeVideo model</a> creates a multipart Http request with the first part containing an XML document with meta data about the video and the second part is the binary contents of the video file being uploaded:</p> <pre><code>// The boundary string is used to identify the different parts of a // multipart http request $boundaryString = 'Next_Part_' . String::uuid(); // Build the multipart body of the http request $body = "--$boundaryString\r\n"; $body.= "Content-Type: application/atom+xml; charset=UTF-8\r\n"; $body.= "\r\n"; $body.= $doc-&gt;saveXML()."\r\n"; $body.= "--$boundaryString\r\n"; $body.= "Content-Type: {$data[$this-&gt;alias]['file']['type']}\r\n"; $body.= "Content-Transfer-Encoding: binary\r\n"; $body.= "\r\n"; $body.= file_get_contents($data[$this-&gt;alias]['file']['tmp_name'])."\r\n"; $body.= "--$boundaryString--\r\n"; $this-&gt;request = array( 'method' =&gt; 'POST', 'uri' =&gt; array( 'host' =&gt; 'uploads.gdata.youtube.com', 'path' =&gt; '/feeds/api/users/default/uploads', ), 'header' =&gt; array( 'Content-Type' =&gt; 'multipart/related; boundary="' . $boundaryString . '"', 'Slug' =&gt; $data[$this-&gt;alias]['file']['name'] ), 'auth' =&gt; array( 'method' =&gt; 'OAuth', ), 'body' =&gt; $body, ); </code></pre> <p>This might get you there.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload