execute method
Future<bool>
execute(
- ReleasePacker releasePacker,
- Directory rootDirectory, {
- ReleaseBundle? releaseBundle,
override
Implementation
@override
Future<bool> execute(ReleasePacker releasePacker, Directory rootDirectory,
{ReleaseBundle? releaseBundle}) async {
var params = await resolveUploadParameters(releaseBundle: releaseBundle);
if (params == null) return false;
gcs.ObjectMetadata? metadata;
if (params.release != null) {
metadata = gcs.ObjectMetadata(
contentType: params.contentType,
custom: {
'release': params.release!,
},
);
}
print(' » Parsing Google Cloud Storage credential...');
var client = await createGCSClient(credential);
print(
' » Uploading to Google Cloud Storage> project: $project ; bucket: ${this.bucket} ; file: ${params.filePath}');
var storage = gcs.Storage(client, project);
var bucket = storage.bucket(this.bucket);
var objInfo = await bucket.writeBytes(
params.filePath,
params.bodyBytes,
contentType: params.contentType,
metadata: metadata,
);
var ok = objInfo.length == params.bodyBytes.length;
print(' » GCS response> ${ok ? 'Ok' : 'Faul'}');
return ok;
}