title: google cloud storage curl php upload
body: <p>I am trying to upload  a file to google cloud storage using Curl php.</p>
  
  <pre><code>define("BASE","https://www.googleapis.com/upload/storage/v1/b/");
  $key='XXXXX';
  $authheaders = array(
  "Authorization: Bearer " .$key,
  "Content-Type: image/jpeg"
  );
  
  $bucket='gs://storage-8c79a.appspot.com';
  
  $file='1234';
  $fileName='1.pdf';
  $url=BASE.$bucket.'/o?name=name_of_file.jpg&amp;uploadType=multipart';
  $curl = curl_init();
  
  curl_setopt($curl, CURLOPT_POSTFIELDS, $file);
  
  curl_setopt($curl, CURLOPT_HTTPHEADER, $authheaders);
  curl_setopt($curl, CURLOPT_URL, $url);
  
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($curl, CURLOPT_USERAGENT, "HTTP/1.1.5");
  
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
  // 1 is CURL_SSLVERSION_TLSv1, which is not always defined in PHP.
  curl_setopt($curl, CURLOPT_SSLVERSION, 1);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_HEADER, true);
  
  
  $response = curl_exec($curl);
  echo $response;
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>HTTP/1.1 404 Not Found X-GUploader-UploadID: AEnB2UriDzXPtSs2Gac2BVfR4b4abfkroNy5gBCg8D85az3MK69YubPCCp_k3cx64A2MsSCMu-N_4F-RfFe10Vh_GjUbrjkrkzZ4NJ3Tlry4I8js-pgUqtw Vary: Origin Vary: X-Origin Content-Type: text/html; charset=UTF-8 Content-Length: 9 Date: Tue, 23 Aug 2016 09:57:23 GMT Server: UploadServer Alternate-Protocol: 443:quic Alt-Svc: quic=":443"; ma=2592000; v="35,34,33,32,31,30" Not Found</p>
  </blockquote>
  
  <p>Please help me to solve this.</p>