使用Google Client API恢复上传.无效的上传网址

问题描述:

我无法使用此api执行断点续传,请帮助我.此代码在我使用断点续传之前运行正常.我可以使用分段上传文件,但不能通过分段上传大文件

I am unable to perform resumable upload using this api please Help Me.This Code Working Fine Until i used resumable Upload . I can Upload FIle Using Multipart but not able upload big files with multipart

我的代码

            $storageObject->setName("FIle Name.mp3");
            $storageObject->setBucket($data["bucket_name"]); 
            $mimetype = mime_content_type($data["temp_name"]);

            $chunkSizeBytes = 1 * 1024 * 1024;

            $storageClient->setDefer(true);

            $status = false;

            $filetoupload = array('name' => "FIle Name.mp3", 
           'uploadType' => 'resumable');

            $request = $storageService->objects->insert(
            $data["bucket_name"], $storageObject, $filetoupload );

            $media = new Google_Http_MediaFileUpload($storageClient,
            $request, $mimetype, null, true, $chunkSizeBytes);

            $media->setFileSize(filesize($data["file_temp_name"]));
            $handle = fopen($data["file_temp_name"], "rb");

            while (!$status && !feof($handle)) 
            {
               $chunk = fread($handle, $chunkSizeBytes);
               $status = $media->nextChunk($chunk);
            }

            $result = false;
            if($status != false) {
            $result = $status;
            }


            $storageClient->setDefer(false);

响应错误

      {
      "error": {
        "errors": [
        {
      "domain": "global",
          "reason": "wrongUrlForUpload",
       "message": "Upload requests must include an uploadType URL parameter and a URL path beginning with /upload/",
       "extendedHelp": "https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload"
      }
     ],
     "code": 400,
      "message": "Upload requests must include an uploadType URL parameter and a URL path beginning with /upload/"
      }
     }**

您的上传URL不正确,因为每当您必须上传文件时,在云存储桶中,上传URL的路径就非常重要.不仅在Google Cloud上,甚至在Amazon S3或任何其他云存储环境中.这些存储桶为您的文件上传位置创建标准路径,并通过CDN边缘使其可用.因此,有必要设置上传路径.

Your upload url is not correct, because whenever you have to upload your files, in cloud buckets the path for Upload URL is very important. Not only on Google Cloud but even in Amazon S3 or any other cloud storage environments. These buckets create standard path for your file upload location, and make it available via CDN edges. SO it is necessary to set upload path.

要使基于HTML的标准文件上传,请参考此链接. https://cloud.google.com/appengine/docs/standard/php/googlestorage/user_upload

For making standard HTML based file upload refer this link. https://cloud.google.com/appengine/docs/standard/php/googlestorage/user_upload

https://cloud.google.com/appengine/docs/standard/php/googlestorage/