internal UploadHelper( StorageClient client, Object destination, Stream source, UploadObjectOptions options, IProgress <IUploadProgress> progress) { _client = client; _mediaUpload = client.CreateObjectUploader(destination, source, options); if (progress != null) { _mediaUpload.ProgressChanged += progress.Report; } var validationMode = options?.UploadValidationMode ?? UploadObjectOptions.DefaultValidationMode; GaxPreconditions.CheckEnumValue(validationMode, nameof(UploadObjectOptions.UploadValidationMode)); switch (validationMode) { case UploadValidationMode.DeleteAndThrow: _crc = new Crc32c(); _mediaUpload.UploadStreamInterceptor += _crc.UpdateHash; _validationFailureAction = obj => client.DeleteObject(obj, new DeleteObjectOptions { Generation = obj.Generation }); _validationFailureAsyncAction = (obj, token) => client.DeleteObjectAsync(obj, new DeleteObjectOptions { Generation = obj.Generation }, token); break; case UploadValidationMode.ThrowOnly: _crc = new Crc32c(); _mediaUpload.UploadStreamInterceptor += _crc.UpdateHash; break; } }
public StorageClient(long totemId) { TotemId = totemId; BucketName = string.Format("{0}-{1:D6}", Constants.PROJECT_ID, TotemId); _client = Google.Cloud.Storage.V1.StorageClient.Create(CREDENTIALS); }