Skip to content

Commit 7a529c5

Browse files
authored
Merge pull request #58 from rameel/gcs-empty-stream-upload
Fix: allow creating empty object in GCS
2 parents e5f6716 + 0d778dd commit 7a529c5

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/Ramstack.FileSystem.Google/GcsWriteStream.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,8 @@ protected override void Dispose(bool disposing)
138138
{
139139
_stream.Position = 0;
140140

141-
if (_stream.Length != 0)
142-
{
143-
var destination = new global::Google.Apis.Storage.v1.Data.Object { Bucket = _fs.BucketName, Name = _objectName };
144-
_fs.StorageClient.UploadObject(destination, _stream);
145-
}
141+
var destination = new global::Google.Apis.Storage.v1.Data.Object { Bucket = _fs.BucketName, Name = _objectName };
142+
_fs.StorageClient.UploadObject(destination, _stream);
146143
}
147144
finally
148145
{
@@ -163,14 +160,11 @@ public override async ValueTask DisposeAsync()
163160
{
164161
_stream.Position = 0;
165162

166-
if (_stream.Length != 0)
167-
{
168-
var destination = new global::Google.Apis.Storage.v1.Data.Object { Bucket = _fs.BucketName, Name = _objectName };
163+
var destination = new global::Google.Apis.Storage.v1.Data.Object { Bucket = _fs.BucketName, Name = _objectName };
169164

170-
await _fs.StorageClient
171-
.UploadObjectAsync(destination, _stream)
172-
.ConfigureAwait(false);
173-
}
165+
await _fs.StorageClient
166+
.UploadObjectAsync(destination, _stream)
167+
.ConfigureAwait(false);
174168
}
175169
finally
176170
{

0 commit comments

Comments
 (0)