PageRenderTime 27ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/p/ilab-media-tools/vendor/ilab/ilab-aws-media-cloud-sdk/src/S3/S3ClientInterface.php

https://bitbucket.org/matthewselby/wpdev
PHP | 322 lines | 83 code | 18 blank | 221 comment | 0 complexity | c0eb440269bc28c00b8f68b1ff10867d MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, LGPL-3.0, LGPL-2.1, AGPL-1.0, BSD-3-Clause, MIT, GPL-3.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. namespace ILAB_Aws\S3;
  3. use ILAB_Aws\AwsClientInterface;
  4. use ILAB_Aws\CommandInterface;
  5. use ILAB_Aws\ResultInterface;
  6. use GuzzleHttp\Promise\PromiseInterface;
  7. use Psr\Http\Message\RequestInterface;
  8. interface S3ClientInterface extends AwsClientInterface
  9. {
  10. /**
  11. * Create a pre-signed URL for the given S3 command object.
  12. *
  13. * @param CommandInterface $command Command to create a pre-signed
  14. * URL for.
  15. * @param int|string|\DateTime $expires The time at which the URL should
  16. * expire. This can be a Unix
  17. * timestamp, a PHP DateTime object,
  18. * or a string that can be evaluated
  19. * by strtotime().
  20. *
  21. * @return RequestInterface
  22. */
  23. public function createPresignedRequest(CommandInterface $command, $expires);
  24. /**
  25. * Returns the URL to an object identified by its bucket and key.
  26. *
  27. * The URL returned by this method is not signed nor does it ensure the the
  28. * bucket and key given to the method exist. If you need a signed URL, then
  29. * use the {@see \ILAB_Aws\S3\S3Client::createPresignedRequest} method and get
  30. * the URI of the signed request.
  31. *
  32. * @param string $bucket The name of the bucket where the object is located
  33. * @param string $key The key of the object
  34. *
  35. * @return string The URL to the object
  36. */
  37. public function getObjectUrl($bucket, $key);
  38. /**
  39. * Determines whether or not a bucket exists by name.
  40. *
  41. * @param string $bucket The name of the bucket
  42. *
  43. * @return bool
  44. */
  45. public function doesBucketExist($bucket);
  46. /**
  47. * Determines whether or not an object exists by name.
  48. *
  49. * @param string $bucket The name of the bucket
  50. * @param string $key The key of the object
  51. * @param array $options Additional options available in the HeadObject
  52. * operation (e.g., VersionId).
  53. *
  54. * @return bool
  55. */
  56. public function doesObjectExist($bucket, $key, array $options = []);
  57. /**
  58. * Register the Amazon S3 stream wrapper with this client instance.
  59. */
  60. public function registerStreamWrapper();
  61. /**
  62. * Deletes objects from Amazon S3 that match the result of a ListObjects
  63. * operation. For example, this allows you to do things like delete all
  64. * objects that match a specific key prefix.
  65. *
  66. * @param string $bucket Bucket that contains the object keys
  67. * @param string $prefix Optionally delete only objects under this key prefix
  68. * @param string $regex Delete only objects that match this regex
  69. * @param array $options Aws\S3\BatchDelete options array.
  70. *
  71. * @see Aws\S3\S3Client::listObjects
  72. * @throws \RuntimeException if no prefix and no regex is given
  73. */
  74. public function deleteMatchingObjects(
  75. $bucket,
  76. $prefix = '',
  77. $regex = '',
  78. array $options = []
  79. );
  80. /**
  81. * Deletes objects from Amazon S3 that match the result of a ListObjects
  82. * operation. For example, this allows you to do things like delete all
  83. * objects that match a specific key prefix.
  84. *
  85. * @param string $bucket Bucket that contains the object keys
  86. * @param string $prefix Optionally delete only objects under this key prefix
  87. * @param string $regex Delete only objects that match this regex
  88. * @param array $options Aws\S3\BatchDelete options array.
  89. *
  90. * @see Aws\S3\S3Client::listObjects
  91. *
  92. * @return PromiseInterface A promise that is settled when matching
  93. * objects are deleted.
  94. */
  95. public function deleteMatchingObjectsAsync(
  96. $bucket,
  97. $prefix = '',
  98. $regex = '',
  99. array $options = []
  100. );
  101. /**
  102. * Upload a file, stream, or string to a bucket.
  103. *
  104. * If the upload size exceeds the specified threshold, the upload will be
  105. * performed using concurrent multipart uploads.
  106. *
  107. * The options array accepts the following options:
  108. *
  109. * - before_upload: (callable) Callback to invoke before any upload
  110. * operations during the upload process. The callback should have a
  111. * function signature like `function (Aws\Command $command) {...}`.
  112. * - concurrency: (int, default=int(3)) Maximum number of concurrent
  113. * `UploadPart` operations allowed during a multipart upload.
  114. * - mup_threshold: (int, default=int(16777216)) The size, in bytes, allowed
  115. * before the upload must be sent via a multipart upload. Default: 16 MB.
  116. * - params: (array, default=array([])) Custom parameters to use with the
  117. * upload. For single uploads, they must correspond to those used for the
  118. * `PutObject` operation. For multipart uploads, they correspond to the
  119. * parameters of the `CreateMultipartUpload` operation.
  120. * - part_size: (int) Part size to use when doing a multipart upload.
  121. *
  122. * @param string $bucket Bucket to upload the object.
  123. * @param string $key Key of the object.
  124. * @param mixed $body Object data to upload. Can be a
  125. * StreamInterface, PHP stream resource, or a
  126. * string of data to upload.
  127. * @param string $acl ACL to apply to the object (default: private).
  128. * @param array $options Options used to configure the upload process.
  129. *
  130. * @see Aws\S3\MultipartUploader for more info about multipart uploads.
  131. * @return ResultInterface Returns the result of the upload.
  132. */
  133. public function upload(
  134. $bucket,
  135. $key,
  136. $body,
  137. $acl = 'private',
  138. array $options = []
  139. );
  140. /**
  141. * Upload a file, stream, or string to a bucket asynchronously.
  142. *
  143. * @param string $bucket Bucket to upload the object.
  144. * @param string $key Key of the object.
  145. * @param mixed $body Object data to upload. Can be a
  146. * StreamInterface, PHP stream resource, or a
  147. * string of data to upload.
  148. * @param string $acl ACL to apply to the object (default: private).
  149. * @param array $options Options used to configure the upload process.
  150. *
  151. * @see self::upload
  152. * @return PromiseInterface Returns a promise that will be fulfilled
  153. * with the result of the upload.
  154. */
  155. public function uploadAsync(
  156. $bucket,
  157. $key,
  158. $body,
  159. $acl = 'private',
  160. array $options = []
  161. );
  162. /**
  163. * Copy an object of any size to a different location.
  164. *
  165. * If the upload size exceeds the maximum allowable size for direct S3
  166. * copying, a multipart copy will be used.
  167. *
  168. * The options array accepts the following options:
  169. *
  170. * - before_upload: (callable) Callback to invoke before any upload
  171. * operations during the upload process. The callback should have a
  172. * function signature like `function (Aws\Command $command) {...}`.
  173. * - concurrency: (int, default=int(5)) Maximum number of concurrent
  174. * `UploadPart` operations allowed during a multipart upload.
  175. * - params: (array, default=array([])) Custom parameters to use with the
  176. * upload. For single uploads, they must correspond to those used for the
  177. * `CopyObject` operation. For multipart uploads, they correspond to the
  178. * parameters of the `CreateMultipartUpload` operation.
  179. * - part_size: (int) Part size to use when doing a multipart upload.
  180. *
  181. * @param string $fromBucket Bucket where the copy source resides.
  182. * @param string $fromKey Key of the copy source.
  183. * @param string $destBucket Bucket to which to copy the object.
  184. * @param string $destKey Key to which to copy the object.
  185. * @param string $acl ACL to apply to the copy (default: private).
  186. * @param array $options Options used to configure the upload process.
  187. *
  188. * @see Aws\S3\MultipartCopy for more info about multipart uploads.
  189. * @return ResultInterface Returns the result of the copy.
  190. */
  191. public function copy(
  192. $fromBucket,
  193. $fromKey,
  194. $destBucket,
  195. $destKey,
  196. $acl = 'private',
  197. array $options = []
  198. );
  199. /**
  200. * Copy an object of any size to a different location asynchronously.
  201. *
  202. * @param string $fromBucket Bucket where the copy source resides.
  203. * @param string $fromKey Key of the copy source.
  204. * @param string $destBucket Bucket to which to copy the object.
  205. * @param string $destKey Key to which to copy the object.
  206. * @param string $acl ACL to apply to the copy (default: private).
  207. * @param array $options Options used to configure the upload process.
  208. *
  209. * @see self::copy for more info about the parameters above.
  210. * @return PromiseInterface Returns a promise that will be fulfilled
  211. * with the result of the copy.
  212. */
  213. public function copyAsync(
  214. $fromBucket,
  215. $fromKey,
  216. $destBucket,
  217. $destKey,
  218. $acl = 'private',
  219. array $options = []
  220. );
  221. /**
  222. * Recursively uploads all files in a given directory to a given bucket.
  223. *
  224. * @param string $directory Full path to a directory to upload
  225. * @param string $bucket Name of the bucket
  226. * @param string $keyPrefix Virtual directory key prefix to add to each upload
  227. * @param array $options Options available in Aws\S3\Transfer::__construct
  228. *
  229. * @see Aws\S3\Transfer for more options and customization
  230. */
  231. public function uploadDirectory(
  232. $directory,
  233. $bucket,
  234. $keyPrefix = null,
  235. array $options = []
  236. );
  237. /**
  238. * Recursively uploads all files in a given directory to a given bucket.
  239. *
  240. * @param string $directory Full path to a directory to upload
  241. * @param string $bucket Name of the bucket
  242. * @param string $keyPrefix Virtual directory key prefix to add to each upload
  243. * @param array $options Options available in Aws\S3\Transfer::__construct
  244. *
  245. * @see Aws\S3\Transfer for more options and customization
  246. *
  247. * @return PromiseInterface A promise that is settled when the upload is
  248. * complete.
  249. */
  250. public function uploadDirectoryAsync(
  251. $directory,
  252. $bucket,
  253. $keyPrefix = null,
  254. array $options = []
  255. );
  256. /**
  257. * Downloads a bucket to the local filesystem
  258. *
  259. * @param string $directory Directory to download to
  260. * @param string $bucket Bucket to download from
  261. * @param string $keyPrefix Only download objects that use this key prefix
  262. * @param array $options Options available in Aws\S3\Transfer::__construct
  263. */
  264. public function downloadBucket(
  265. $directory,
  266. $bucket,
  267. $keyPrefix = '',
  268. array $options = []
  269. );
  270. /**
  271. * Downloads a bucket to the local filesystem
  272. *
  273. * @param string $directory Directory to download to
  274. * @param string $bucket Bucket to download from
  275. * @param string $keyPrefix Only download objects that use this key prefix
  276. * @param array $options Options available in Aws\S3\Transfer::__construct
  277. *
  278. * @return PromiseInterface A promise that is settled when the download is
  279. * complete.
  280. */
  281. public function downloadBucketAsync(
  282. $directory,
  283. $bucket,
  284. $keyPrefix = '',
  285. array $options = []
  286. );
  287. /**
  288. * Returns the region in which a given bucket is located.
  289. *
  290. * @param string $bucketName
  291. *
  292. * @return string
  293. */
  294. public function determineBucketRegion($bucketName);
  295. /**
  296. * Returns a promise fulfilled with the region in which a given bucket is
  297. * located.
  298. *
  299. * @param string $bucketName
  300. *
  301. * @return PromiseInterface
  302. */
  303. public function determineBucketRegionAsync($bucketName);
  304. }