@@ -1042,13 +1042,18 @@ public virtual Response<BlobContentInfo> Upload(
10421042 public virtual Response < BlobContentInfo > Upload (
10431043 BinaryData content ,
10441044 BlobUploadOptions options ,
1045- CancellationToken cancellationToken = default ) =>
1046- StagedUploadInternal (
1047- content . ToStream ( ) ,
1048- options ,
1049- async: false ,
1050- cancellationToken : cancellationToken )
1051- . EnsureCompleted ( ) ;
1045+ CancellationToken cancellationToken = default )
1046+ {
1047+ using ( var stream = content . ToStream ( ) )
1048+ {
1049+ return StagedUploadInternal (
1050+ stream ,
1051+ options ,
1052+ async: false ,
1053+ cancellationToken : cancellationToken )
1054+ . EnsureCompleted ( ) ;
1055+ }
1056+ }
10521057
10531058 /// <summary>
10541059 /// The <see cref="Upload(Stream, BlobHttpHeaders, Metadata, BlobRequestConditions, IProgress{long}, AccessTier?, StorageTransferOptions, CancellationToken)"/>
@@ -1360,13 +1365,18 @@ await StagedUploadInternal(
13601365 public virtual async Task < Response < BlobContentInfo > > UploadAsync (
13611366 BinaryData content ,
13621367 BlobUploadOptions options ,
1363- CancellationToken cancellationToken = default ) =>
1364- await StagedUploadInternal (
1365- content . ToStream ( ) ,
1366- options ,
1367- async: true ,
1368- cancellationToken : cancellationToken )
1369- . ConfigureAwait ( false ) ;
1368+ CancellationToken cancellationToken = default )
1369+ {
1370+ using ( var stream = content . ToStream ( ) )
1371+ {
1372+ return await StagedUploadInternal (
1373+ stream ,
1374+ options ,
1375+ async: true ,
1376+ cancellationToken : cancellationToken )
1377+ . ConfigureAwait ( false ) ;
1378+ }
1379+ }
13701380
13711381 /// <summary>
13721382 /// The <see cref="UploadAsync(Stream, BlobHttpHeaders, Metadata, BlobRequestConditions, IProgress{long}, AccessTier?, StorageTransferOptions, CancellationToken)"/>
0 commit comments