gpt4 book ai didi

flutter - 如何在 flutter 应用程序中使用 google Drive api 创建文件夹?

转载 作者:行者123 更新时间:2023-12-01 16:35:34 25 4
gpt4 key购买 nike

我尝试在 Google 云端硬盘帐户flutter 应用 中创建文件夹。它向我显示了一个错误的参数错误。尽管我正在使用文档示例

这是我尝试做的代码。它生成

"Bad argument(s)" error.

final _SCOPES = [drive.DriveApi.DriveScope];

void adrive(){

clientViaServiceAccount(_credentials,_SCOPES).then(onValue).catchError((e)=>print(e));
}


FutureOr onValue(AuthClient client) {
//drive.DriveApi(client).files.list().then((value)=>print(value.items[0]));
// The previous line works fine
drive.File r = new drive.File();
r.mimeType = "application/vnd.google-apps.folder";
r.title = "hello";

drive.DriveApi(client).files.insert(r,uploadOptions: commons.UploadOptions.Resumable).then((f)=>print(f.mimeType+" "+f.originalFilename))
.catchError((ex)=>print(ex.toString()));




最佳答案

由于您已经完成了身份验证凭据,因此您可以使用此凭据在 Google 云端硬盘中创建文件夹的简单功能。

clientViaServiceAccount(credentials, scopes).then((http_client) async {
var _drive = v3.DriveApi(http_client);
var _createFolder = await _drive.files.create(
v3.File()
..name = 'FileName'
..parents = ['1f4tjhpBJwF5t6FpYvufTljk8Gapbwajc'] // Optional if you want to create subfolder
..mimeType = 'application/vnd.google-apps.folder', // this defines its folder
);
});

关于flutter - 如何在 flutter 应用程序中使用 google Drive api 创建文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57175693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com