upload method
Create remote file name
with content
name
is filenamecontent
is Stringparents
default 'appDataFolder'modifiedTime
create remote file with supplied time if not null
Implementation
Future upload({
required String name,
required String content,
DateTime? modifiedTime,
List<String> parents = lazy.defaultGDriveParents,
}) async {
String debugPrefix = '$runtimeType.upload()';
lazy.log(debugPrefix);
try {
var file = lazy.gDriveFileMeta(
name: name,
modifiedTime: modifiedTime,
parents: parents,
);
// [toMedia] use utf8 encoding
var media = content.toMedia();
lazy.log('$debugPrefix:size:${media.length}byte');
// Upload/Create remote file
var result = await create(file: file, uploadMedia: media);
lazy.log('$debugPrefix:result(should be empty):\n${result.jsonPretty()}');
} catch (e) {
lazy.log('$debugPrefix:catch:$e');
}
}