定义收件人文件夹gdrive

时间:2016-12-25 19:49:21

标签: file-upload google-drive-api subdirectory

我正在使用gdrive将备份文件直接上传到谷歌硬盘,但收件人文件夹应该是BACKUP;我正在使用命令:

matrix

其中2016-12-25.tar.gz是备份文件。原样,文件上传到谷歌硬盘的主目录;将收件人文件夹设置为BACKUP的选项是什么?

谢谢

1 个答案:

答案 0 :(得分:1)

尝试查看文档Work with Folders,该文档将说明如何在文件夹中插入文件。

以下是php应用程序的示例代码:

$folderId = '0BwwA4oUTeiV1TGRPeTVjaWRDY1E';
$fileMetadata = new Google_Service_Drive_DriveFile(array(
  'name' => 'photo.jpg',
  'parents' => array($folderId)
));
$content = file_get_contents('files/photo.jpg');
$file = $driveService->files->create($fileMetadata, array(
  'data' => $content,
  'mimeType' => 'image/jpeg',
  'uploadType' => 'multipart',
  'fields' => 'id'));
printf("File ID: %s\n", $file->id);

现在检查您的代码,命令行代码,我找到了GitHub和教程 - How to upload a file to Google Drive from the command line,这里有用于将文件上传到文件夹的示例代码:

gdrive upload --parent 0B3X9GlR6EmbnY1RLVTk5VUtOVkk

//gdrive [global] upload [options] <path>
//-p, --parent <parent>     Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents

希望这有帮助。

相关问题