copyFile method
Implementation
@override
Future<FileModel?> copyFile(String sourceBucketId, String sourceFileId,
{String bucketId = ""}) async {
try {
await initialize();
var target = await getFileData("$sourceBucketId/$sourceFileId", bucketId: sourceBucketId);
if (target != null) {
var targetBytes =
await getFileBytes("$sourceBucketId/$sourceFileId", bucketId: sourceBucketId);
if (targetBytes == null) throw Exception("file not exist");
return await uploadFile(target.name, target.contentType.name, targetBytes,
bucketId: bucketId, usageType: getUsageType(target.id));
}
} catch (error) {
logger.severe("error during Storage.copyFile >> $error");
}
return null;
}