flutter_aws_s3_client
간단하고 공식이 아닌 Dart용 AWS S3 클라이언트입니다. 버킷 내 개체 다운로드 및 목록 조회를 지원합니다.
간단하고 공식이 아닌 AWS S3 클라이언트
^1.0.0-nullsafety.3^8.0.0^5.0.0^5.0.0^0.13.0^8.0.0^1.10.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Since there is now an official package for accessing AWS services, I decided to not longer support this package. please migrate to https://github.com/aws-amplify/amplify-flutter / https://pub.dev/packages/amplify_storage_s3/example
Supports downloading objects and listing objects in a bucket.
The heavy lifting was done by Amazon Cognito Identity SDK for Dart, this project contains just convenience methods for common use cases.
if you need more requests, you can use this instead to build what you need. If you implement more methods, feel free to open a pull request.
const region = "eu-central-1";
const bucketId = "yourBucketId";
final AwsS3Client s3client = AwsS3Client(
region: region,
host: "s3.$region.amazonaws.com",
bucketId: bucketId,
accessKey: "<your access key>",
secretKey: "<your secret key>");
final response = await s3client.getObject("your/object/key");
ListBucketResult listBucketResult =
await s3client.listObjects(prefix: "dir1/dir2/", delimiter: "/");
print(listBucketResult.toString());
If you want to use a custom http client, use the method buildSignedGetParams.
This method returns an object containing the URL and the Authorization headers, which can be
used to build the request with your preferred http client.
Use the buildSignedGetParams method.
Example code (with ETag support):
Future download(String key, File file, [String etag = null]) async {
final signedParams = awsS3Client.buildSignedGetParams(key: key);
final request = await HttpClient().getUrl(signedParams.uri);
for (final header in (signedParams.headers ?? const {}).entries) {
request.headers.add(header.key, header.value);
}
if(eTag != null){
request.headers.add(HttpHeaders.ifNoneMatchHeader, eTag);
}
final response = response = await request.close();
if(response.statusCode != HttpStatus.ok){
//handle error
}else{
return response.pipe(file.openWrite());
}
}