put method

Future<String> put(
  1. String folder,
  2. List<int> bytes, {
  3. String? extension,
})

store bytes with a new uuid file name and return its path. the extension is guessed from the bytes when not given.

String path = await Storage().put('images', bytes, extension: 'png');

Implementation

Future<String> put(
  String folder,
  List<int> bytes, {
  String? extension,
}) async {
  extension ??= lookupMimeType('', headerBytes: bytes)?.split('/').last;
  String key = _newKey(folder, extension);
  await use().put(key, bytes);
  return '/$key';
}