@@ -3,18 +3,15 @@ package fly.play.s3
3
3
import java .io .File
4
4
import java .lang .IllegalArgumentException
5
5
import java .util .Date
6
-
7
6
import scala .concurrent .Await
8
7
import scala .concurrent .Awaitable
9
8
import scala .concurrent .Future
10
9
import scala .concurrent .duration .Duration
11
10
import scala .util .Failure
12
11
import scala .util .Success
13
-
14
12
import org .specs2 .execute .AsResult
15
13
import org .specs2 .mutable .Specification
16
14
import org .specs2 .specification .Example
17
-
18
15
import fly .play .aws .auth .SimpleAwsCredentials
19
16
import fly .play .s3 .acl .CanonicalUser
20
17
import fly .play .s3 .acl .FULL_CONTROL
@@ -32,6 +29,7 @@ import play.api.libs.ws.WS
32
29
import play .api .test .FakeApplication
33
30
import play .api .test .Helpers .running
34
31
import utils .MultipartFormData
32
+ import java .net .URLEncoder
35
33
36
34
class S3Spec extends Specification {
37
35
@@ -403,6 +401,28 @@ class S3Spec extends Specification {
403
401
404
402
noException(testBucket remove expectedFileName)
405
403
}
404
+
405
+ }
406
+
407
+ " be able to add and delete files with 'weird' names" inApp {
408
+
409
+ def uploadListAndRemoveFileWithName (prefix: String , name : String ) = {
410
+ await(testBucket + BucketFile (URLEncoder .encode(prefix + name, " UTF-8" ), " text/plain" , " test" .getBytes))
411
+
412
+ await(testBucket.list(prefix)) must beLike {
413
+ case Seq (BucketItem (itemName, false )) => itemName === (prefix + name)
414
+ }
415
+
416
+ await(testBucket - URLEncoder .encode(prefix + name, " UTF-8" ))
417
+
418
+ success
419
+ }
420
+
421
+ uploadListAndRemoveFileWithName(" sample/" , " test file.txt" )
422
+ uploadListAndRemoveFileWithName(" sample/" , " test&;-file.txt" )
423
+ uploadListAndRemoveFileWithName(" sample/" , " test & file.txt" )
424
+ uploadListAndRemoveFileWithName(" sample/" , " test+&+file.txt" )
406
425
}
407
426
}
427
+
408
428
}
0 commit comments