Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google drive api elixir将文件上载到google drive_Google Drive Api_Elixir - Fatal编程技术网

Google drive api elixir将文件上载到google drive

Google drive api elixir将文件上载到google drive,google-drive-api,elixir,Google Drive Api,Elixir,我遵循谷歌驱动api的指示 这是我的请求主体 multipart_request_body = --1234567 Content-Type: application/json { name: "text.csv", mimeType: "text/csv"} --1234567 Content-Length: 18 Content-Type: text/comma-separated-values Content-Transfer-Encoding: binary id,promo\

我遵循谷歌驱动api的指示 这是我的请求主体

multipart_request_body = 
--1234567
Content-Type: application/json


{ name: "text.csv", mimeType: "text/csv"}
--1234567
Content-Length: 18
Content-Type: text/comma-separated-values
Content-Transfer-Encoding: binary


id,promo\n1,asdadas
--1234567--
和标题

headers = [{"Content-Type", "multipart/related; boundary=1234567"},
           {"Content-Length", byte_size(multipart_request_body)},
           {"Authorization","Bearer #{access_token}"}]`
和url

api_url = "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"
我正在使用
HTTPoison
发出post请求:

response = HTTPoison.post!(api_url,multipart_request_body, headers)
我得到的是
status_code:200
,返回的元数据是
%{“id”=>“0B6Xd6TBQkqUPM0s4TEY5SGRXcU0”,“kind”=>“drive#file”,
“mimeType”=>“text/csv”,“name”=>“text.csv”}

但是当我检查我的谷歌硬盘时,文件根本不存在,我无法使用return
id
获取文件


我在这里被困了好几个小时了,有谁能帮我这里出了什么问题吗?

服务帐户不是你的。将服务帐户视为虚拟用户。它有自己的驱动器帐户,谷歌日历帐户,可能还有更多

当您上载到服务帐户时,您正在上载到服务帐户Google drive帐户。无法通过图形方式访问服务帐户驱动器帐户,例如Google驱动器网站

现在你有几个选择

  • 与服务帐户共享google drive帐户上的文件夹,并通过将要上载的文件的父id设置为帐户上文件夹的id来上载到该文件夹。与此相关的问题包括权限,服务帐户将拥有该文件,并且必须升级该文件的权限,以便为您的用户提供访问该文件的google帐户
  • 让服务帐户在其帐户上创建一个目录,并与您的个人谷歌帐户共享。与此相关的问题还包括对相关文件的权限。仅仅因为当文件添加到目录时,您的个人帐户可以访问该目录,所以必须对其进行修补以使您能够访问该目录,这不是自动完成的。因此,可以访问目录,但不能访问已上载到目录中的文件
  • 为服务帐户创建自己的图形界面。使用file.list返回驱动器帐户上当前文件的列表

  • 我的服务帐户教程深入介绍了服务帐户的工作原理。

    您确定access\u令牌与您正在检查的Google Drive帐户属于同一帐户吗?上传后,请尝试创建一个files.list。API说它已经上传了。它会给你一个上传文件的文件id。这可能是您正在使用的服务帐户,并且您正在上载到服务帐户驱动器帐户。@DaImTo是的,我正在使用服务帐户上载文件,如何查看服务帐户驱动器帐户?