adopt static method

Future<void> adopt(
  1. String sourcePath,
  2. String key, {
  3. required int size,
  4. UStorageBucket bucket = UStorageBucket.support,
  5. Duration? expireIn,
  6. String? mimeType,
  7. String? sha256,
  8. Map<String, String>? tags,
})

Takes ownership of a file that is already in bucket's format — plain bytes, or a vault file for the vault bucket — and files it under key. The download manager finishes downloads this way so they are never copied twice.

Implementation

static Future<void> adopt(
  String sourcePath,
  String key, {
  required int size,
  UStorageBucket bucket = UStorageBucket.support,
  Duration? expireIn,
  String? mimeType,
  String? sha256,
  Map<String, String>? tags,
}) async {
  await _ensure();
  await _backend.move(sourcePath, _pathFor(bucket, key));
  await _record(key, bucket, size, expireIn: expireIn, mimeType: mimeType, sha256: sha256, tags: tags);
}