简体   繁体   English

在googledrive中的特定文件夹中上传文件

[英]Uploading files in a specific folder in googledrive

I have used the following url to upload files to Googleddrive using curl in php 我已经使用以下网址使用php中的curl将文件上传到Googleddrive

https://www.googleapis.com/upload/drive/v2/files?uploadType=media.

It' working fine to upload files in main outside folder ie drive.But How to upload files in a specific folder.I have folderid. 可以将文件上传到外部主文件夹(例如drive),但工作正常。但是如何上传特定文件夹中的文件。我有folderid。

I tried following url to upload files in inner folders but it does not work:- 我尝试按照以下url上传内部文件夹中的文件,但不起作用:-

https://www.googleapis.com/upload/drive/v2/files/{folderid}?uploadType=media.

If anyone can help me.I will be very thankful. 如果有人能帮助我,我将非常感激。

You have to set the id of the target folder in the parents collection in metadata: 您必须在元数据的父集合中设置目标文件夹的ID:

{
  "title" : "My document",
  "mimeType" : "image/jpeg",
  "parents": [{
    "kind": "drive#file",
    "id": "<folderId>"
  }]
}

Are you using PHP for this? 您正在为此使用PHP吗? If so, then I will recommend using the PHP API client by Google as they do the heavy lifting for you. 如果是这样,那么我建议您使用Google的PHP API客户端,因为它们可以为您完成繁重的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM