@@ -6,7 +6,7 @@ Basic S3 access library for Vapor written in Swift
6
6
7
7
1 ) Add following package to your ``` Package.swift ``` :
8
8
``` Swift
9
- .Package (url : " https://github.com/manGoweb/S3.git" , majorVersion : 1 , minor : 0 )
9
+ .Package (url : " https://github.com/manGoweb/S3.git" , majorVersion : 1 )
10
10
```
11
11
12
12
2 ) Run ``` vapor clean ```
@@ -21,31 +21,39 @@ Import the module ```import S3```
21
21
22
22
``` Swift
23
23
let s3: S3 = try S3 (droplet : drop)
24
- let fileData: Data = try s3.get (fileAtPath : " images/image.png" , bucketName : " booststore " )
24
+ let fileData: Data = try s3.get (fileAtPath : " images/image.png" )
25
25
```
26
26
27
27
#### Upload data to S3
28
28
29
29
``` Swift
30
30
let s3: S3 = try S3 (droplet : drop)
31
31
let url = URL.init (fileURLWithPath : " /Users/pro/Dropbox/books/agile-android-software-development.pdf" )
32
- try s3.put (fileAtUrl : url, filePath : " books/agile-android-software-development.pdf" , bucketName : " booststore " , accessControl : .publicRead )
32
+ try s3.put (fileAtUrl : url, filePath : " books/agile-android-software-development.pdf" , accessControl : .publicRead )
33
33
```
34
34
35
35
#### Delete data from S3
36
36
37
37
``` Swift
38
38
let s3: S3 = try S3 (droplet : drop)
39
- try s3.delete (fileAtPath : " images/image.png" , bucketName : " booststore " )
39
+ try s3.delete (fileAtPath : " images/image.png" )
40
40
```
41
41
42
42
### Config
43
43
44
44
Looks like this ``` Config/s3.json ``` :
45
45
```
46
46
{
47
- "accessKey": "{your-AWS-accees-key}",
48
- "secretKey": "{your-AWS-secret-key}"
47
+ "accessKey": "{your-AWS-accees-key}",
48
+ "secretKey": "{your-AWS-secret-key}",
49
+ "bucket": "{bucket-name}"
50
+ }
51
+ ```
52
+ The bucket name is an optional value so you can skip it if you want:
53
+ ```
54
+ {
55
+ "accessKey": "{your-AWS-accees-key}",
56
+ "secretKey": "{your-AWS-secret-key}"
49
57
}
50
58
```
51
59
0 commit comments