R2SignedUrl class
A presigned S3/R2 URL that grants temporary, credential-free access to a specific R2 object.
Generated by R2API.presignedUrl; share url with a client so it can read or write an object without needing its own R2 credentials.
Example – client-side upload flow:
// Backend: generate a presigned PUT URL valid for 15 minutes.
final signed = await r2.presignedUrl(
'my-bucket', 'uploads/document.pdf',
method: AWSHttpMethod.put,
expiresIn: Duration(minutes: 15),
);
// Client: upload without credentials.
await http.put(
Uri.parse(signed.url),
headers: {'content-type': 'application/pdf'},
body: pdfBytes,
);
- Available extensions
- Annotations
-
- @CopyWith.new()
- @JsonSerializable.new()
Constructors
- R2SignedUrl({required String url, required String bucket, required String key, required String type, required DateTime expiresAt})
-
const
-
R2SignedUrl.fromJson(Map<
String, dynamic> json) -
factory
Properties
- bucket → String
-
The R2 bucket the object lives in.
final
- expiresAt → DateTime
-
The UTC instant at which the presigned URL expires.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isExpired → bool
-
Whether the URL is still valid at the current instant.
no setter
- key → String
-
The object key within bucket (analogous to a file path).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → String
-
The HTTP method this URL permits — uppercase, e.g.
"GET"or"PUT".final - url → String
-
The full presigned URL string.
final
Methods
-
copyWith(
{String? url, String? bucket, String? key, String? type, DateTime? expiresAt}) → R2SignedUrl -
Available on R2SignedUrl, provided by the $R2SignedUrlCopyWithExtension extension
-
fromJsonList(
List? jsonList) → List< R2SignedUrl> ? -
inherited
-
fromJsonMap(
Map< String, dynamic> ? json) → R2SignedUrl? -
fromJsonString(
String? json) → R2SignedUrl? -
inherited
-
fromJsonStringList(
String? jsonStringList) → List< R2SignedUrl> ? -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
toJsonMap(
) → Map< String, dynamic> -
inherited
-
toJsonString(
) → String -
inherited
-
toString(
) → String -
This is just to suggest children to implement a named constructor to
support creating objects fromJson(...) and fromJsonString(...) as easy as
T.build().fromJson(...) or T.build().fromJsonString(...)
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited