我正在尝试使用 javascript drive api 将文件夹上传到谷歌驱动器并保持其目录结构。我实现了上传所有文件但不是文件夹中的文件夹。我还实现了通过驱动器 api 将一个空文件夹上传到谷歌驱动器。但是,我找不到解释上传文件夹并保留其所有目录结构的资源。例如,我有一个这样的文件夹:(我添加了一个链接来显示我的示例文件夹。由于我的声誉低,我无法添加直接图像。) http://postimg.org/image/h52bvb71v/
但是当我选择文件夹时,我可以上传 .txt 文件。至少 google drive api Javascript Quickstart 为我提供了该代码。我不想破坏文件夹的结构,我想将其上传到具有原始结构的驱动器。您知道我如何使用 google drive api 和 javascript 执行此操作吗?谢谢。
这是我的代码。它只是上传文件夹内的文件,而不是文件夹。
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<script type="text/javascript">
var CLIENT_ID = 'xxxxxxxxxxxxxxxxxxx';
var SCOPES = 'https://www.googleapis.com/auth/drive';
/**
* Called when the client library is loaded to start the auth flow.
*/
function handleClientLoad() {
window.setTimeout(checkAuth, 1);
}
/**
* Check if the current user has authorized the application.
*/
function checkAuth() {
gapi.auth.authorize(
{ 'client_id': CLIENT_ID, 'scope': …Run Code Online (Sandbox Code Playgroud)