1 | <?php |
||
14 | class Options |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Default options, these can be overwritten within the constructor. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $options = [ |
||
23 | |||
24 | // If the upload is a success, this is the http code we get back from S3. |
||
25 | // By default this will be a 201 Created. |
||
26 | 'success_status' => 201, |
||
27 | |||
28 | // If the file should be private/public-read/public-write. |
||
29 | // This is file specific, not bucket. More info: http://amzn.to/1SSOgwO |
||
30 | 'acl' => 'private', |
||
31 | |||
32 | // The file's name on s3, can be set with JS by changing the input[name="key"]. |
||
33 | // ${filename} will just mean the original filename of the file being uploaded. |
||
34 | 'default_filename' => '${filename}', |
||
35 | |||
36 | // The maximum file size of an upload in MB. Will refuse with a EntityTooLarge |
||
37 | // and 400 Bad Request if you exceed this limit. |
||
38 | 'max_file_size' => 500, |
||
39 | |||
40 | // Request expiration time, specified in relative time format or in seconds. |
||
41 | // minimum of 1 (+1 second), maximum of 604800 (+7 days) |
||
42 | 'expires' => '+6 hours', |
||
43 | |||
44 | // Server will check that the filename starts with this prefix and fail |
||
45 | // with a AccessDenied 403 if not. |
||
46 | 'valid_prefix' => '', |
||
47 | |||
48 | // Strictly only allow a single content type, blank will allow all. Will fail |
||
49 | // with a AccessDenied 403 is this condition is not met. |
||
50 | 'content_type' => '', |
||
51 | |||
52 | // Sets whether AWS server side encryption should be applied to the uploaded files, |
||
53 | // so that files will be encrypted with AES256 when at rest. |
||
54 | 'encryption' => false, |
||
55 | |||
56 | // Allow S3 compatible solutions by specifying the domain it should POST to. Must be |
||
57 | // a valid url (inc. http/https) otherwise will throw InvalidOptionException. |
||
58 | 'custom_url' => null, |
||
59 | |||
60 | // Set Amazon S3 Transfer Acceleration |
||
61 | 'accelerate' => false, |
||
62 | |||
63 | // Any additional inputs to add to the form. This is an array of name => value |
||
64 | // pairs e.g. ['Content-Disposition' => 'attachment'] |
||
65 | 'additional_inputs' => [] |
||
66 | |||
67 | ]; |
||
68 | |||
69 | public function __construct($options = []) |
||
73 | |||
74 | /** |
||
75 | * Get all options. |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | public function getOptions(): array |
||
83 | |||
84 | public function get($name) |
||
91 | |||
92 | /** |
||
93 | * Set/overwrite any default options. |
||
94 | * |
||
95 | * @param array $options any options to override. |
||
96 | */ |
||
97 | public function setOptions(array $options): void |
||
113 | |||
114 | public function set(string $name, $value): void |
||
121 | |||
122 | } |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.