exportFile static method
Future<bool>
exportFile(
- String key,
- String destinationPath, {
- UStorageBucket bucket = UStorageBucket.support,
Writes a plaintext copy of key to destinationPath (decrypting vault entries).
Implementation
static Future<bool> exportFile(String key, String destinationPath, {UStorageBucket bucket = UStorageBucket.support}) async {
if (!_backend.hasFileSystem) throw UnsupportedError("exportFile needs a file system.");
await _ensure();
if (_live(key, bucket) == null) return false;
if (bucket == UStorageBucket.vault) {
final UStorageSink sink = await _backend.open(destinationPath, truncate: true);
int position = 0;
try {
await for (final Uint8List chunk in read(key, bucket: bucket)) {
await sink.writeAt(position, chunk);
position += chunk.length;
}
} finally {
await sink.close();
}
} else {
await _backend.copy(_pathFor(bucket, key), destinationPath);
}
return true;
}