Skip to content

web + storage + reference_web.dart putString needs testing and fixes #13464

@kevmoo

Description

@kevmoo

/// Upload a [String] value as a storage object.
///
/// Use [PutStringFormat] to correctly encode the string:
/// - [PutStringFormat.raw] the string will be encoded in a Base64 format.
/// - [PutStringFormat.dataUrl] the string must be in a data url format
/// (e.g. "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=="). If no
/// [SettableMetadata.mimeType] is provided as part of the [metadata]
/// argument, the [mimeType] will be automatically set.
/// - [PutStringFormat.base64] will be encoded as a Base64 string.
/// - [PutStringFormat.base64Url] will be encoded as a Base64 string safe URL.
@override
TaskPlatform putString(
String data,
PutStringFormat format, [
SettableMetadata? metadata,
]) {
dynamic _data = data;
// The universal package is converting raw to base64, so we need to convert
// Any base64 string values into a Uint8List.
if (format == PutStringFormat.base64) {
_data = base64Decode(data);
}
return TaskWeb(
this,
_ref.put(
_data,
settableMetadataToFbUploadMetadata(
_cache.store(metadata),
// md5 is computed server-side, so we don't have to unpack a potentially huge Blob.
),
),
);
}

  • The casting to dynamic is scary
  • In only one case is the value converted to Uint8List – but all calls to put should be a binary type

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions