@@ -166,11 +166,14 @@ public async Task UploadAsync_AsText_WithOptions_ToDirectory_SpecifyingFileName(
166166 [ InlineData ( 1 ) ]
167167 [ InlineData ( 3 ) ]
168168 [ InlineData ( 5 ) ]
169- public async Task UploadAsync_LargeStream_ShouldRoundTrip ( int gigabytes )
169+ public virtual async Task UploadAsync_LargeStream_ShouldRoundTrip ( int gigabytes )
170170 {
171171 var sizeBytes = LargeFileTestHelper . ResolveSizeBytes ( gigabytes ) ;
172172 var directory = "large-files" ;
173173
174+ var containerResult = await Storage . CreateContainerAsync ( CancellationToken . None ) ;
175+ containerResult . IsSuccess . ShouldBeTrue ( ) ;
176+
174177 await using var localFile = await LargeFileTestHelper . CreateRandomFileAsync ( sizeBytes , ".bin" ) ;
175178 var expectedCrc = LargeFileTestHelper . CalculateFileCrc ( localFile . FilePath ) ;
176179 var fileName = Path . GetFileName ( localFile . FilePath ) ;
@@ -182,21 +185,41 @@ public async Task UploadAsync_LargeStream_ShouldRoundTrip(int gigabytes)
182185 MimeType = MimeHelper . GetMimeType ( fileName )
183186 } ;
184187
185- string storedPath = uploadOptions . FullPath ;
188+ string directoryPath = uploadOptions . Directory ?? string . Empty ;
189+ string storedName = uploadOptions . FileName ;
186190
187191 await using ( var uploadStream = File . OpenRead ( localFile . FilePath ) )
188192 {
189193 var uploadResult = await Storage . UploadAsync ( uploadStream , uploadOptions , CancellationToken . None ) ;
190194 uploadResult . IsSuccess . ShouldBeTrue ( ) ;
191195 uploadResult . Value . ShouldNotBeNull ( ) ;
192196
193- storedPath = uploadResult . Value ! . FullName ??
194- ( ! string . IsNullOrWhiteSpace ( uploadResult . Value . Name )
195- ? new UploadOptions ( uploadResult . Value . Name ! , uploadOptions . Directory ) . FullPath
196- : uploadOptions . FullPath ) ;
197+ if ( ! string . IsNullOrWhiteSpace ( uploadResult . Value ! . FullName ) )
198+ {
199+ var full = uploadResult . Value . FullName ! ;
200+ var slashIndex = full . LastIndexOf ( '/' ) ;
201+ if ( slashIndex >= 0 )
202+ {
203+ directoryPath = full [ ..slashIndex ] ;
204+ storedName = full [ ( slashIndex + 1 ) ..] ;
205+ }
206+ else
207+ {
208+ directoryPath = string . Empty ;
209+ storedName = full ;
210+ }
211+ }
212+ else if ( ! string . IsNullOrWhiteSpace ( uploadResult . Value . Name ) )
213+ {
214+ storedName = uploadResult . Value . Name ! ;
215+ }
197216 }
198217
199- var downloadResult = await Storage . DownloadAsync ( storedPath , CancellationToken . None ) ;
218+ var downloadResult = await Storage . DownloadAsync ( new DownloadOptions
219+ {
220+ FileName = storedName ,
221+ Directory = string . IsNullOrWhiteSpace ( directoryPath ) ? null : directoryPath
222+ } , CancellationToken . None ) ;
200223
201224 downloadResult . IsSuccess . ShouldBeTrue ( ) ;
202225 downloadResult . Value . ShouldNotBeNull ( ) ;
@@ -205,7 +228,11 @@ public async Task UploadAsync_LargeStream_ShouldRoundTrip(int gigabytes)
205228 var actualCrc = LargeFileTestHelper . CalculateFileCrc ( downloaded . FilePath ) ;
206229 actualCrc . ShouldBe ( expectedCrc ) ;
207230
208- var deleteResult = await Storage . DeleteAsync ( storedPath , CancellationToken . None ) ;
231+ var deleteResult = await Storage . DeleteAsync ( new DeleteOptions
232+ {
233+ FileName = storedName ,
234+ Directory = string . IsNullOrWhiteSpace ( directoryPath ) ? null : directoryPath
235+ } , CancellationToken . None ) ;
209236
210237 deleteResult . IsSuccess . ShouldBeTrue ( ) ;
211238 }
0 commit comments