doumuyu0837 2013-07-11 18:06
浏览 70

使用PHP curl存储具有开放堆栈API文件存储的对象

I am using php curl to call open stack's api to store a object. My curl call looks like this

 $token = $this->getToken();       
 $url = '';    

dummyfile.pdf is the file name i want the stored file to be called.

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Length: 5611',      //not sure if its required
        'X-HTTP-Method-Override: PUT',   //not sure if its required

    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 a 408 Request Timeout

Has anyone figured this out. Also am i specifying the file location to be uploaded correctly using the content-location header or is there another way to do.

  • 写回答

1条回答 默认 最新

  • dongmin4052 2013-07-11 23:57

    For Anyone whos having the same issue i solved the problem the following way:

     $url = '';
     $fp = fopen('');
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Auth-Token:sometoken'));
     curl_setopt($ch, CURLOPT_PUT, true);
     curl_setopt($ch, CURLOPT_INFILE, $fp);     //this was the main one that i was 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 to resolve it and upload the file from the url to object storage server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型