将文件上载到google云存储(php curl)

将文件上载到google云存储(php curl),php,google-cloud-storage,postman,php-curl,Php,Google Cloud Storage,Postman,Php Curl,您好,我已经创建了我的google云存储帐户,用它来存储视频和文件,我使用这个rest api()在请求正文(filename=file)中发送上传的文件,当我试图使用postman来做这件事时,它成功地用这个php代码上传了 <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "http://acquired-backup-198200.appspot.com/upload?un

您好,我已经创建了我的google云存储帐户,用它来存储视频和文件,我使用这个rest api()在请求正文(filename=file)中发送上传的文件,当我试图使用postman来做这件事时,它成功地用这个php代码上传了

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://acquired-backup-198200.appspot.com/upload?uname=arun@gmail.com",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"filename\"; filename=\"current-logo.png\"\r\nContent-Type: image/png\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
  CURLOPT_HTTPHEADER => array(
    "Cache-Control: no-cache",
    "Postman-Token: 0c28e4e9-ac5d-42b9-9f7a-928b32bb3464",
    "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}