Using PHP curl to store object with open stack API file storage -


i using php curl call open stack's api store object. curl call looks this

 $token = $this->gettoken();         $url = 'http://myfilestorageurl.com/v1/auth_volume/container/dummyfile.pdf';     

dummyfile.pdf file name want stored file called.

    $ch=curl_init();     curl_setopt($ch, curlopt_httpheader, array(         'x-auth-token:'.$token,         'content-length: 5611',      //not sure if required         'x-http-method-override: put',   //not sure if required         'content-location:/data/dummyfile.pdf'     ));       curl_setopt($ch, curlopt_url, $url_call);     curl_setopt($ch, curlopt_header, true);     curl_setopt($ch, curlopt_customrequest, "put");          $response = curl_exec($ch); 

the response keeps returning 408 request timeout

has figured out. specifying file location uploaded correctly using content-location header or there way do.

for whos having same issue solved problem following way:

 $url = 'http://myurltouploadfileto.com';  $fp = fopen('http://urltofiletoupload.com');  $ch=curl_init();  curl_setopt($ch, curlopt_httpheader, array('x-auth-token:sometoken'));  curl_setopt($ch, curlopt_put, true);  curl_setopt($ch, curlopt_infile, $fp);     //this main 1 missing  curl_setopt($ch, curlopt_url, $url);  curl_setopt($ch, curlopt_header, true);  curl_setopt($ch, curlopt_returntransfer, true);  curl_setopt($ch, curlopt_customrequest, "put");     

this seemed resolve , upload file url object storage server.


Comments