我已经尝试在flutter app
中的google drive account
中创建文件夹。它显示了一个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()));
您已经完成Auth credentials
,可以使用此简单的功能即可在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
);
});