InfiniteWP Client - Version 1.5.0

Version Description

  • Improvement: Compatibility with PHP7.
  • Improvement: Memory usage in Multi call backup now optimized.
  • Improvement: Support for new Amazon S3 SDK. Added support for Frankfut bucket which will solve random errors in amazon backup. For php < v5.3.3 will use older S3 library.
  • Improvement: Timeout will be reduced in Single call backup Zip Archive.
  • Improvement: Client plugin will support MySQLi by using wpdb class.
  • Improvement: All tables created by client plugin will use default DB engine.
  • Improvement: Maintenance mode status also included in reload data. This will result in the IWP Admin Panel displaying relevant status colours.
  • Improvement: Support for WP Maintenance Addon's new options - Clear trash comments, Clear trash posts, Unused posts metadata, Unused comments metadata, Remove pingbacks, Remove trackbacks.
  • Improvement: Dedicated cacert.pem file introduced for Dropbox API." client plugin.
  • Fix: Issue with IWP DB Table version not updating.
  • Fix: Backup DB table now uses WP's charset (default UTF8). This will solve filename issues with foreign (umlaut) characters.
  • Fix: Temp files not getting deleted while using single call backup in certain cases.
Download this release

Release Info

Developer infinitewp
Plugin Icon 128x128 InfiniteWP Client
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.3 to 1.5.0

Files changed (270) hide show
  1. addons/comments/comments.class.php +1 -1
  2. addons/google_webmasters/google_webmasters.class.php +1 -1
  3. addons/post_links/link.class.php +6 -4
  4. addons/post_links/post.class.php +30 -17
  5. addons/wp_optimize/optimize.class.php +84 -9
  6. backup.class.multicall.php +702 -322
  7. backup.class.singlecall.php +148 -82
  8. init.php +108 -46
  9. lib/amazon/autoload.php +7 -0
  10. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Aws.php +105 -0
  11. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php +283 -0
  12. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/AwsClientInterface.php +118 -0
  13. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/ClientBuilder.php +526 -0
  14. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/DefaultClient.php +67 -0
  15. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/ExpiredCredentialsChecker.php +80 -0
  16. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/ThrottlingErrorChecker.php +75 -0
  17. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/UploadBodyListener.php +95 -0
  18. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/UserAgentListener.php +61 -0
  19. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/AwsQueryVisitor.php +117 -0
  20. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/JsonCommand.php +47 -0
  21. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/QueryCommand.php +53 -0
  22. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/XmlResponseLocationVisitor.php +74 -0
  23. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/AbstractCredentialsDecorator.php +136 -0
  24. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/AbstractRefreshableCredentials.php +76 -0
  25. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/CacheableCredentials.php +73 -0
  26. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/Credentials.php +337 -0
  27. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/CredentialsInterface.php +96 -0
  28. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/NullCredentials.php +68 -0
  29. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/RefreshableInstanceProfileCredentials.php +59 -0
  30. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum.php +55 -0
  31. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/ClientOptions.php +162 -0
  32. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/DateFormat.php +31 -0
  33. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/Region.php +63 -0
  34. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/Size.php +53 -0
  35. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/Time.php +46 -0
  36. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/UaString.php +55 -0
  37. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/AwsExceptionInterface.php +30 -0
  38. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/BadMethodCallException.php +22 -0
  39. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/DomainException.php +22 -0
  40. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/ExceptionFactoryInterface.php +36 -0
  41. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/ExceptionListener.php +59 -0
  42. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/InstanceProfileCredentialsException.php +50 -0
  43. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/InvalidArgumentException.php +22 -0
  44. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/LogicException.php +22 -0
  45. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/MultipartUploadException.php +55 -0
  46. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php +103 -0
  47. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/OutOfBoundsException.php +22 -0
  48. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/OverflowException.php +22 -0
  49. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/AbstractJsonExceptionParser.php +66 -0
  50. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/DefaultXmlExceptionParser.php +100 -0
  51. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/ExceptionParserInterface.php +42 -0
  52. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/JsonQueryExceptionParser.php +41 -0
  53. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/JsonRestExceptionParser.php +48 -0
  54. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/RequiredExtensionNotLoadedException.php +22 -0
  55. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/RuntimeException.php +22 -0
  56. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/ServiceResponseException.php +183 -0
  57. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/TransferException.php +24 -0
  58. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/UnexpectedValueException.php +22 -0
  59. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Facade/Facade.php +67 -0
  60. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Facade/FacadeInterface.php +32 -0
  61. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Facade/facade-classes.php +283 -0
  62. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/ChunkHash.php +87 -0
  63. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/ChunkHashInterface.php +52 -0
  64. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/HashUtils.php +76 -0
  65. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/TreeHash.php +195 -0
  66. lib/amazon/aws/aws-sdk-php/src/Aws/Common/HostNameUtils.php +85 -0
  67. lib/amazon/aws/aws-sdk-php/src/Aws/Common/InstanceMetadata/InstanceMetadataClient.php +102 -0
  68. lib/amazon/aws/aws-sdk-php/src/Aws/Common/InstanceMetadata/Waiter/ServiceAvailable.php +50 -0
  69. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Iterator/AwsResourceIterator.php +169 -0
  70. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Iterator/AwsResourceIteratorFactory.php +106 -0
  71. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractTransfer.php +270 -0
  72. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractTransferState.php +164 -0
  73. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractUploadBuilder.php +148 -0
  74. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractUploadId.php +89 -0
  75. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractUploadPart.php +101 -0
  76. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/TransferInterface.php +66 -0
  77. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/TransferStateInterface.php +92 -0
  78. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/UploadIdInterface.php +39 -0
  79. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/UploadPartInterface.php +46 -0
  80. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Resources/aws-config.php +314 -0
  81. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Resources/public-endpoints.php +79 -0
  82. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Resources/sdk1-config.php +138 -0
  83. lib/amazon/aws/aws-sdk-php/src/Aws/Common/RulesEndpointProvider.php +67 -0
  84. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/AbstractSignature.php +44 -0
  85. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/EndpointSignatureInterface.php +42 -0
  86. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureInterface.php +52 -0
  87. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureListener.php +83 -0
  88. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureV2.php +109 -0
  89. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureV3Https.php +52 -0
  90. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureV4.php +470 -0
  91. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/AbstractResourceWaiter.php +53 -0
  92. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/AbstractWaiter.php +146 -0
  93. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/CallableWaiter.php +82 -0
  94. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/CompositeWaiterFactory.php +90 -0
  95. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/ConfigResourceWaiter.php +225 -0
  96. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/ResourceWaiterInterface.php +34 -0
  97. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterClassFactory.php +106 -0
  98. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterConfig.php +67 -0
  99. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterConfigFactory.php +98 -0
  100. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterFactoryInterface.php +41 -0
  101. lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterInterface.php +60 -0
  102. lib/amazon/aws/aws-sdk-php/src/Aws/S3/AcpListener.php +75 -0
  103. lib/amazon/aws/aws-sdk-php/src/Aws/S3/BucketStyleListener.php +89 -0
  104. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Command/S3Command.php +65 -0
  105. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/CannedAcl.php +32 -0
  106. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/EncodingType.php +27 -0
  107. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Event.php +27 -0
  108. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/GranteeType.php +29 -0
  109. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Group.php +29 -0
  110. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/MFADelete.php +28 -0
  111. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/MetadataDirective.php +28 -0
  112. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Payer.php +28 -0
  113. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Permission.php +31 -0
  114. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Protocol.php +28 -0
  115. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/ServerSideEncryption.php +27 -0
  116. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Status.php +28 -0
  117. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Storage.php +29 -0
  118. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/StorageClass.php +28 -0
  119. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/AccessDeniedException.php +22 -0
  120. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/AccountProblemException.php +22 -0
  121. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/AmbiguousGrantByEmailAddressException.php +22 -0
  122. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BadDigestException.php +22 -0
  123. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BucketAlreadyExistsException.php +22 -0
  124. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BucketAlreadyOwnedByYouException.php +22 -0
  125. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BucketNotEmptyException.php +22 -0
  126. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/CredentialsNotSupportedException.php +22 -0
  127. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/CrossLocationLoggingProhibitedException.php +22 -0
  128. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/DeleteMultipleObjectsException.php +48 -0
  129. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/EntityTooLargeException.php +22 -0
  130. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/EntityTooSmallException.php +22 -0
  131. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ExpiredTokenException.php +22 -0
  132. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/IllegalVersioningConfigurationException.php +22 -0
  133. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/IncompleteBodyException.php +22 -0
  134. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/IncorrectNumberOfFilesInPostRequestException.php +22 -0
  135. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InlineDataTooLargeException.php +22 -0
  136. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InternalErrorException.php +22 -0
  137. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidAccessKeyIdException.php +22 -0
  138. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidAddressingHeaderException.php +22 -0
  139. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidArgumentException.php +22 -0
  140. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidBucketNameException.php +22 -0
  141. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidBucketStateException.php +22 -0
  142. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidDigestException.php +22 -0
  143. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidLocationConstraintException.php +22 -0
  144. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPartException.php +22 -0
  145. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPartOrderException.php +22 -0
  146. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPayerException.php +22 -0
  147. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPolicyDocumentException.php +22 -0
  148. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidRangeException.php +22 -0
  149. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidRequestException.php +22 -0
  150. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidSOAPRequestException.php +22 -0
  151. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidSecurityException.php +22 -0
  152. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidStorageClassException.php +22 -0
  153. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidTagErrorException.php +23 -0
  154. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidTargetBucketForLoggingException.php +22 -0
  155. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidTokenException.php +22 -0
  156. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidURIException.php +22 -0
  157. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/KeyTooLongException.php +22 -0
  158. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MalformedACLErrorException.php +22 -0
  159. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MalformedPOSTRequestException.php +22 -0
  160. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MalformedXMLException.php +22 -0
  161. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MaxMessageLengthExceededException.php +22 -0
  162. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MaxPostPreDataLengthExceededErrorException.php +22 -0
  163. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MetadataTooLargeException.php +22 -0
  164. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MethodNotAllowedException.php +22 -0
  165. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingAttachmentException.php +22 -0
  166. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingContentLengthException.php +22 -0
  167. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingRequestBodyErrorException.php +22 -0
  168. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingSecurityElementException.php +22 -0
  169. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingSecurityHeaderException.php +22 -0
  170. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoLoggingStatusForKeyException.php +22 -0
  171. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchBucketException.php +22 -0
  172. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchBucketPolicyException.php +22 -0
  173. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchCORSConfigurationException.php +22 -0
  174. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchKeyException.php +22 -0
  175. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchLifecycleConfigurationException.php +22 -0
  176. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchTagSetErrorException.php +22 -0
  177. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchUploadException.php +22 -0
  178. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchVersionException.php +22 -0
  179. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchWebsiteConfigurationException.php +22 -0
  180. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NotImplementedException.php +22 -0
  181. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NotSignedUpException.php +22 -0
  182. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NotSuchBucketPolicyException.php +22 -0
  183. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ObjectAlreadyInActiveTierErrorException.php +22 -0
  184. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ObjectNotInActiveTierErrorException.php +22 -0
  185. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/OperationAbortedException.php +22 -0
  186. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/Parser/S3ExceptionParser.php +72 -0
  187. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/PermanentRedirectException.php +22 -0
  188. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/PreconditionFailedException.php +22 -0
  189. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RedirectException.php +22 -0
  190. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestIsNotMultiPartContentException.php +22 -0
  191. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestTimeTooSkewedException.php +22 -0
  192. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestTimeoutException.php +22 -0
  193. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestTorrentOfBucketErrorException.php +22 -0
  194. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/S3Exception.php +24 -0
  195. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ServiceUnavailableException.php +22 -0
  196. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/SignatureDoesNotMatchException.php +22 -0
  197. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/SlowDownException.php +22 -0
  198. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/TemporaryRedirectException.php +22 -0
  199. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/TokenRefreshRequiredException.php +22 -0
  200. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/TooManyBucketsException.php +22 -0
  201. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/UnexpectedContentException.php +22 -0
  202. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/UnresolvableGrantByEmailAddressException.php +22 -0
  203. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/UserKeyMustBeSpecifiedException.php +22 -0
  204. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListBucketsIterator.php +48 -0
  205. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListMultipartUploadsIterator.php +46 -0
  206. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListObjectVersionsIterator.php +48 -0
  207. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListObjectsIterator.php +68 -0
  208. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/OpendirIterator.php +86 -0
  209. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/Acp.php +243 -0
  210. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/AcpBuilder.php +134 -0
  211. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/ClearBucket.php +189 -0
  212. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/DeleteObjectsBatch.php +87 -0
  213. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/DeleteObjectsTransfer.php +133 -0
  214. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/Grant.php +139 -0
  215. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/Grantee.php +245 -0
  216. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/AbstractTransfer.php +103 -0
  217. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/ParallelTransfer.php +124 -0
  218. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/SerialTransfer.php +86 -0
  219. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/TransferState.php +41 -0
  220. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/UploadBuilder.php +297 -0
  221. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/UploadId.php +35 -0
  222. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/UploadPart.php +74 -0
  223. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/PostObject.php +275 -0
  224. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Resources/s3-2006-03-01.php +5022 -0
  225. lib/amazon/aws/aws-sdk-php/src/Aws/S3/ResumableDownload.php +176 -0
  226. lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3Client.php +683 -0
  227. lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3Md5Listener.php +73 -0
  228. lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3Signature.php +266 -0
  229. lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3SignatureInterface.php +24 -0
  230. lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3SignatureV4.php +60 -0
  231. lib/amazon/aws/aws-sdk-php/src/Aws/S3/SocketTimeoutChecker.php +71 -0
  232. lib/amazon/aws/aws-sdk-php/src/Aws/S3/SseCpkListener.php +68 -0
  233. lib/amazon/aws/aws-sdk-php/src/Aws/S3/StreamWrapper.php +892 -0
  234. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/AbstractSync.php +127 -0
  235. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/AbstractSyncBuilder.php +435 -0
  236. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/ChangedFilesIterator.php +130 -0
  237. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/DownloadSync.php +95 -0
  238. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/DownloadSyncBuilder.php +129 -0
  239. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/FilenameConverterInterface.php +32 -0
  240. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/KeyConverter.php +67 -0
  241. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSync.php +86 -0
  242. lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php +190 -0
  243. lib/amazon/composer/ClassLoader.php +413 -0
  244. lib/amazon/composer/autoload_classmap.php +9 -0
  245. lib/amazon/composer/autoload_namespaces.php +13 -0
  246. lib/amazon/composer/autoload_psr4.php +9 -0
  247. lib/amazon/composer/autoload_real.php +50 -0
  248. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/AbstractCacheAdapter.php +21 -0
  249. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/CacheAdapterFactory.php +117 -0
  250. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/CacheAdapterInterface.php +55 -0
  251. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/ClosureCacheAdapter.php +57 -0
  252. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/DoctrineCacheAdapter.php +41 -0
  253. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/NullCacheAdapter.php +31 -0
  254. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/Zf1CacheAdapter.php +44 -0
  255. lib/amazon/guzzle/guzzle/src/Guzzle/Cache/Zf2CacheAdapter.php +41 -0
  256. lib/amazon/guzzle/guzzle/src/Guzzle/Common/AbstractHasDispatcher.php +49 -0
  257. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Collection.php +403 -0
  258. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Event.php +52 -0
  259. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/BadMethodCallException.php +5 -0
  260. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/ExceptionCollection.php +108 -0
  261. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/GuzzleException.php +8 -0
  262. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/InvalidArgumentException.php +5 -0
  263. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/RuntimeException.php +5 -0
  264. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/UnexpectedValueException.php +5 -0
  265. lib/amazon/guzzle/guzzle/src/Guzzle/Common/FromConfigInterface.php +18 -0
  266. lib/amazon/guzzle/guzzle/src/Guzzle/Common/HasDispatcherInterface.php +54 -0
  267. lib/amazon/guzzle/guzzle/src/Guzzle/Common/ToArrayInterface.php +16 -0
  268. lib/amazon/guzzle/guzzle/src/Guzzle/Common/Version.php +29 -0
  269. lib/amazon/guzzle/guzzle/src/Guzzle/Http/AbstractEntityBodyDecorator.php +221 -0
  270. lib/amazon/guzzle/guzzle/src/Guzzle/Http/CachingEntityBody.php +22 -0
addons/comments/comments.class.php CHANGED
@@ -51,7 +51,7 @@ class IWP_MMB_Comment extends IWP_MMB_Core
51
 
52
  if(!empty($filter_comments))
53
  {
54
- $where.=" AND (c.comment_author LIKE '%".mysql_real_escape_string($filter_comments)."%' OR c.comment_content LIKE '%".mysql_real_escape_string($filter_comments)."%')";
55
  }
56
  $comment_array = array();
57
  $comment_statuses = array('approved', 'pending', 'spam', 'trash');
51
 
52
  if(!empty($filter_comments))
53
  {
54
+ $where.=" AND (c.comment_author LIKE '%".esc_sql($filter_comments)."%' OR c.comment_content LIKE '%".esc_sql($filter_comments)."%')";
55
  }
56
  $comment_array = array();
57
  $comment_statuses = array('approved', 'pending', 'spam', 'trash');
addons/google_webmasters/google_webmasters.class.php CHANGED
@@ -21,7 +21,7 @@ if(!function_exists('iwp_mmb_create_webmasters_redirect_table')){
21
  `redirectLink` varchar(255) NOT NULL,
22
  PRIMARY KEY (`id`),
23
  UNIQUE KEY `oldLink` (`oldLink`)
24
- ) ENGINE=InnoDB ;
25
  ";
26
 
27
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
21
  `redirectLink` varchar(255) NOT NULL,
22
  PRIMARY KEY (`id`),
23
  UNIQUE KEY `oldLink` (`oldLink`)
24
+ );
25
  ";
26
 
27
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
addons/post_links/link.class.php CHANGED
@@ -89,7 +89,7 @@ class IWP_MMB_Link extends IWP_MMB_Core
89
 
90
  if(!empty($filter_links))
91
  {
92
- $where.=" AND (link_name LIKE '%".mysql_real_escape_string($filter_links)."%' OR link_url LIKE '%".mysql_real_escape_string($filter_links)."%')";
93
  }
94
 
95
  $linkcats = $this->getLinkCats();
@@ -104,9 +104,11 @@ class IWP_MMB_Link extends IWP_MMB_Core
104
  {
105
  $link_cat = $linkcats[$link_info->link_id];
106
  $cats = array();
107
- foreach($link_cat as $catkey=>$catval)
108
- {
109
- $cats[] = $catval;
 
 
110
  }
111
 
112
  $links[$link_info->link_id] = array(
89
 
90
  if(!empty($filter_links))
91
  {
92
+ $where.=" AND (link_name LIKE '%".esc_sql($filter_links)."%' OR link_url LIKE '%".esc_sql($filter_links)."%')";
93
  }
94
 
95
  $linkcats = $this->getLinkCats();
104
  {
105
  $link_cat = $linkcats[$link_info->link_id];
106
  $cats = array();
107
+ if (!empty($link_cat)) {
108
+ foreach($link_cat as $catkey=>$catval)
109
+ {
110
+ $cats[] = $catval;
111
+ }
112
  }
113
 
114
  $links[$link_info->link_id] = array(
addons/post_links/post.class.php CHANGED
@@ -475,20 +475,20 @@ class IWP_MMB_Post extends IWP_MMB_Core
475
 
476
  if(!empty($filter_posts))
477
  {
478
- $where.=" AND post_title LIKE '%".mysql_real_escape_string($filter_posts)."%'";
479
  }
480
 
481
  if(!empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
482
  {
483
- $where.=" AND post_date BETWEEN '".mysql_real_escape_string($iwp_get_posts_date_from)."' AND '".mysql_real_escape_string($iwp_get_posts_date_to)."'";
484
  }
485
  else if(!empty($iwp_get_posts_date_from) && empty($iwp_get_posts_date_to))
486
  {
487
- $where.=" AND post_date >= '".mysql_real_escape_string($iwp_get_posts_date_from)."'";
488
  }
489
  else if(empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
490
  {
491
- $where.=" AND post_date <= '".mysql_real_escape_string($iwp_get_posts_date_to)."'";
492
  }
493
  $post_array=array();
494
  $post_statuses = array('publish', 'pending', 'private', 'future', 'draft', 'trash');
@@ -503,7 +503,7 @@ class IWP_MMB_Post extends IWP_MMB_Core
503
  $where.=" AND post_status IN (".implode(",",$post_array).")";
504
  }
505
 
506
- $limit = ($iwp_get_posts_range) ? ' LIMIT ' . mysql_real_escape_string($iwp_get_posts_range) : ' LIMIT 500';
507
 
508
  $sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' ".$where." ORDER BY post_date DESC";
509
 
@@ -516,10 +516,11 @@ class IWP_MMB_Post extends IWP_MMB_Core
516
  $total['total_num']=count($posts_info);
517
 
518
  if($iwp_get_posts_range && !empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to) && $total['total_num'] < $iwp_get_posts_range) {
 
519
  $sql_query = "$wpdb->posts
520
- WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' AND post_date <= '".mysql_real_escape_string($iwp_get_posts_date_to)."'
521
  ORDER BY post_date DESC
522
- LIMIT " . mysql_real_escape_string($iwp_get_posts_range);
523
 
524
  $posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query);
525
  $total = array();
@@ -530,9 +531,11 @@ class IWP_MMB_Post extends IWP_MMB_Core
530
  {
531
 
532
  $cats=array();
533
- foreach($post_cats[$post_info->ID] as $cat_array => $cat_array_val)
534
- {
535
- $cats[] = array('name' => $cat_array_val);
 
 
536
  }
537
 
538
  $tags=array();
@@ -642,19 +645,25 @@ class IWP_MMB_Post extends IWP_MMB_Core
642
 
643
  if(!empty($filter_pages))
644
  {
645
- $where.=" AND post_title LIKE '%".mysql_real_escape_string($filter_pages)."%'";
 
 
646
  }
647
  if(!empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to))
648
  {
649
- $where.=" AND post_date BETWEEN '".mysql_real_escape_string($iwp_get_pages_date_from)."' AND '".mysql_real_escape_string($iwp_get_pages_date_to)."'";
 
 
650
  }
651
  else if(!empty($iwp_get_pages_date_from) && empty($iwp_get_pages_date_to))
652
  {
653
- $where.=" AND post_date >= '".mysql_real_escape_string($iwp_get_pages_date_from)."'";
 
 
654
  }
655
  else if(empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to))
656
  {
657
- $where.=" AND post_date <= '".mysql_real_escape_string($iwp_get_pages_date_to)."'";
658
  }
659
 
660
  $post_array=array();
@@ -670,7 +679,8 @@ class IWP_MMB_Post extends IWP_MMB_Core
670
  $where.=" AND post_status IN (".implode(",",$post_array).")";
671
  }
672
 
673
- $limit = ($iwp_get_pages_range) ? ' LIMIT ' . mysql_real_escape_string($iwp_get_pages_range) : ' LIMIT 500';
 
674
 
675
  $sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='page' ".$where.' ORDER BY post_date DESC';
676
 
@@ -682,9 +692,12 @@ class IWP_MMB_Post extends IWP_MMB_Core
682
 
683
  if($iwp_get_pages_range && !empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to) && $total['total_num'] < $iwp_get_pages_range) {
684
  $sql_query = "$wpdb->posts
685
- WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' AND post_date <= '".mysql_real_escape_string($iwp_get_pages_date_to)."'
686
  ORDER BY post_date DESC
687
- LIMIT " . mysql_real_escape_string($iwp_get_pages_range);
 
 
 
688
 
689
  $posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query);
690
  $total = array();
475
 
476
  if(!empty($filter_posts))
477
  {
478
+ $where.=" AND post_title LIKE '%".esc_sql($filter_posts)."%'";
479
  }
480
 
481
  if(!empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
482
  {
483
+ $where.=" AND post_date BETWEEN '".esc_sql($iwp_get_posts_date_from)."' AND '".esc_sql($iwp_get_posts_date_to)."'";
484
  }
485
  else if(!empty($iwp_get_posts_date_from) && empty($iwp_get_posts_date_to))
486
  {
487
+ $where.=" AND post_date >= '".esc_sql($iwp_get_posts_date_from)."'";
488
  }
489
  else if(empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
490
  {
491
+ $where.=" AND post_date <= '".esc_sql($iwp_get_posts_date_to)."'";
492
  }
493
  $post_array=array();
494
  $post_statuses = array('publish', 'pending', 'private', 'future', 'draft', 'trash');
503
  $where.=" AND post_status IN (".implode(",",$post_array).")";
504
  }
505
 
506
+ $limit = ($iwp_get_posts_range) ? ' LIMIT ' . esc_sql($iwp_get_posts_range) : ' LIMIT 500';
507
 
508
  $sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' ".$where." ORDER BY post_date DESC";
509
 
516
  $total['total_num']=count($posts_info);
517
 
518
  if($iwp_get_posts_range && !empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to) && $total['total_num'] < $iwp_get_posts_range) {
519
+
520
  $sql_query = "$wpdb->posts
521
+ WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' AND post_date <= '".esc_sql($iwp_get_posts_date_to)."'
522
  ORDER BY post_date DESC
523
+ LIMIT " . esc_sql($iwp_get_posts_range);
524
 
525
  $posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query);
526
  $total = array();
531
  {
532
 
533
  $cats=array();
534
+ if(!empty($post_cats)){
535
+ foreach($post_cats[$post_info->ID] as $cat_array => $cat_array_val)
536
+ {
537
+ $cats[] = array('name' => $cat_array_val);
538
+ }
539
  }
540
 
541
  $tags=array();
645
 
646
  if(!empty($filter_pages))
647
  {
648
+
649
+ $where.=" AND post_title LIKE '%".esc_sql($filter_pages)."%'";
650
+
651
  }
652
  if(!empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to))
653
  {
654
+ $where.=" AND post_date BETWEEN '".esc_sql($iwp_get_pages_date_from)."' AND '".esc_sql($iwp_get_pages_date_to)."'";
655
+
656
+
657
  }
658
  else if(!empty($iwp_get_pages_date_from) && empty($iwp_get_pages_date_to))
659
  {
660
+ $where.=" AND post_date >= '".esc_sql($iwp_get_pages_date_from)."'";
661
+
662
+
663
  }
664
  else if(empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to))
665
  {
666
+ $where.=" AND post_date <= '".esc_sql($iwp_get_pages_date_to)."'";
667
  }
668
 
669
  $post_array=array();
679
  $where.=" AND post_status IN (".implode(",",$post_array).")";
680
  }
681
 
682
+ $limit = ($iwp_get_pages_range) ? ' LIMIT ' . esc_sql($iwp_get_pages_range) : ' LIMIT 500';
683
+
684
 
685
  $sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='page' ".$where.' ORDER BY post_date DESC';
686
 
692
 
693
  if($iwp_get_pages_range && !empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to) && $total['total_num'] < $iwp_get_pages_range) {
694
  $sql_query = "$wpdb->posts
695
+ WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' AND post_date <= '".esc_sql($iwp_get_pages_date_to)."'
696
  ORDER BY post_date DESC
697
+ LIMIT " . esc_sql($iwp_get_pages_range);
698
+
699
+
700
+
701
 
702
  $posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query);
703
  $total = array();
addons/wp_optimize/optimize.class.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  if(basename($_SERVER['SCRIPT_FILENAME']) == "optimize.class.php"):
3
  exit;
4
  endif;
@@ -14,7 +15,7 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
14
  $cleanup_values = array();
15
  $cleanup_values['value_array'] = array();
16
  $text = '';
17
-
18
  if (isset($cleanupType["clean-revisions"])) {
19
  $values = self::cleanup_type_process('revisions');
20
  $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
@@ -38,6 +39,37 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
38
  $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
39
  $cleanup_values['value_array']['unapproved'] = $values['value'];
40
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  $text .= '<br>';
43
 
@@ -99,7 +131,50 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
99
  //$message_array['del_unapproved_comments']['message'] = $comments.__(' unapproved comments deleted<br>', 'wp-optimize');
100
 
101
  break;
102
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  case "optimize-db":
104
  self::optimize_tables(true);
105
  $message .= "Database ".DB_NAME." Optimized!";
@@ -120,16 +195,16 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
120
  } // end of function
121
 
122
  function optimize_tables($Optimize=false){
123
-
124
  $db_clean = DB_NAME;
125
 
126
- $local_query = 'SHOW TABLE STATUS FROM `'. DB_NAME.'`';
127
- $result = mysql_query($local_query);
128
- if (mysql_num_rows($result)){
129
- while ($row = mysql_fetch_array($result))
130
  {
131
- $local_query = 'OPTIMIZE TABLE '.$row[0];
132
- $resultat = mysql_query($local_query);
133
  }
134
  }
135
 
1
  <?php
2
+ global $wpdb;
3
  if(basename($_SERVER['SCRIPT_FILENAME']) == "optimize.class.php"):
4
  exit;
5
  endif;
15
  $cleanup_values = array();
16
  $cleanup_values['value_array'] = array();
17
  $text = '';
18
+
19
  if (isset($cleanupType["clean-revisions"])) {
20
  $values = self::cleanup_type_process('revisions');
21
  $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
39
  $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
40
  $cleanup_values['value_array']['unapproved'] = $values['value'];
41
  }
42
+ if (isset($cleanupType["trash-post"])) {
43
+ $values = self::cleanup_type_process('trash-post');
44
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
45
+ $cleanup_values['value_array']['trash-post'] = $values['value'];
46
+ }
47
+ if (isset($cleanupType["trash-comments"])) {
48
+ $values = self::cleanup_type_process('trash-comments');
49
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
50
+ $cleanup_values['value_array']['trash-comments'] = $values['value'];
51
+ }
52
+ if (isset($cleanupType["meta-comments"])) {
53
+ $values = self::cleanup_type_process('meta-comments');
54
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
55
+ $cleanup_values['value_array']['meta-comments'] = $values['value'];
56
+ }
57
+ if (isset($cleanupType["meta-posts"])) {
58
+ $values = self::cleanup_type_process('meta-posts');
59
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
60
+ $cleanup_values['value_array']['meta-posts'] = $values['value'];
61
+ }
62
+ if (isset($cleanupType["pingbacks"])) {
63
+ $values = self::cleanup_type_process('pingbacks');
64
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
65
+ $cleanup_values['value_array']['pingbacks'] = $values['value'];
66
+ }
67
+ if (isset($cleanupType["trackbacks"])) {
68
+ $values = self::cleanup_type_process('trackbacks');
69
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
70
+ $cleanup_values['value_array']['trackbacks'] = $values['value'];
71
+ }
72
+
73
 
74
  $text .= '<br>';
75
 
131
  //$message_array['del_unapproved_comments']['message'] = $comments.__(' unapproved comments deleted<br>', 'wp-optimize');
132
 
133
  break;
134
+
135
+ case "trash-post":
136
+ $clean = "DELETE FROM $wpdb->posts WHERE post_status = 'trash';";
137
+ $comments = $wpdb->query( $clean );
138
+ $message .= __('Trashed posts deleted - ', 'wp-optimize') . $comments;
139
+ $message_array['value'] = $comments;
140
+ //$message_array['del_unapproved_comments']['message'] = $comments.__(' unapproved comments deleted<br>', 'wp-optimize');
141
+
142
+ break;
143
+
144
+ case "trash-comments":
145
+ $clean = "DELETE FROM $wpdb->comments WHERE comment_approved = 'trash';";
146
+ $comments = $wpdb->query( $clean );
147
+ $message .= __('Trashed comments deleted - ', 'wp-optimize') . $comments;
148
+ $message_array['value'] = $comments;
149
+ break;
150
+ case "meta-comments":
151
+ $clean = "DELETE cm FROM $wpdb->commentmeta cm LEFT JOIN $wpdb->comments wp ON wp.comment_ID = cm.comment_id WHERE wp.comment_ID IS NULL";
152
+ $comments = $wpdb->query( $clean );
153
+ $message .= __('Unused comments metadata deleted - ', 'wp-optimize') . $comments;
154
+ $message_array['value'] = $comments;
155
+ break;
156
+
157
+ case "meta-posts":
158
+ $clean = "DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;";
159
+ $comments = $wpdb->query( $clean );
160
+ $message .= __('Unused posts metadata deleted - ', 'wp-optimize') . $comments;
161
+ $message_array['value'] = $comments;
162
+ break;
163
+
164
+ case "pingbacks":
165
+ $clean = "DELETE FROM $wpdb->comments WHERE comment_type = 'pingback';";
166
+ $comments = $wpdb->query( $clean );
167
+ $message .= __('Pingbacks deleted - ', 'wp-optimize') . $comments;
168
+ $message_array['value'] = $comments;
169
+ break;
170
+
171
+ case "trackbacks":
172
+ $clean = "DELETE FROM $wpdb->comments WHERE comment_type = 'trackback';";
173
+ $comments = $wpdb->query( $clean );
174
+ $message .= __('Trackbacks deleted - ', 'wp-optimize') . $comments;
175
+ $message_array['value'] = $comments;
176
+
177
+ break;
178
  case "optimize-db":
179
  self::optimize_tables(true);
180
  $message .= "Database ".DB_NAME." Optimized!";
195
  } // end of function
196
 
197
  function optimize_tables($Optimize=false){
198
+ global $wpdb;
199
  $db_clean = DB_NAME;
200
 
201
+ $local_query = 'SHOW TABLE STATUS FROM infinite';
202
+ $result = $wpdb->get_results($local_query);
203
+ if ($wpdb->num_rows){
204
+ foreach ($result as $row)
205
  {
206
+ $local_query = 'OPTIMIZE TABLE '.$row->Name;
207
+ $resultat = $wpdb->get_results($local_query);
208
  }
209
  }
210
 
backup.class.multicall.php CHANGED
@@ -31,7 +31,6 @@ if(!defined('IWP_PCLZIP_TEMPORARY_DIR')){
31
  define('IWP_PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
32
  }
33
 
34
-
35
  $zip_errors = array(
36
  'No error',
37
  'No error',
@@ -73,7 +72,6 @@ $unzip_errors = array(
73
  82 => 'No files were found due to bad decryption password(s)'
74
  );
75
 
76
-
77
  class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
78
  {
79
  var $site_name;
@@ -87,6 +85,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
87
  var $backup_url;
88
  var $backup_settings_vals = array();
89
  var $iwpScriptStartTime;
 
90
  function __construct()
91
  {
92
 
@@ -146,22 +145,56 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
146
  $action = $responseParams['nextFunc'];
147
  if(empty($action))
148
  {
 
149
  return $this->statusLog($datas['backupParentHID'], array('stage' => 'trigger_check', 'status' => 'error', 'statusMsg' => 'Calling Next Function failed - Error while fetching table data', 'statusCode' => 'calling_next_function_failed_error_while_fetching_table_data'));
150
  }
151
 
152
  unset($responseParams);
153
-
154
- if(method_exists('IWP_MMB_Backup_Multicall', $action)){
155
- $result = self::$action($datas['backupParentHID']);
 
 
 
 
 
 
 
 
 
 
156
  return $result;
157
  }
158
  }
159
  }
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  function set_backup_task($params)
162
  {
163
  if(!empty($params))
164
  {
 
 
 
 
 
 
 
165
  //darkCode testing purpose static values
166
  if((empty($params['args']['file_block_size']))||($params['args']['file_block_size'] < 1))
167
  {
@@ -177,7 +210,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
177
  }
178
  if((empty($params['args']['file_loop_break_time']))||($params['args']['file_loop_break_time'] < 6))
179
  {
180
- $params['args']['file_loop_break_time'] = 23;
181
  }
182
  if((empty($params['args']['db_loop_break_time']))||($params['args']['db_loop_break_time'] < 6))
183
  {
@@ -287,32 +320,11 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
287
 
288
  function backup($historyID)
289
  {
290
- $zipPartNotOver = true;
291
  $this -> hisID = $historyID;
292
- $args = $this->getRequiredData($historyID, "requestParams");
293
- //argsInsideBackup argsFormat
294
- extract($args['args']);
295
- extract($args);
296
- //$task_name = $args['task_name'];
297
- //Prepare .zip file name
298
- $hash = md5(microtime(true).uniqid('',true).substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, rand(20,60)));
299
- $label = $type ? $type : 'manual';
300
- $backup_file_name = $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
301
- $backup_file = IWP_BACKUP_DIR . '/' . $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
302
- $backup_url = content_url() . '/infinitewp/backups/' . $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
303
- $this -> backup_url = $backup_url;
304
- //$backup_url = $backup_file;
305
-
306
- $backup_file_info = array();
307
- $backup_file_info['backup_file_name'] = $backup_file_name;
308
- $backup_file_info['backup_file'] = $backup_file;
309
- $backup_file_info['backup_url'] = $backup_url;
310
-
311
- if(empty($account_info))
312
- {
313
- $account_info = array();
314
- }
315
 
 
 
316
  if($what == 'db')
317
  {
318
  //DB alone funcion
@@ -330,7 +342,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
330
  //both files and db.
331
 
332
  $result = $this->backupDB($historyID,$backup_file,$account_info);
333
- //$result = $this->backupFiles($historyID,$backup_file);
334
  return $result;
335
  }
336
 
@@ -339,14 +350,11 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
339
 
340
  function backup_uploads($historyID)
341
  {
342
-
343
  //after creating the backup file dont forget to include it in the account_info array
344
  $this -> hisID = $historyID;
345
- $files_to_zip = '';
346
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
347
  $account_info = $responseParams['response_data']['account_info'];
348
  $backup_file = $responseParams['response_data']['backup_file'];
349
-
350
  //storing the filesize value into settings array - first get the values and then append the value of filesize to it
351
  $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
352
  $backup_settings_values = $this -> backup_settings_vals;
@@ -379,19 +387,18 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
379
  if (isset($account_info['iwp_amazon_s3']) && !empty($account_info['iwp_amazon_s3'])) {
380
  $account_info['iwp_amazon_s3']['backup_file'] = $backup_file;
381
  iwp_mmb_print_flush('Amazon S3 upload: Start');
382
- $amazons3_result = $this->amazons3_backup($historyID,$account_info['iwp_amazon_s3']);
383
- iwp_mmb_print_flush('Amazon S3 upload: End');
384
-
385
- if (empty($amazons3_result) && $del_host_file) {
386
- $this->unlinkBackupFiles($backup_file);
 
 
387
  }
 
388
  if (is_array($amazons3_result) && isset($amazons3_result['error'])) {
389
  $this->unlinkBackupFiles($backup_file);
390
  }
391
- if($amazons3_result['status'] == 'partiallyCompleted') //darkCode true loop
392
- {
393
- return $amazons3_result;
394
- }
395
  return $amazons3_result;
396
 
397
  }
@@ -399,17 +406,13 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
399
  if (isset($account_info['iwp_gdrive']) && !empty($account_info['iwp_gdrive'])) {
400
  $account_info['iwp_gdrive']['backup_file'] = $backup_file;
401
  iwp_mmb_print_flush('google Drive upload: Start');
402
- $gdrive_result = $this->google_drive_backup($historyID, $account_info['iwp_gdrive']);
403
  iwp_mmb_print_flush('google Drive upload: End');
404
-
405
  if (is_array($gdrive_result) && isset($gdrive_result['error'])){
406
  if($del_host_file){
407
  $this->unlinkBackupFiles($backup_file);
408
  }
409
  }
410
- if(empty($gdrive_result) && $del_host_file){
411
- $this->unlinkBackupFiles($backup_file);
412
- }
413
 
414
  return $gdrive_result;
415
 
@@ -461,6 +464,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
461
 
462
  function backupDB($historyID,$backup_file,$account_info = array())
463
  {
 
464
  $this->statusLog($historyID, array('stage' => 'backupDB', 'status' => 'processing', 'statusMsg' => 'backupDBInitiated'));
465
 
466
  if(file_exists(IWP_DB_DIR) && is_dir(IWP_DB_DIR))
@@ -487,8 +491,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
487
  }
488
  }
489
 
490
- if(true) // if the verification is true go for the DB process
491
- {
492
  $db_index_file = '<?php
493
  global $old_url, $old_file_path;
494
  $old_url = \''.get_option('siteurl').'\';
@@ -516,10 +518,9 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
516
  return $db_result;
517
  }
518
 
519
- }
520
-
521
  function backupDBZip($historyID)
522
  {
 
523
  // if the DB backup is successful do the zip operations
524
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
525
  $responseParams['category'] = 'dbZip';
@@ -565,11 +566,10 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
565
 
566
  }
567
  //$this->statusLog($historyID, array('stage' => 'backupDBZip', 'status' => 'completed', 'statusMsg' => 'backupZipCompleted'));
568
-
569
  return $result;
570
  }
571
 
572
-
573
  function backupDBPHP($historyID) //file must be db name alone ; $response_array should be table_name and its fields and callCount
574
  {
575
  //getting the settings first
@@ -665,7 +665,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
665
  file_put_contents($file, '');//safe to reset any old data
666
  } */
667
  //$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
668
- $tables = $wpdb->get_results('SHOW TABLES LIKE "'.$wpdb->base_prefix.'%"', ARRAY_N);
 
669
 
670
  foreach ($tables as $table) {
671
  $is_continue = '';
@@ -716,6 +717,11 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
716
  else{
717
  $breakingCount = 0;
718
  }
 
 
 
 
 
719
  if ($count > 100)
720
  {
721
  $count = ceil($count / 100);
@@ -749,6 +755,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
749
 
750
  if (is_array($rows)) {
751
  foreach ($rows as $row) {
 
752
  //insert single row
753
  if(($table[0] != $left_out_table))
754
  $dump_data = "INSERT INTO $table[0] VALUES(";
@@ -788,7 +795,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
788
  $break_flag == '';
789
  }
790
  }
791
- if(($left_out_table == $table[0])&&($count_field <= $left_out_count-1))
792
  {
793
  continue;
794
  }
@@ -818,6 +825,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
818
  {
819
  $dump_data = "\n\n\n";
820
  file_put_contents($file, $dump_data, FILE_APPEND);
 
821
  }
822
  else
823
  {
@@ -843,6 +851,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
843
  $db_res_array['status'] = $db_final_response['success']['status'];
844
  $db_res_array['backupParentHID'] = $db_final_response['success']['backupParentHID'];
845
  $db_res_array['parentHID'] = $db_final_response['success']['parentHID'];
 
846
  return $db_res_array;
847
 
848
  break;
@@ -895,8 +904,13 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
895
 
896
  function backupFiles($historyID, $backup_file='', $account_info = array(), $exclude = array(), $include = array())
897
  {
 
898
  $this -> hisID = $historyID;
899
 
 
 
 
 
900
  //for exclude and include
901
  $requestParams = $this->getRequiredData($historyID, "requestParams");
902
  $exclude = $requestParams['args']['exclude'];
@@ -950,12 +964,21 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
950
  trim(basename(WP_CONTENT_DIR)) . "/infinitewp/backups",
951
  trim(basename(WP_CONTENT_DIR)) . "/" . md5('iwp_mmb-client') . "/iwp_backups",
952
  trim(basename(WP_CONTENT_DIR)) . "/cache",
953
- trim(basename(WP_CONTENT_DIR)) . "/w3tc"
 
 
 
 
 
 
 
 
 
954
  );
955
-
956
  if((!empty($exclude_file_size))||(!empty($exclude_extensions)))
957
  {
958
- //removing files which are larger than the specified size
959
  $total_files_array = get_all_files_from_dir(ABSPATH, $remove);
960
  $files_excluded_by_size = array();
961
  foreach($total_files_array as $key => $value)
@@ -992,10 +1015,10 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
992
  }
993
  }
994
  }
995
- $remove = array_merge($remove, $files_excluded_by_size);
996
  }
997
  $exclude = array_merge($exclude, $remove);
998
-
999
  //Exclude paths
1000
 
1001
 
@@ -1050,6 +1073,12 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1050
  $result_arr['response_data']['nextCount'] = 0;
1051
  $result_arr['status'] = 'processing';
1052
  $result_arr['category'] = $category;
 
 
 
 
 
 
1053
  $result_arr['response_data']['include_data'] = $include_data;
1054
  $result_arr['response_data']['exclude_data'] = $exclude_data;
1055
  $result_arr['response_data']['backup_file'] = $backup_file;
@@ -1068,10 +1097,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1068
  function backupFilesZIP($historyID)
1069
  {
1070
  $this -> hisID = $historyID;
1071
- $files_to_zip = '';
1072
  $files_with_error = array();
1073
  $files_excluded_by_size = array();
1074
- $start34 = microtime(true);
1075
  //get the backup settings values from options table
1076
  $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
1077
  $backup_settings_values = $this -> backup_settings_vals;
@@ -1089,7 +1116,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1089
  $exclude_file_size = $requestParams['args']['exclude_file_size'];
1090
  $exclude_extensions = $requestParams['args']['exclude_extensions'];
1091
  $zip_split_size = $requestParams['args']['zip_split_size'];
1092
-
1093
  if(isset($backup_settings_values['dbFileHashValue']) && !empty($backup_settings_values['dbFileHashValue'][$historyID]))
1094
  {
1095
  $dbFileHashValue = $backup_settings_values['dbFileHashValue'][$historyID];
@@ -1117,10 +1144,13 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1117
  $p_filedescr_list = isset($responseParams['response_data']['p_filedescr_list']) ? $responseParams['response_data']['p_filedescr_list'] : array();
1118
  $zip_split_part = isset($responseParams['response_data']['zip_split_part']) ? $responseParams['response_data']['zip_split_part'] : 0;
1119
  $is_new_zip = isset($responseParams['response_data']['is_new_zip']) ? $responseParams['response_data']['is_new_zip'] : 0;
 
 
1120
  /* if(empty($zip_split_part))
1121
  {
1122
  $zip_split_part = 1;
1123
  } */
 
1124
  if((!empty($zip_split_part))&&(!empty($is_new_zip)))
1125
  {
1126
  if(strpos($backup_file, '_iwp_part_'))
@@ -1134,43 +1164,23 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1134
  $backup_url = substr($backup_url, 0, strpos($backup_url, '.zip')).'_iwp_part_'.$zip_split_part.'.zip';
1135
  }
1136
  }
1137
- else
1138
  {
1139
  $zip_split_part = 0;
1140
  }
1141
 
1142
- if(empty($p_filedescr_list))
1143
- {
1144
- $p_filedescr_list = array();
1145
- }
1146
- if(empty($files_with_error))
1147
- {
1148
- $files_with_error = array();
1149
- }
1150
- if(empty($files_excluded_by_size))
1151
- {
1152
- $files_excluded_by_size = array();
1153
- }
1154
-
1155
  include_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
1156
- //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1157
-
1158
- //include_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.split.php';
1159
  $returnArr = array();
1160
- if(!$nextCount)
1161
- {
1162
- $nextCount = 0;
1163
- }
1164
  if((($nextCount != 0)||($category == 'fileZipAfterDBZip'))&&(empty($is_new_zip)))
1165
  {
1166
  unset($responseParams);
1167
  $initialFileSize = iwp_mmb_get_file_size($backup_file)/1024/1024;
1168
  $returnArr = $this->backupFilesNext($include_data, $exclude_data, $backup_file, $backup_url, $nextCount, $p_filedescr_list, $account_info, $files_with_error, $files_excluded_by_size, $zip_split_part);
1169
  $fileNextTimeTaken = microtime(true) - $this->iwpScriptStartTime;
1170
- echo "<br>Total file size".(iwp_mmb_get_file_size($backup_file)/1024/1024);
1171
  $file_size_in_this_call = (iwp_mmb_get_file_size($backup_file)/1024/1024) - $initialFileSize;
1172
- echo "<br>file size in this call".$file_size_in_this_call;
1173
- echo "<br>Time taken in this call ".$fileNextTimeTaken."<br>";
1174
  if(($file_size_in_this_call == 0) && !(is_array($returnArr) && !empty($returnArr['error'])) && !(is_array($returnArr) && !empty($returnArr['isGetFileList'])))
1175
  {
1176
  return array( 'error' => 'Zip-error: Unable to zip', 'error_code' => 'zip_error_unable_to_zip');
@@ -1188,20 +1198,24 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1188
  $archive = new IWPPclZip($backup_file);
1189
  if($category == 'dbZip')
1190
  {
1191
- if(empty($p_filedescr_list))
1192
  {
 
1193
  //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1194
  $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //darkCode set the file block size here .. static values
1195
- $p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1196
- unset($p_filedescr_list_array['p_filedescr_list']);
1197
-
 
1198
  if($p_filedescr_list_array['status'] == 'partiallyCompleted')
1199
  {
 
1200
  $result_arr = array();
1201
  $result_arr = $responseParams;
1202
  $result_arr['nextFunc'] = 'backupFilesZIP';
1203
  $result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1204
  unset($p_filedescr_list);
 
1205
  $result_arr['response_data']['complete_folder_list'] = $p_filedescr_list_array['complete_folder_list'];
1206
  unset($p_filedescr_list_array);
1207
  $this->statusLog($this -> hisID, array('stage' => 'gettingFileList', 'status' => 'processing', 'statusMsg' => 'gettingFileListInMultiCall','responseParams' => $result_arr));
@@ -1222,22 +1236,22 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1222
  }
1223
  else
1224
  {
1225
- if(empty($p_filedescr_list))
1226
  {
1227
- $p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
 
 
1228
 
1229
- $p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1230
- unset($p_filedescr_list_array['p_filedescr_list']);
 
 
 
1231
  $next_file_index = $p_filedescr_list_array['next_file_index'];
1232
 
1233
- /* $resArray = array();
1234
- $resArray['status'] = 'completed';
1235
- //$resArray['backupParentHID'] = $historyID;
1236
- return $resArray;
1237
- exit; */
1238
-
1239
  if($p_filedescr_list_array['status'] == 'partiallyCompleted')
1240
  {
 
1241
  $result_arr = array();
1242
  $result_arr = $responseParams;
1243
  $result_arr['nextFunc'] = 'backupFilesZIP';
@@ -1272,17 +1286,25 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1272
  );
1273
  $v_result = 1;
1274
  $v_header = array();
 
 
 
1275
  $p_result_list = array();
1276
- $v_nb = sizeof($p_result_list);
1277
- $v_header_list = array();
1278
- $v_comment = '';
1279
  //$nextCount = 0;
1280
  $archive->privOpenFd('wb');
1281
  $p_filedescr_list_omitted = array();
1282
  $omitted_flag = '';
1283
- $p_filedescr_list_size = sizeof($p_filedescr_list);
1284
- echo "loopStarted";
 
 
 
 
1285
  for ($j=$nextCount; ($j<$p_filedescr_list_size) && ($v_result==1); $j++) {
 
 
 
 
1286
  // ----- Format the filename
1287
  $p_filedescr_list[$j]['filename'] = IWPPclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
1288
 
@@ -1296,7 +1318,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1296
  // ----- Check the filename
1297
  if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
1298
  && (!file_exists($p_filedescr_list[$j]['filename']))) {
1299
- echo 'FILE DOESNT EXIST';
1300
  }
1301
 
1302
  // ----- Look if it is a file or a dir with no all path remove option
@@ -1310,41 +1332,42 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1310
  || !$p_options[IWP_PCLZIP_OPT_REMOVE_ALL_PATH]))
1311
  ) {
1312
 
1313
- $time = microtime(true);
1314
- $finish_part = $time;
1315
- $total_time_part = $finish_part - $start;
1316
- /* if(($total_time_part > 2)&&($p_filedescr_list[$j]['size'] > 5000000))
1317
- {
1318
- $p_filedescr_list_omitted[$j] = $p_filedescr_list[$j];
1319
- $v_nb++;
1320
- $nextCount = $v_nb;
1321
- $omitted_flag = 'set';
1322
- continue;
1323
-
1324
- }
1325
- */
1326
  // ----- Add the file
1327
  $v_result = $archive->privAddFile($p_filedescr_list[$j], $v_header, $p_options);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1328
 
1329
  // ----- Store the file infos
1330
- $p_result_list[$v_nb++] = $v_header;
1331
  $nextCount = $j+1;
1332
 
 
 
1333
  if ($v_result != 1) {
1334
- echo 'Error zipping this file'.$p_filedescr_list[$j]['filename'];
1335
- $files_with_error[] = $p_filedescr_list[$j]['filename'];
1336
  if($v_result == -10)
1337
  {
1338
- return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-error: Error compressing the file "'.$p_filedescr_list[$j]['filename'].'".Try excluding this file and try again.', 'statusCode' => 'zip_error_while_compressing_file'));
1339
  }
1340
  continue;
1341
  //return $v_result;
1342
  }
1343
  }
1344
 
1345
- $time = microtime(true);
1346
- $finish = $time;
1347
- $total_time = $finish - $this->iwpScriptStartTime;
1348
  //if(($total_time > $file_loop_break_time)||) //darkCode static Values
1349
  $buffer_size = $zip_split_size*1024*1024 - 3*1024*1024*$file_block_size;
1350
  $is_new_zip = false;
@@ -1360,13 +1383,22 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1360
  //iwp_mmb_print_flush("|");
1361
  iwp_mmb_auto_print("multiCallZip");
1362
  echo("|");
 
1363
  }
1364
- echo "loopEnded";
 
1365
  $v_offset = @ftell($archive->zip_fd);
1366
- $v_header_list = $p_result_list;
 
1367
  //$nextCount = sizeof($p_result_list);
1368
- for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
 
 
 
1369
  {
 
 
 
1370
  // ----- Create the file header
1371
  if ($v_header_list[$i]['status'] == 'ok') {
1372
  if (($v_result = $archive->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
@@ -1379,12 +1411,18 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1379
 
1380
  // ----- Transform the header to a 'usable' info
1381
  $archive->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
 
 
 
 
1382
  }
 
1383
  $v_size = @ftell($archive->zip_fd)-$v_offset;
1384
  $archive->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment);
1385
  $archive->privCloseFd();
1386
- echo 'next Count -'.$nextCount;
1387
- if(($nextCount == sizeof($p_filedescr_list)+1)||($nextCount == sizeof($p_filedescr_list)))
 
1388
  {
1389
  $nextCount = "completed";
1390
  $status = "completed";
@@ -1393,6 +1431,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1393
  {
1394
  $status = "partiallyCompleted";
1395
  }
 
1396
  $result_arr = array();
1397
 
1398
  //return $p_result_list;
@@ -1408,6 +1447,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1408
  $result_arr['response_data']['files_with_error'] = $files_with_error;
1409
  $result_arr['response_data']['files_excluded_by_size'] = $files_excluded_by_size;
1410
  $result_arr['response_data']['is_new_zip'] = $is_new_zip;
 
1411
  //$result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1412
  $result_arr['response_data']['zip_split_part'] = $zip_split_part;
1413
  $resArray = array (
@@ -1432,8 +1472,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1432
  }
1433
  if($status == 'partiallyCompleted')
1434
  {
1435
- echo 'filesNextCount: '.$nextCount;
1436
- echo 'totalFilesCount: '.count($p_filedescr_list);
1437
  $result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1438
  unset($p_filedescr_list);
1439
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'backupFileSingleCall'.$status,'nextFunc' => 'backupFilesZIP', 'responseParams' => $result_arr));
@@ -1457,6 +1497,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1457
  }
1458
  else
1459
  {
 
1460
  $paths = array();
1461
  $tempPaths = array();
1462
 
@@ -1491,6 +1532,12 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1491
  $paths['task_results'][$historyID] = $tempPath;
1492
  if(empty($account_info))
1493
  {
 
 
 
 
 
 
1494
  $result_arr['nextFunc'] = 'backupFilesZIPOver';
1495
  }
1496
  else
@@ -1539,25 +1586,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1539
  }
1540
  }
1541
 
1542
-
1543
- function get_exclude_ext_array($exclude_extensions){
1544
- if(empty($exclude_extensions))
1545
- {
1546
- $exclude_extensions = array();
1547
- }
1548
- else if($exclude_extensions == 'eg. .zip,.mp4')
1549
- {
1550
- $exclude_extensions = array();
1551
- }
1552
- else
1553
- {
1554
- $exclude_extensions_array = explode(",",$exclude_extensions);
1555
- $exclude_extensions = array();
1556
- $exclude_extensions = $exclude_extensions_array;
1557
- }
1558
- return $exclude_extensions;
1559
- }
1560
-
1561
  function get_total_files_size($backup_files)
1562
  {
1563
  if(is_array($backup_files))
@@ -1578,7 +1606,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1578
  function backupFilesNext($include_data, $exclude_data, $backup_file, $backup_url, $nextCount, $p_filedescr_list = array(), $account_info = array(), $files_with_error = array(), $files_excluded_by_size = array(), $zip_split_part = 0)
1579
  {
1580
  $historyID = $this -> hisID;
1581
- $start34 = microtime(true);
1582
  $is_new_zip = false;
1583
  $backup_settings_values = $this -> backup_settings_vals;
1584
  //$file_block_size = $backup_settings_values['file_block_size'];
@@ -1604,6 +1631,9 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1604
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
1605
  $category = $responseParams['category']; //Am getting the category to perform the dbZip actions
1606
 
 
 
 
1607
  $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'processing', 'statusMsg' => 'backupMultiCallInitiated', 'responseParams' => $responseParams));
1608
 
1609
  $time = microtime(true);
@@ -1615,8 +1645,10 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1615
  {
1616
  if(empty($p_filedescr_list)||($nextCount == 0))
1617
  {
 
1618
  $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID);//darkCode set the file block size here .. static values
1619
  $p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
 
1620
 
1621
  if($p_filedescr_list_array['status'] == 'partiallyCompleted')
1622
  {
@@ -1626,6 +1658,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1626
  $result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1627
  $result_arr['response_data']['next_file_index'] = $p_filedescr_list_array['next_file_index'];
1628
  $result_arr['response_data']['complete_folder_list'] = $p_filedescr_list_array['complete_folder_list'];
 
1629
  $this->statusLog($this -> hisID, array('stage' => 'gettingFileList', 'status' => 'processing', 'statusMsg' => 'gettingFileListInMultiCall','responseParams' => $result_arr));
1630
 
1631
  $resArray = array();
@@ -1643,11 +1676,15 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1643
  }
1644
  }
1645
  }
 
1646
  else
1647
  {
1648
  if(empty($p_filedescr_list)||($nextCount == 0))
1649
  {
1650
- $p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
 
 
 
1651
 
1652
  $p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1653
 
@@ -1663,7 +1700,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1663
  $result_arr['response_data']['complete_folder_list'] = $p_filedescr_list_array['complete_folder_list'];
1664
 
1665
  $this->statusLog($this -> hisID, array('stage' => 'gettingFileList', 'status' => 'processing', 'statusMsg' => 'gettingFileListInMultiCall','responseParams' => $result_arr));
1666
- $timeTaken34 = microtime(true) - $start34;
1667
  unset($p_filedescr_list_array);
1668
  $resArray = array();
1669
  $resArray['status'] = 'partiallyCompleted';
@@ -1681,6 +1717,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1681
  }
1682
  }
1683
  }
 
1684
  $archive->privDisableMagicQuotes();
1685
  if (($v_result=$archive->privOpenFd('rb+')) != 1)
1686
  {
@@ -1694,7 +1731,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1694
  $v_central_dir = array();
1695
  if (($v_result = $archive->privReadEndCentralDir($v_central_dir)) != 1)
1696
  {
1697
- echo 'error2';
1698
  $archive->privCloseFd();
1699
  $archive->privSwapBackMagicQuotes();
1700
  if(is_array($v_result) && !empty($v_result['error']))
@@ -1718,7 +1755,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1718
  {
1719
  $archive->privCloseFd();
1720
  $archive->privSwapBackMagicQuotes();
1721
- echo 'error3';
1722
  return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Unable to open temporary file', 'statusCode' => 'unable_to_open_temporary_file')); // ----- Return
1723
 
1724
  }
@@ -1762,19 +1799,23 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1762
  $v_header = array();
1763
  $p_result_list = array();
1764
  $v_header_list = array();
1765
- $v_nb = sizeof($v_header_list);
1766
  $v_comment = '';
1767
  //$nextCount = $_REQUEST['nextCount'];
1768
  $omitted_flag = '';
1769
  $nextCountHere = 0;
1770
- $p_filedescr_list_size = sizeof($p_filedescr_list);
1771
- $timeBeforeAdd = microtime(true) - $start34;
1772
  iwp_mmb_print_flush("loopStarted");
 
 
 
1773
  for ($j=($nextCount); ($j<$p_filedescr_list_size) && ($v_result==1); $j++) {
 
 
 
 
1774
  // ----- Format the filename
1775
- $p_filedescr_list[$j]['filename']
1776
- = IWPPclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
1777
-
1778
 
1779
  // ----- Skip empty file names
1780
  // TBC : Can this be possible ? not checked in DescrParseAtt ?
@@ -1813,18 +1854,33 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1813
  } */
1814
 
1815
  // ----- Add the file
 
 
 
1816
  $v_result = $archive->privAddFile($p_filedescr_list[$j], $v_header, $p_options);
 
 
 
 
 
 
 
 
 
 
 
 
1817
  // ----- Store the file infos
1818
- $v_header_list[$v_nb++] = $v_header;
1819
 
1820
  if ($v_result != 1) {
1821
  //$this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'SomeError1'));
1822
- echo "error zipping this file:".$p_filedescr_list[$j]['filename'];
1823
- echo 'errorCode - '.$v_result;
1824
- $files_with_error[] = $p_filedescr_list[$j]['filename'];
1825
  if($v_result == -10)
1826
  {
1827
- return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-error: Error compressing the file "'.$p_filedescr_list[$j]['filename'].'".Try excluding this file and try again.', 'statusCode' => 'zip_error_while_compressing_file'));
1828
  }
1829
  continue;
1830
  //return $v_result;
@@ -1841,14 +1897,17 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1841
  {
1842
  $zip_split_part += 1;
1843
  $is_new_zip = true;
 
1844
  }
1845
  break;
1846
  }
1847
  //iwp_mmb_print_flush("|");
1848
  iwp_mmb_auto_print("multiCallZip");
1849
  //echo "|";
 
1850
  }
1851
- echo "loopEnded";
 
1852
  $v_offset = @ftell($archive->zip_fd);
1853
  $v_size = $v_central_dir['size'];
1854
  /* while ($v_size != 0)
@@ -1872,17 +1931,22 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1872
  $v_buffer = fread($v_zip_temp_fd, $v_central_dir['size']);
1873
  $writeResult = fwrite($archive->zip_fd, $v_buffer);
1874
 
 
1875
 
1876
-
1877
  //array_pop($v_header_list);
1878
  //$v_header_list = $p_result_list;
1879
  // ----- Create the Central Dir files header
1880
- for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
 
1881
  {
 
 
 
1882
  // ----- Create the file header
1883
  if ($v_header_list[$i]['status'] == 'ok') {
1884
  if (($v_result = $archive->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
1885
- echo 'error4';
1886
  fclose($v_zip_temp_fd);
1887
  $archive->privCloseFd();
1888
  @unlink($v_zip_temp_name);
@@ -1895,7 +1959,10 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1895
 
1896
  // ----- Transform the header to a 'usable' info
1897
  $archive->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
 
 
1898
  }
 
1899
  // ----- Calculate the size of the central header
1900
  $v_size = @ftell($archive->zip_fd)-$v_offset;
1901
 
@@ -1903,7 +1970,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1903
  if (($v_result = $archive->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
1904
  {
1905
  // ----- Reset the file list
1906
- echo 'error5';
1907
  unset($v_header_list);
1908
  $archive->privSwapBackMagicQuotes();
1909
  return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-Error: Error while writing footer', 'statusCode' => 'zip_error_while_writing_footer'));
@@ -1935,7 +2002,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1935
 
1936
  $nextCount = $nextCountHere;
1937
 
1938
- $size_file_des = sizeof($p_filedescr_list);
1939
  if($nextCount == $size_file_des)
1940
  //if(true)
1941
  {
@@ -1946,7 +2013,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1946
  else{
1947
  $status = "partiallyCompleted";
1948
  }
1949
-
1950
  $result_arr = array();
1951
  $result_arr['response_data']['nextCount'] = $nextCount;
1952
  $result_arr['status'] = $status;
@@ -1961,6 +2028,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1961
  $result_arr['response_data']['is_new_zip'] = $is_new_zip;
1962
  $result_arr['response_data']['files_with_error'] = $files_with_error;
1963
  $result_arr['response_data']['files_excluded_by_size'] = $files_excluded_by_size;
 
1964
 
1965
  //$result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1966
  $resArray = array (
@@ -1983,9 +2051,9 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1983
  }
1984
  if($status == "partiallyCompleted")
1985
  {
1986
- echo 'filesNextCount: '.$nextCount;
1987
- echo 'totalFilesCount: '.count($p_filedescr_list);
1988
- $result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1989
  unset($p_filedescr_list);
1990
  $this->statusLog($this -> hisID, array('stage' => 'backupFilesMultiCall', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status,'nextFunc' => 'backupFilesZIP', 'responseParams' => $result_arr));
1991
  unset($result_arr);
@@ -2005,14 +2073,15 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2005
  $resArray['status'] = 'partiallyCompleted';
2006
  $result_arr['nextFunc'] = 'backupFiles';
2007
  $result_arr['status'] = 'partiallyCompleted';
 
2008
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status,'nextFunc' => 'backupFiles', 'responseParams' => $result_arr));
2009
  }
2010
  else
2011
  {
2012
 
2013
  //$this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status, 'responseParams' => $result_arr));
2014
-
2015
- $paths = array();
2016
  $tempPaths = array();
2017
 
2018
  $backup_files_array = $this->get_files_array_from_iwp_part($backup_file);
@@ -2050,6 +2119,14 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2050
  {
2051
  //this is where the call goes to upload after backup zip completion ..
2052
  $resArray['status'] = 'completed';
 
 
 
 
 
 
 
 
2053
  $result_arr['nextFunc'] = 'backupFilesZIPOver';
2054
  $result_arr['status'] = 'completed';
2055
  }
@@ -2060,7 +2137,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2060
  $result_arr['nextFunc'] = 'backup_uploads';
2061
  $result_arr['status'] = 'partiallyCompleted';
2062
  $result_arr['actual_file_size'] = $size;
2063
- $result_arr['backup_file'] = $backup_file;
2064
  }
2065
 
2066
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status, 'responseParams' => $result_arr,'task_result' => $paths));
@@ -2094,8 +2171,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2094
 
2095
  }
2096
  }
2097
- $fileNextTimeTaken = microtime(true) - $start34;
2098
-
2099
  return $resArray;
2100
 
2101
  }
@@ -2149,8 +2224,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2149
  }
2150
  }
2151
 
2152
-
2153
-
2154
  function getHashValuesArray($p_filedescr_list)
2155
  {
2156
  $hashValues = array();
@@ -2341,6 +2414,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2341
  {
2342
  if($statusArray['status'] == 'error')
2343
  {
 
 
2344
  $returnParams = array();
2345
  $returnParams['parentHID'] = $historyID;
2346
  $returnParams['backupRowID'] = $insertID;
@@ -2606,7 +2681,14 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2606
  {
2607
  $args['backup_file'] = $value;
2608
  iwp_mmb_print_flush('Amazon S3 download: Start '.$key);
2609
- $backup_file[] = $this->get_amazons3_backup($args);
 
 
 
 
 
 
 
2610
  iwp_mmb_print_flush('Amazon S3 download: End '.$key);
2611
  if ($backup_file[$key] == false) {
2612
  return array(
@@ -2867,20 +2949,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2867
 
2868
  }
2869
 
2870
-
2871
- /*if(!empty($clone_options['iwp_client_backup_tasks'])){
2872
-
2873
- if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$table."'")) == 1){
2874
- echo "Table exists";
2875
-
2876
- $delete = $wpdb->query("DELETE TABLE wp_iwp_backup_status");
2877
- }
2878
- iwp_mmb_create_backup_table();
2879
-
2880
- insertBackupStatusContens($clone_options['iwp_client_backup_tasks']);
2881
-
2882
- }*/
2883
-
2884
  //Backup file will be extracted to a temporary path
2885
  if(!is_array($backup_file))
2886
  {
@@ -3109,9 +3177,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
3109
  global $wpdb;
3110
 
3111
  $table = $GLOBALS['table_prefix'].'iwp_backup_status';
3112
-
3113
- if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$table."'")) == 1){
3114
-
3115
  $delete = $wpdb->query("DROP TABLE '".$table."' ");
3116
  }
3117
 
@@ -3278,7 +3345,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
3278
  function restore_db($new_temp_folder)
3279
  {
3280
  global $wpdb;
3281
- $paths = $this->check_mysql_paths();
3282
  $file_path = $new_temp_folder . '/iwp_db';
3283
  @chmod($file_path,0755);
3284
  $file_name = glob($file_path . '/*.sql');
@@ -3389,7 +3456,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
3389
  }
3390
 
3391
  ### Function: Auto Detect MYSQL and MYSQL Dump Paths
3392
- function check_mysql_paths()
3393
  {
3394
  global $wpdb;
3395
  $paths = array(
@@ -3542,7 +3609,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
3542
 
3543
  $reqs['Unzip']['pass'] = true;
3544
 
3545
- $paths = $this->check_mysql_paths();
3546
 
3547
  if (!empty($paths['mysqldump'])) {
3548
  $reqs['MySQL Dump']['status'] = $paths['mysqldump'];
@@ -3854,7 +3921,7 @@ function ftp_backup($historyID,$args = '')
3854
  return $backup_files_base_name;
3855
  }
3856
 
3857
- function postUploadVerification(&$obj, $backup_file, $destFile, $type = "", $as3_bucket = "")
3858
  {
3859
  $actual_file_size = iwp_mmb_get_file_size($backup_file);
3860
  $size1 = $actual_file_size-((0.1) * $actual_file_size);
@@ -3874,26 +3941,13 @@ function ftp_backup($historyID,$args = '')
3874
  }
3875
  else if($type == "amazons3")
3876
  {
3877
- $response = $obj -> if_object_exists($as3_bucket, $destFile);
3878
- if($response == true)
3879
- {
3880
- $meta = $obj -> get_object_headers($as3_bucket, $destFile);
3881
- $cfu_obj = new CFUtilities;
3882
- $meta_response_array = $cfu_obj->convert_response_to_array($meta);
3883
- $s3_filesize = $meta_response_array['header']['content-length'];
3884
- echo "S3 fileszie during verification - ".$s3_filesize;
3885
- if((($s3_filesize >= $size1 && $s3_filesize <= $actual_file_size) || ($s3_filesize <= $size2 && $s3_filesize >= $actual_file_size) || ($s3_filesize == $actual_file_size)) && ($s3_filesize != 0))
3886
- {
3887
- return true;
3888
- }
3889
- else
3890
- {
3891
- return false;
3892
- }
3893
  }
3894
- else
3895
- {
3896
- return false;
3897
  }
3898
  }
3899
  else if($type == "ftp")
@@ -3918,6 +3972,29 @@ function ftp_backup($historyID,$args = '')
3918
  }
3919
  }
3920
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3921
 
3922
  function remove_ftp_backup($args)
3923
  {
@@ -4376,8 +4453,7 @@ function ftp_backup($historyID,$args = '')
4376
 
4377
  */
4378
 
4379
-
4380
- function amazons3_backup($historyID , $args='' )
4381
  {
4382
  $s3StartTime = $this->iwpScriptStartTime;
4383
  $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
@@ -4390,9 +4466,6 @@ function ftp_backup($historyID,$args = '')
4390
  {
4391
  $s3_retrace_count = 0;
4392
  }
4393
- //$upload_file_block_size = $backup_settings_values['upload_file_block_size'];
4394
- //$del_host_file = $backup_settings_values['del_host_file'];
4395
-
4396
  //get the settings by other method
4397
  $requestParams = $this -> getRequiredData($historyID,"requestParams");
4398
  $upload_loop_break_time = $requestParams['account_info']['upload_loop_break_time']; //darkcode changed
@@ -4408,12 +4481,6 @@ function ftp_backup($historyID,$args = '')
4408
  @set_time_limit(0);
4409
  $this -> hisID = $historyID;
4410
 
4411
-
4412
- //the multiCall arguments
4413
- /* $uploadLoopCount = 0;
4414
- $upload_id = false;
4415
- $partsArray = array(); */
4416
-
4417
  $uploadLoopCount = 0;
4418
  $upload_id = 'start';
4419
  $partsArray = array();
@@ -4421,7 +4488,6 @@ function ftp_backup($historyID,$args = '')
4421
  $retrace = 'notSet';
4422
  $doComplete = false;
4423
 
4424
-
4425
  if($args == '')
4426
  {
4427
  //on the next call $args would be ''
@@ -4467,8 +4533,6 @@ function ftp_backup($historyID,$args = '')
4467
  $backup_settings_values['s3_retrace_count'][$historyID] = $s3_retrace_count;
4468
  update_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
4469
 
4470
- //$partsArray = $s3->list_parts($as3_bucket, $as3_file, $upload_id);//commenting this line because of fatal error $s3 object is not created, looks like these lines not required here
4471
- //$nextPart = (count($partsArray) + 1);//commenting this line because of fatal error $s3 object is not created, looks like these lines not required here
4472
  }
4473
  else
4474
  {
@@ -4476,26 +4540,13 @@ function ftp_backup($historyID,$args = '')
4476
  }
4477
  }
4478
 
4479
- //tracback ends
4480
-
4481
- /* $upload_id = 'myAQl0R72GE2s6qqlCWnQrIl9NQcPS8rm_GSICHAuon58n9z9M9qjpkUOFiT1G9tj966VLb6WqsxRI7rB9CCPg--';
4482
- $partsArray = array (
4483
- 1 =>
4484
- array (
4485
- 'PartNumber' => 1,
4486
- 'ETag' => '"84658f71569196e8a3e249c48186e166"',
4487
- ),
4488
- ); */
4489
-
4490
- //$this->statusLog($this -> hisID, array('stage' => 'uploadingFilesAmazon', 'status' => 'partiallyCompleted', 'statusMsg' => 's3SingleCall'));
4491
-
4492
  if (!$this->iwp_mmb_function_exists('curl_init')) {
4493
  return array(
4494
  'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
4495
  'partial' => 1, 'error_code' => 'cannot_use_s3_enable_curl_first'
4496
  );
4497
  }
4498
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
4499
 
4500
  $tempArgs = $args;
4501
  extract($args);
@@ -4644,6 +4695,7 @@ function ftp_backup($historyID,$args = '')
4644
  $s3ChunkCount = 0;
4645
  $reloop = false;
4646
  $reloopCount = 0;
 
4647
  do
4648
  {
4649
  $uploadLoopCount = 0;
@@ -4774,7 +4826,7 @@ function ftp_backup($historyID,$args = '')
4774
  else
4775
  {
4776
  //to continue zip split parts
4777
-
4778
  $chunkResult = array();
4779
  $chunkResult['partsArray'] = array();
4780
  $chunkResult['nextPart'] = 1;
@@ -4879,12 +4931,10 @@ function ftp_backup($historyID,$args = '')
4879
  }
4880
  }
4881
 
4882
-
4883
-
4884
- function remove_amazons3_backup($args)
4885
  {
4886
  if ($this->iwp_mmb_function_exists('curl_init')) {
4887
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
4888
  extract($args);
4889
 
4890
  if(!is_array($backup_file))
@@ -4927,10 +4977,10 @@ function ftp_backup($historyID,$args = '')
4927
  }
4928
  }
4929
 
4930
- function get_amazons3_backup($args)
4931
  {
4932
  if ($this->iwp_mmb_function_exists('curl_init')) {
4933
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
4934
  extract($args);
4935
  $temp = '';
4936
  try{
@@ -5010,7 +5060,6 @@ function ftp_backup($historyID,$args = '')
5010
  $downloadUrl = $file->getDownloadUrl();
5011
 
5012
  $temp = wp_tempnam('iwp_temp_backup.zip');
5013
- //$temp = WP_CONTENT_DIR .'/DE_clientPluginSIde.zip';
5014
 
5015
  try
5016
  {
@@ -5049,8 +5098,7 @@ function ftp_backup($historyID,$args = '')
5049
 
5050
  */
5051
 
5052
- function google_drive_backup($historyID = 0, $args = '', $uploadid = null, $offset = 0)
5053
- {
5054
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Client.php');
5055
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Http/MediaFileUpload.php');
5056
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Service/Drive.php');
@@ -5072,8 +5120,7 @@ function ftp_backup($historyID,$args = '')
5072
  $resumeURI = false;
5073
  $current_file_num = 0;
5074
 
5075
- if($args == '')
5076
- {
5077
  //on the next call $args would be ''
5078
  //set $args, $uploadid, $offset from the DB
5079
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
@@ -5105,25 +5152,21 @@ function ftp_backup($historyID,$args = '')
5105
  $refreshToken = $accessToken['refresh_token'];
5106
  $backup_file = $args['backup_file'];
5107
 
5108
- if(!is_array($backup_file))
5109
- {
5110
  $temp_backup_file = $backup_file;
5111
  $backup_file = array();
5112
  $backup_file[] = $temp_backup_file;
5113
  }
5114
 
5115
- if(is_array($backup_file))
5116
- {
5117
  $backup_files_count = count($backup_file);
5118
  $backup_file = $backup_file[$current_file_num];
5119
  }
5120
 
5121
- try
5122
- {
5123
  $client->refreshToken($refreshToken);
5124
  }
5125
- catch(Exception $e)
5126
- {
5127
  echo 'google Error ', $e->getMessage(), "\n";
5128
  return array("error" => $e->getMessage(), "error_code" => "google_error_backup_refresh_token");
5129
  }
@@ -5135,17 +5178,15 @@ function ftp_backup($historyID,$args = '')
5135
  $service = new IWP_google_Service_Drive($client);
5136
 
5137
  //create iwp folder folder if it is not present
5138
- try
5139
- {
5140
  $parameters = array();
5141
- $parameters['q'] = "title = 'infinitewp' and trashed = false and 'root' in parents and 'me' in owners and mimeType= 'application/vnd.google-apps.folder'";
5142
  $files = $service->files->listFiles($parameters);
5143
  $list_result = array();
5144
  $list_result = array_merge($list_result, $files->getItems());
5145
  $list_result = (array)$list_result;
5146
 
5147
- if(empty($list_result))
5148
- {
5149
  $file = new IWP_google_Service_Drive_DriveFile();
5150
  $file->setTitle('infinitewp');
5151
  $file->setMimeType('application/vnd.google-apps.folder');
@@ -5153,14 +5194,12 @@ function ftp_backup($historyID,$args = '')
5153
  $createdFolder = $service->files->insert($file, array(
5154
  'mimeType' => 'application/vnd.google-apps.folder',
5155
  ));
5156
- if($createdFolder)
5157
- {
5158
  $createdFolder = (array)$createdFolder;
5159
  $iwp_folder_id = $createdFolder['id'];
5160
  }
5161
  }
5162
- else
5163
- {
5164
  foreach($list_result as $k => $v){
5165
  $iwp_folder_id = $v->id;
5166
  }
@@ -5171,18 +5210,16 @@ function ftp_backup($historyID,$args = '')
5171
  }
5172
 
5173
  //create sub folder by site name
5174
- if($create_sub_folder)
5175
- {
5176
  $parameters = array();
5177
- $parameters['q'] = "title = '$sub_folder_name' and trashed = false and '$iwp_folder_id' in parents and 'me' in owners and mimeType = 'application/vnd.google-apps.folder'";
5178
- //$parameters['corpus'] = "DEFAULT";
5179
  $files = $service->files->listFiles($parameters);
5180
  $list_result = array();
5181
  $list_result = array_merge($list_result, $files->getItems());
5182
  $list_result = (array)$list_result;
5183
 
5184
- if(empty($list_result))
5185
- {
5186
  $file = new IWP_google_Service_Drive_DriveFile();
5187
  $file->setTitle($sub_folder_name);
5188
  $file->setMimeType('application/vnd.google-apps.folder');
@@ -5201,11 +5238,10 @@ function ftp_backup($historyID,$args = '')
5201
  $sub_folder_id = $createdFolder['id'];
5202
  }
5203
  }
5204
- else
5205
- {
5206
- foreach($list_result as $k => $v){
5207
- $sub_folder_id = $v->id;
5208
- }
5209
  }
5210
  }
5211
 
@@ -5216,21 +5252,17 @@ function ftp_backup($historyID,$args = '')
5216
 
5217
  // Set the Parent Folder on Google Drive
5218
  $parent = new IWP_google_Service_Drive_ParentReference();
5219
- if(empty($sub_folder_id))
5220
- {
5221
  $parent->setId($iwp_folder_id);
5222
  }
5223
- else
5224
- {
5225
  $parent->setId($sub_folder_id);
5226
  }
5227
  $file->setParents(array($parent));
5228
 
5229
  $gDriveID = '';
5230
- try
5231
- {
5232
- if(false)
5233
- {
5234
  //single upload
5235
  $data = file_get_contents($backup_file);
5236
  $createdFile = (array)$service->files->insert($file, array(
@@ -5242,8 +5274,7 @@ function ftp_backup($historyID,$args = '')
5242
 
5243
  //multipart upload
5244
 
5245
- if(true)
5246
- {
5247
  // Call the API with the media upload, defer so it doesn't immediately return.
5248
  $client->setDefer(true);
5249
  $request = $service->files->insert($file);
@@ -5262,8 +5293,7 @@ function ftp_backup($historyID,$args = '')
5262
  'backupParentHID' => $historyID,
5263
  );
5264
 
5265
- while (!$status && !feof($handle))
5266
- {
5267
  iwp_mmb_auto_print('gdrive_chucked_upload');
5268
  $chunk = fread($handle, $upload_file_block_size);
5269
  $statusArray = $media->nextChunk($chunk, $resumeURI, $fileSizeUploaded);
@@ -5273,8 +5303,7 @@ function ftp_backup($historyID,$args = '')
5273
  $fileSizeUploaded = $statusArray['progress'];
5274
 
5275
  $googleTimeTaken = microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
5276
- if(($googleTimeTaken > 10)&&($status != true))
5277
- {
5278
  $chunkResult['resumeURI'] = $resumeURI;
5279
  $chunkResult['fileSizeUploaded'] = $fileSizeUploaded;
5280
 
@@ -5300,7 +5329,7 @@ function ftp_backup($historyID,$args = '')
5300
  }
5301
 
5302
  $result = false;
5303
- if($status != false) {
5304
  $result = $status;
5305
  }
5306
 
@@ -5312,8 +5341,7 @@ function ftp_backup($historyID,$args = '')
5312
  //$gDriveID = $createdFile['id'];
5313
  $gDriveID = $completeBackupResult['id'];
5314
  }
5315
- }catch (Exception $e)
5316
- {
5317
  echo "An error occurred: " . $e->getMessage();
5318
  return array("error" => "gDrive Error".$e->getMessage(), "error_code" => "google_error_multipart_upload");
5319
  }
@@ -5337,21 +5365,19 @@ function ftp_backup($historyID,$args = '')
5337
  //$task_result['gDrive'] = basename($backup_file);
5338
  $task_result['gDrive'][] = $gDriveID;
5339
 
5340
- if($current_file_num == $backup_files_count)
5341
- {
5342
  $result_arr['nextFunc'] = 'google_drive_completed';
5343
  iwp_mmb_print_flush('Google Drive upload: End');
5344
  unset($task_result['task_results'][$historyID]['server']);
5345
  }
5346
- else
5347
- {
5348
  $result_arr['status'] = "partiallyCompleted";
5349
  $result_arr['nextFunc'] = 'google_drive_backup';
 
5350
  $resArray['status'] = 'partiallyCompleted';
5351
  }
5352
 
5353
- if($del_host_file)
5354
- {
5355
  @unlink($backup_file);
5356
  }
5357
 
@@ -5602,7 +5628,14 @@ function ftp_backup($historyID,$args = '')
5602
  $amazons3_file = $task_result['task_results'][$backup_data['historyID']]['amazons3'];
5603
  $args = $thisRequestParams['account_info']['iwp_amazon_s3'];
5604
  $args['backup_file'] = $amazons3_file;
5605
- $this->remove_amazons3_backup($args);
 
 
 
 
 
 
 
5606
  }
5607
 
5608
  if (isset($task_result['task_results'][$backup_data['historyID']]['dropbox']) && isset($thisRequestParams['account_info']['iwp_dropbox'])) {
@@ -5765,7 +5798,14 @@ function ftp_backup($historyID,$args = '')
5765
  $amazons3_file = $backup['amazons3'];
5766
  $args = $args['iwp_amazon_s3'];
5767
  $args['backup_file'] = $amazons3_file;
5768
- $this->remove_amazons3_backup($args);
 
 
 
 
 
 
 
5769
  }
5770
 
5771
  if (isset($backup['dropbox'])) {
@@ -5795,7 +5835,13 @@ function ftp_backup($historyID,$args = '')
5795
  $old_wpdb = $wpdb;
5796
  //Reconnect to avoid timeout problem after ZIP files
5797
  if(class_exists('wpdb') && function_exists('wp_set_wpdb_vars')){
5798
- @mysql_close($wpdb->dbh);
 
 
 
 
 
 
5799
  $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
5800
  wp_set_wpdb_vars();
5801
  $wpdb->options = $old_wpdb->options;//fix for multi site full backup
@@ -5879,8 +5925,342 @@ function ftp_backup($historyID,$args = '')
5879
  else
5880
  return true;
5881
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5882
  }
5883
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5884
  /*if( function_exists('add_filter') ){
5885
  add_filter( 'iwp_website_add', 'IWP_MMB_Backup::readd_tasks' );
5886
  }*/
31
  define('IWP_PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
32
  }
33
 
 
34
  $zip_errors = array(
35
  'No error',
36
  'No error',
72
  82 => 'No files were found due to bad decryption password(s)'
73
  );
74
 
 
75
  class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
76
  {
77
  var $site_name;
85
  var $backup_url;
86
  var $backup_settings_vals = array();
87
  var $iwpScriptStartTime;
88
+
89
  function __construct()
90
  {
91
 
145
  $action = $responseParams['nextFunc'];
146
  if(empty($action))
147
  {
148
+ manual_debug('', 'triggerError');
149
  return $this->statusLog($datas['backupParentHID'], array('stage' => 'trigger_check', 'status' => 'error', 'statusMsg' => 'Calling Next Function failed - Error while fetching table data', 'statusCode' => 'calling_next_function_failed_error_while_fetching_table_data'));
150
  }
151
 
152
  unset($responseParams);
153
+
154
+ $is_s3 = false;
155
+ $is_s3 = $this->check_if_s3_backup($action, $datas['backupParentHID']);
156
+
157
+ if(method_exists('IWP_MMB_Backup_Multicall', $action) || !empty($is_s3)){
158
+ manual_debug('', 'triggerStart');
159
+ if(empty($is_s3)){
160
+ $result = self::$action($datas['backupParentHID']);
161
+ }
162
+ else{
163
+ $result = $is_s3;
164
+ }
165
+ manual_debug('', 'triggerEnd');
166
  return $result;
167
  }
168
  }
169
  }
170
 
171
+ function check_if_s3_backup($action, $h_id){
172
+ $amazons3_result = false;
173
+ if($action == 'amazons3_backup'){
174
+ if(is_new_s3_compatible()){
175
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
176
+ $new_s3_obj = new IWP_MMB_S3_MULTICALL();
177
+ $amazons3_result = $new_s3_obj->amazons3_backup($h_id);
178
+ }
179
+ else{
180
+ $action = 'amazons3_backup_bwd_comp';
181
+ $amazons3_result = self::$action($h_id);
182
+ }
183
+ }
184
+ return $amazons3_result;
185
+ }
186
+
187
  function set_backup_task($params)
188
  {
189
  if(!empty($params))
190
  {
191
+ initialize_manual_debug();
192
+
193
+ $initialize_result = refresh_iwp_files_db();
194
+ if(is_array($initialize_result) && isset($initialize_result['error'])){
195
+ return $initialize_result;
196
+ }
197
+
198
  //darkCode testing purpose static values
199
  if((empty($params['args']['file_block_size']))||($params['args']['file_block_size'] < 1))
200
  {
210
  }
211
  if((empty($params['args']['file_loop_break_time']))||($params['args']['file_loop_break_time'] < 6))
212
  {
213
+ $params['args']['file_loop_break_time'] = 17;
214
  }
215
  if((empty($params['args']['db_loop_break_time']))||($params['args']['db_loop_break_time'] < 6))
216
  {
320
 
321
  function backup($historyID)
322
  {
 
323
  $this -> hisID = $historyID;
324
+ $args = $this->getRequiredData($historyID, "requestParams"); //format available - $args
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
 
326
+ $backup_file_details = $this->prepareBackupFileDetails($args);
327
+ extract($backup_file_details);
328
  if($what == 'db')
329
  {
330
  //DB alone funcion
342
  //both files and db.
343
 
344
  $result = $this->backupDB($historyID,$backup_file,$account_info);
 
345
  return $result;
346
  }
347
 
350
 
351
  function backup_uploads($historyID)
352
  {
 
353
  //after creating the backup file dont forget to include it in the account_info array
354
  $this -> hisID = $historyID;
 
355
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
356
  $account_info = $responseParams['response_data']['account_info'];
357
  $backup_file = $responseParams['response_data']['backup_file'];
 
358
  //storing the filesize value into settings array - first get the values and then append the value of filesize to it
359
  $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
360
  $backup_settings_values = $this -> backup_settings_vals;
387
  if (isset($account_info['iwp_amazon_s3']) && !empty($account_info['iwp_amazon_s3'])) {
388
  $account_info['iwp_amazon_s3']['backup_file'] = $backup_file;
389
  iwp_mmb_print_flush('Amazon S3 upload: Start');
390
+ if(is_new_s3_compatible()){
391
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
392
+ $new_s3_obj = new IWP_MMB_S3_MULTICALL();
393
+ $amazons3_result = $new_s3_obj->amazons3_backup($historyID,$account_info['iwp_amazon_s3']);
394
+ }
395
+ else{
396
+ $amazons3_result = $this->amazons3_backup_bwd_comp($historyID,$account_info['iwp_amazon_s3']);
397
  }
398
+ iwp_mmb_print_flush('Amazon S3 upload: End');
399
  if (is_array($amazons3_result) && isset($amazons3_result['error'])) {
400
  $this->unlinkBackupFiles($backup_file);
401
  }
 
 
 
 
402
  return $amazons3_result;
403
 
404
  }
406
  if (isset($account_info['iwp_gdrive']) && !empty($account_info['iwp_gdrive'])) {
407
  $account_info['iwp_gdrive']['backup_file'] = $backup_file;
408
  iwp_mmb_print_flush('google Drive upload: Start');
409
+ $gdrive_result = $this->google_drive_backup($historyID, $account_info['iwp_gdrive']);
410
  iwp_mmb_print_flush('google Drive upload: End');
 
411
  if (is_array($gdrive_result) && isset($gdrive_result['error'])){
412
  if($del_host_file){
413
  $this->unlinkBackupFiles($backup_file);
414
  }
415
  }
 
 
 
416
 
417
  return $gdrive_result;
418
 
464
 
465
  function backupDB($historyID,$backup_file,$account_info = array())
466
  {
467
+ manual_debug('', 'backupDBStart');
468
  $this->statusLog($historyID, array('stage' => 'backupDB', 'status' => 'processing', 'statusMsg' => 'backupDBInitiated'));
469
 
470
  if(file_exists(IWP_DB_DIR) && is_dir(IWP_DB_DIR))
491
  }
492
  }
493
 
 
 
494
  $db_index_file = '<?php
495
  global $old_url, $old_file_path;
496
  $old_url = \''.get_option('siteurl').'\';
518
  return $db_result;
519
  }
520
 
 
 
521
  function backupDBZip($historyID)
522
  {
523
+ manual_debug('', 'backupDBZipStart');
524
  // if the DB backup is successful do the zip operations
525
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
526
  $responseParams['category'] = 'dbZip';
566
 
567
  }
568
  //$this->statusLog($historyID, array('stage' => 'backupDBZip', 'status' => 'completed', 'statusMsg' => 'backupZipCompleted'));
569
+ manual_debug('', 'backupDBZipEnd');
570
  return $result;
571
  }
572
 
 
573
  function backupDBPHP($historyID) //file must be db name alone ; $response_array should be table_name and its fields and callCount
574
  {
575
  //getting the settings first
665
  file_put_contents($file, '');//safe to reset any old data
666
  } */
667
  //$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
668
+ $this_prefix = $wpdb->base_prefix;
669
+ $tables = $wpdb->get_results('SHOW TABLES LIKE "'.$this_prefix.'%"', ARRAY_N);
670
 
671
  foreach ($tables as $table) {
672
  $is_continue = '';
717
  else{
718
  $breakingCount = 0;
719
  }
720
+
721
+ if(!$breakingCount)
722
+ {
723
+ $breakingCount = 0;
724
+ }
725
  if ($count > 100)
726
  {
727
  $count = ceil($count / 100);
755
 
756
  if (is_array($rows)) {
757
  foreach ($rows as $row) {
758
+ manual_debug('', 'eachRow', 1000);
759
  //insert single row
760
  if(($table[0] != $left_out_table))
761
  $dump_data = "INSERT INTO $table[0] VALUES(";
795
  $break_flag == '';
796
  }
797
  }
798
+ if(($left_out_table == $table[0])&&(($count_field <= $left_out_count-1)&&(!empty($count_field))))
799
  {
800
  continue;
801
  }
825
  {
826
  $dump_data = "\n\n\n";
827
  file_put_contents($file, $dump_data, FILE_APPEND);
828
+ //manual_debug('', 'endingTableSingle');
829
  }
830
  else
831
  {
851
  $db_res_array['status'] = $db_final_response['success']['status'];
852
  $db_res_array['backupParentHID'] = $db_final_response['success']['backupParentHID'];
853
  $db_res_array['parentHID'] = $db_final_response['success']['parentHID'];
854
+ //manual_debug('', 'endingTableMulti');
855
  return $db_res_array;
856
 
857
  break;
904
 
905
  function backupFiles($historyID, $backup_file='', $account_info = array(), $exclude = array(), $include = array())
906
  {
907
+ iwp_mmb_auto_print("backupFiles");
908
  $this -> hisID = $historyID;
909
 
910
+ $initialize_result = refresh_iwp_files_db();
911
+ if(is_array($initialize_result) && isset($initialize_result['error'])){
912
+ return $initialize_result;
913
+ }
914
  //for exclude and include
915
  $requestParams = $this->getRequiredData($historyID, "requestParams");
916
  $exclude = $requestParams['args']['exclude'];
964
  trim(basename(WP_CONTENT_DIR)) . "/infinitewp/backups",
965
  trim(basename(WP_CONTENT_DIR)) . "/" . md5('iwp_mmb-client') . "/iwp_backups",
966
  trim(basename(WP_CONTENT_DIR)) . "/cache",
967
+ trim(basename(WP_CONTENT_DIR)) . "/w3tc",
968
+ trim(basename(WP_CONTENT_DIR)) . "/logs",
969
+ trim(basename(WP_CONTENT_DIR)) . "/widget_cache",
970
+ trim(basename(WP_CONTENT_DIR)) . "/tmp",
971
+ trim(basename(WP_CONTENT_DIR)) . "/updraft",
972
+ trim(basename(WP_CONTENT_DIR)) . "/updraftplus",
973
+ trim(basename(WP_CONTENT_DIR)) . "/backups",
974
+ trim(basename(WP_CONTENT_DIR)) . "/uploads/wp-clone",
975
+ trim(basename(WP_CONTENT_DIR)) . "/uploads/db-backup",
976
+ trim(basename(WP_PLUGIN_DIR)) . "/cache",
977
  );
978
+ manual_debug('', 'beforeExclude', 0);
979
  if((!empty($exclude_file_size))||(!empty($exclude_extensions)))
980
  {
981
+ /* //removing files which are larger than the specified size
982
  $total_files_array = get_all_files_from_dir(ABSPATH, $remove);
983
  $files_excluded_by_size = array();
984
  foreach($total_files_array as $key => $value)
1015
  }
1016
  }
1017
  }
1018
+ $remove = array_merge($remove, $files_excluded_by_size); */
1019
  }
1020
  $exclude = array_merge($exclude, $remove);
1021
+ manual_debug('', 'afterExclude', 0);
1022
  //Exclude paths
1023
 
1024
 
1073
  $result_arr['response_data']['nextCount'] = 0;
1074
  $result_arr['status'] = 'processing';
1075
  $result_arr['category'] = $category;
1076
+ /* $include_data = array (
1077
+ 0 => 'F:\\wamp\\www\\plugin_for_bugs/wp-new-dark/',
1078
+ ); */
1079
+ /* $include_data = array (
1080
+ 0 => '/mnt/weba/e2/89/53672689/htdocs/wordpress_v2/wp-content/uploads/2015/03/',
1081
+ ); */
1082
  $result_arr['response_data']['include_data'] = $include_data;
1083
  $result_arr['response_data']['exclude_data'] = $exclude_data;
1084
  $result_arr['response_data']['backup_file'] = $backup_file;
1097
  function backupFilesZIP($historyID)
1098
  {
1099
  $this -> hisID = $historyID;
 
1100
  $files_with_error = array();
1101
  $files_excluded_by_size = array();
 
1102
  //get the backup settings values from options table
1103
  $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
1104
  $backup_settings_values = $this -> backup_settings_vals;
1116
  $exclude_file_size = $requestParams['args']['exclude_file_size'];
1117
  $exclude_extensions = $requestParams['args']['exclude_extensions'];
1118
  $zip_split_size = $requestParams['args']['zip_split_size'];
1119
+ $v_offset = 0;
1120
  if(isset($backup_settings_values['dbFileHashValue']) && !empty($backup_settings_values['dbFileHashValue'][$historyID]))
1121
  {
1122
  $dbFileHashValue = $backup_settings_values['dbFileHashValue'][$historyID];
1144
  $p_filedescr_list = isset($responseParams['response_data']['p_filedescr_list']) ? $responseParams['response_data']['p_filedescr_list'] : array();
1145
  $zip_split_part = isset($responseParams['response_data']['zip_split_part']) ? $responseParams['response_data']['zip_split_part'] : 0;
1146
  $is_new_zip = isset($responseParams['response_data']['is_new_zip']) ? $responseParams['response_data']['is_new_zip'] : 0;
1147
+ $get_file_list = isset($responseParams['response_data']['get_file_list']) ? $responseParams['response_data']['get_file_list'] : '';
1148
+ $next_file_index = isset($responseParams['response_data']['next_file_index']) ? $responseParams['response_data']['next_file_index'] : 0;
1149
  /* if(empty($zip_split_part))
1150
  {
1151
  $zip_split_part = 1;
1152
  } */
1153
+ //If the zip file exceeds ~1.6 GB we are splitting the zip file into many parts.
1154
  if((!empty($zip_split_part))&&(!empty($is_new_zip)))
1155
  {
1156
  if(strpos($backup_file, '_iwp_part_'))
1164
  $backup_url = substr($backup_url, 0, strpos($backup_url, '.zip')).'_iwp_part_'.$zip_split_part.'.zip';
1165
  }
1166
  }
1167
+ if(empty($zip_split_part))
1168
  {
1169
  $zip_split_part = 0;
1170
  }
1171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1172
  include_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
 
 
 
1173
  $returnArr = array();
 
 
 
 
1174
  if((($nextCount != 0)||($category == 'fileZipAfterDBZip'))&&(empty($is_new_zip)))
1175
  {
1176
  unset($responseParams);
1177
  $initialFileSize = iwp_mmb_get_file_size($backup_file)/1024/1024;
1178
  $returnArr = $this->backupFilesNext($include_data, $exclude_data, $backup_file, $backup_url, $nextCount, $p_filedescr_list, $account_info, $files_with_error, $files_excluded_by_size, $zip_split_part);
1179
  $fileNextTimeTaken = microtime(true) - $this->iwpScriptStartTime;
1180
+ echo "<br>iwpmsg Total file size".(iwp_mmb_get_file_size($backup_file)/1024/1024);
1181
  $file_size_in_this_call = (iwp_mmb_get_file_size($backup_file)/1024/1024) - $initialFileSize;
1182
+ echo "<br>iwpmsg file size in this call".$file_size_in_this_call;
1183
+ echo "<br>iwpmsg Time taken in this call ".$fileNextTimeTaken."<br>";
1184
  if(($file_size_in_this_call == 0) && !(is_array($returnArr) && !empty($returnArr['error'])) && !(is_array($returnArr) && !empty($returnArr['isGetFileList'])))
1185
  {
1186
  return array( 'error' => 'Zip-error: Unable to zip', 'error_code' => 'zip_error_unable_to_zip');
1198
  $archive = new IWPPclZip($backup_file);
1199
  if($category == 'dbZip')
1200
  {
1201
+ if(empty($get_file_list))
1202
  {
1203
+ manual_debug('', 'beforeGettingFileList', 0);
1204
  //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1205
  $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //darkCode set the file block size here .. static values
1206
+ //$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1207
+ //unset($p_filedescr_list_array['p_filedescr_list']);
1208
+ $next_file_index = $p_filedescr_list_array['next_file_index'];
1209
+ manual_debug('', 'afterGettingFileList', 0);
1210
  if($p_filedescr_list_array['status'] == 'partiallyCompleted')
1211
  {
1212
+ echo('iwpmsg fileListDBInMultiPart');
1213
  $result_arr = array();
1214
  $result_arr = $responseParams;
1215
  $result_arr['nextFunc'] = 'backupFilesZIP';
1216
  $result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1217
  unset($p_filedescr_list);
1218
+ $result_arr['response_data']['next_file_index'] = $next_file_index;
1219
  $result_arr['response_data']['complete_folder_list'] = $p_filedescr_list_array['complete_folder_list'];
1220
  unset($p_filedescr_list_array);
1221
  $this->statusLog($this -> hisID, array('stage' => 'gettingFileList', 'status' => 'processing', 'statusMsg' => 'gettingFileListInMultiCall','responseParams' => $result_arr));
1236
  }
1237
  else
1238
  {
1239
+ if(empty($get_file_list))
1240
  {
1241
+ manual_debug('', 'beforeGettingFileList', 0);
1242
+
1243
+ //$p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
1244
 
1245
+ $p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE, $exclude_file_size, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT, $exclude_extensions, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID);
1246
+
1247
+ manual_debug('', 'afterGettingFileList', 0);
1248
+ //$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1249
+ //unset($p_filedescr_list_array['p_filedescr_list']);
1250
  $next_file_index = $p_filedescr_list_array['next_file_index'];
1251
 
 
 
 
 
 
 
1252
  if($p_filedescr_list_array['status'] == 'partiallyCompleted')
1253
  {
1254
+ echo('iwpmsg fileListInMultiPart');
1255
  $result_arr = array();
1256
  $result_arr = $responseParams;
1257
  $result_arr['nextFunc'] = 'backupFilesZIP';
1286
  );
1287
  $v_result = 1;
1288
  $v_header = array();
1289
+ $v_header_list = array();
1290
+ $v_nb = get_iwp_files_db_count('headers');
1291
+ $v_nb_initial = get_iwp_files_db_count('headers');
1292
  $p_result_list = array();
 
 
 
1293
  //$nextCount = 0;
1294
  $archive->privOpenFd('wb');
1295
  $p_filedescr_list_omitted = array();
1296
  $omitted_flag = '';
1297
+ //$p_filedescr_list_size = sizeof($p_filedescr_list);
1298
+ //$p_filedescr_list_size = $p_filedescr_list_array['total_FL_count'];
1299
+ $p_filedescr_list_size = get_iwp_files_db_count('files');
1300
+ echo "iwpmsg loopStarted";
1301
+ echo "iwpmsg ". $p_filedescr_list_size;
1302
+ manual_debug('', 'beforeStartingLoop', 0);
1303
  for ($j=$nextCount; ($j<$p_filedescr_list_size) && ($v_result==1); $j++) {
1304
+
1305
+ //new method of getting fileList
1306
+ $p_filedescr_list[$j] = get_from_iwp_files_db($j);
1307
+
1308
  // ----- Format the filename
1309
  $p_filedescr_list[$j]['filename'] = IWPPclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
1310
 
1318
  // ----- Check the filename
1319
  if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
1320
  && (!file_exists($p_filedescr_list[$j]['filename']))) {
1321
+ echo 'iwpmsg FILE DOESNT EXIST';
1322
  }
1323
 
1324
  // ----- Look if it is a file or a dir with no all path remove option
1332
  || !$p_options[IWP_PCLZIP_OPT_REMOVE_ALL_PATH]))
1333
  ) {
1334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1335
  // ----- Add the file
1336
  $v_result = $archive->privAddFile($p_filedescr_list[$j], $v_header, $p_options);
1337
+ //saving the header in DB
1338
+ $cur_file = $p_filedescr_list[$j]['filename'];
1339
+ if($v_result == 1){
1340
+ $header_save_result = save_in_iwp_files_db(0, array(), $v_header, 'update', $v_nb);
1341
+ }
1342
+ else{
1343
+ $header_save_result = save_in_iwp_files_db(0, array(), array('error' => 1), 'update', $v_nb);
1344
+ $files_with_error[] = $cur_file;
1345
+ }
1346
+ if(is_array($header_save_result) && isset($header_save_result['error'])){
1347
+ return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-error: Error while updating the file "'.$cur_file.'" in the file list table.', 'statusCode' => 'zip_error_while_updating_file_list_table'));
1348
+ }
1349
+ $v_nb++;
1350
+ unset($p_filedescr_list);
1351
 
1352
  // ----- Store the file infos
1353
+ //$v_header_list[$v_nb++] = $v_header;
1354
  $nextCount = $j+1;
1355
 
1356
+ //unset($v_header_list[$v_nb++]);
1357
+
1358
  if ($v_result != 1) {
1359
+ echo 'iwpmsg Error zipping this file'.$cur_file;
1360
+ $files_with_error[] = $cur_file;
1361
  if($v_result == -10)
1362
  {
1363
+ return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-error: Error compressing the file "'.$cur_file.'".Try excluding this file and try again.', 'statusCode' => 'zip_error_while_compressing_file'));
1364
  }
1365
  continue;
1366
  //return $v_result;
1367
  }
1368
  }
1369
 
1370
+ $total_time = microtime(true) - $this->iwpScriptStartTime;
 
 
1371
  //if(($total_time > $file_loop_break_time)||) //darkCode static Values
1372
  $buffer_size = $zip_split_size*1024*1024 - 3*1024*1024*$file_block_size;
1373
  $is_new_zip = false;
1383
  //iwp_mmb_print_flush("|");
1384
  iwp_mmb_auto_print("multiCallZip");
1385
  echo("|");
1386
+ manual_debug('', "zipLoop", 1000);
1387
  }
1388
+ echo "iwpmsg loopEnded";
1389
+ manual_debug('', 'afterEndingLoop', 0);
1390
  $v_offset = @ftell($archive->zip_fd);
1391
+ $size_of_v_header_list = 0;
1392
+ //$v_header_list = $p_result_list;
1393
  //$nextCount = sizeof($p_result_list);
1394
+ manual_debug('', 'beforeStartingHeaderWrite', 0);
1395
+ $total_header_count = get_iwp_files_db_count('headers');
1396
+ //for ($i=$v_nb_initial, $v_count=$v_nb_initial; $i<sizeof($v_header_list); $i++)
1397
+ for ($i=$v_nb_initial, $v_count=0; $i<$total_header_count; $i++)
1398
  {
1399
+ //getting header list from db
1400
+ $v_header_list[$i] = get_from_iwp_files_db($i, 'thisFileHeader');
1401
+
1402
  // ----- Create the file header
1403
  if ($v_header_list[$i]['status'] == 'ok') {
1404
  if (($v_result = $archive->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
1411
 
1412
  // ----- Transform the header to a 'usable' info
1413
  $archive->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1414
+ unset($v_header_list);
1415
+ unset($p_result_list);
1416
+
1417
+ //manual_debug('', "duringEachHeaderWrite", 100);
1418
  }
1419
+ manual_debug('', 'afterHeaderWrite', 0);
1420
  $v_size = @ftell($archive->zip_fd)-$v_offset;
1421
  $archive->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment);
1422
  $archive->privCloseFd();
1423
+ echo 'iwpmsg next Count -'.$nextCount;
1424
+ //if(($nextCount == sizeof($p_filedescr_list)+1)||($nextCount == sizeof($p_filedescr_list)))
1425
+ if(($nextCount == get_iwp_files_db_count('files')+1)||($nextCount == get_iwp_files_db_count('files')))
1426
  {
1427
  $nextCount = "completed";
1428
  $status = "completed";
1431
  {
1432
  $status = "partiallyCompleted";
1433
  }
1434
+ manual_debug('', 'afterWholeHeaderWrite', 0);
1435
  $result_arr = array();
1436
 
1437
  //return $p_result_list;
1447
  $result_arr['response_data']['files_with_error'] = $files_with_error;
1448
  $result_arr['response_data']['files_excluded_by_size'] = $files_excluded_by_size;
1449
  $result_arr['response_data']['is_new_zip'] = $is_new_zip;
1450
+ $result_arr['response_data']['get_file_list'] = 'completed';
1451
  //$result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1452
  $result_arr['response_data']['zip_split_part'] = $zip_split_part;
1453
  $resArray = array (
1472
  }
1473
  if($status == 'partiallyCompleted')
1474
  {
1475
+ echo 'iwpmsg filesNextCount: '.$nextCount;
1476
+ echo 'iwpmsg totalFilesCount: '.get_iwp_files_db_count('files');
1477
  $result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1478
  unset($p_filedescr_list);
1479
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'backupFileSingleCall'.$status,'nextFunc' => 'backupFilesZIP', 'responseParams' => $result_arr));
1497
  }
1498
  else
1499
  {
1500
+ refresh_iwp_files_db(); //truncating table on final call.
1501
  $paths = array();
1502
  $tempPaths = array();
1503
 
1532
  $paths['task_results'][$historyID] = $tempPath;
1533
  if(empty($account_info))
1534
  {
1535
+ $tempPath['server']['dbHost'] = DB_HOST;
1536
+ $tempPath['server']['dbName'] = DB_NAME;
1537
+ $tempPath['server']['dbUser'] = DB_USER;
1538
+ $tempPath['server']['dbPassword'] = DB_PASSWORD;
1539
+ $resArray['task_results'][$historyID] = $tempPath;
1540
+
1541
  $result_arr['nextFunc'] = 'backupFilesZIPOver';
1542
  }
1543
  else
1586
  }
1587
  }
1588
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1589
  function get_total_files_size($backup_files)
1590
  {
1591
  if(is_array($backup_files))
1606
  function backupFilesNext($include_data, $exclude_data, $backup_file, $backup_url, $nextCount, $p_filedescr_list = array(), $account_info = array(), $files_with_error = array(), $files_excluded_by_size = array(), $zip_split_part = 0)
1607
  {
1608
  $historyID = $this -> hisID;
 
1609
  $is_new_zip = false;
1610
  $backup_settings_values = $this -> backup_settings_vals;
1611
  //$file_block_size = $backup_settings_values['file_block_size'];
1631
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
1632
  $category = $responseParams['category']; //Am getting the category to perform the dbZip actions
1633
 
1634
+ $get_file_list = isset($responseParams['response_data']['get_file_list']) ? $responseParams['response_data']['get_file_list'] : '';
1635
+
1636
+
1637
  $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'processing', 'statusMsg' => 'backupMultiCallInitiated', 'responseParams' => $responseParams));
1638
 
1639
  $time = microtime(true);
1645
  {
1646
  if(empty($p_filedescr_list)||($nextCount == 0))
1647
  {
1648
+ if($get_file_list != 'completed'){
1649
  $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID);//darkCode set the file block size here .. static values
1650
  $p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1651
+ $next_file_index = $p_filedescr_list_array['next_file_index'];
1652
 
1653
  if($p_filedescr_list_array['status'] == 'partiallyCompleted')
1654
  {
1658
  $result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
1659
  $result_arr['response_data']['next_file_index'] = $p_filedescr_list_array['next_file_index'];
1660
  $result_arr['response_data']['complete_folder_list'] = $p_filedescr_list_array['complete_folder_list'];
1661
+ unset($p_filedescr_list_array);
1662
  $this->statusLog($this -> hisID, array('stage' => 'gettingFileList', 'status' => 'processing', 'statusMsg' => 'gettingFileListInMultiCall','responseParams' => $result_arr));
1663
 
1664
  $resArray = array();
1676
  }
1677
  }
1678
  }
1679
+ }
1680
  else
1681
  {
1682
  if(empty($p_filedescr_list)||($nextCount == 0))
1683
  {
1684
+ if($get_file_list != 'completed'){
1685
+ //$p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
1686
+
1687
+ $p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE, $exclude_file_size, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT, $exclude_extensions, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID);
1688
 
1689
  $p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1690
 
1700
  $result_arr['response_data']['complete_folder_list'] = $p_filedescr_list_array['complete_folder_list'];
1701
 
1702
  $this->statusLog($this -> hisID, array('stage' => 'gettingFileList', 'status' => 'processing', 'statusMsg' => 'gettingFileListInMultiCall','responseParams' => $result_arr));
 
1703
  unset($p_filedescr_list_array);
1704
  $resArray = array();
1705
  $resArray['status'] = 'partiallyCompleted';
1717
  }
1718
  }
1719
  }
1720
+ }
1721
  $archive->privDisableMagicQuotes();
1722
  if (($v_result=$archive->privOpenFd('rb+')) != 1)
1723
  {
1731
  $v_central_dir = array();
1732
  if (($v_result = $archive->privReadEndCentralDir($v_central_dir)) != 1)
1733
  {
1734
+ echo 'iwpmsg error2';
1735
  $archive->privCloseFd();
1736
  $archive->privSwapBackMagicQuotes();
1737
  if(is_array($v_result) && !empty($v_result['error']))
1755
  {
1756
  $archive->privCloseFd();
1757
  $archive->privSwapBackMagicQuotes();
1758
+ echo 'iwpmsg error3';
1759
  return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Unable to open temporary file', 'statusCode' => 'unable_to_open_temporary_file')); // ----- Return
1760
 
1761
  }
1799
  $v_header = array();
1800
  $p_result_list = array();
1801
  $v_header_list = array();
1802
+ $v_nb = $v_nb_initial = get_iwp_files_db_count('headers');
1803
  $v_comment = '';
1804
  //$nextCount = $_REQUEST['nextCount'];
1805
  $omitted_flag = '';
1806
  $nextCountHere = 0;
1807
+ $p_filedescr_list_size = get_iwp_files_db_count('files');
 
1808
  iwp_mmb_print_flush("loopStarted");
1809
+ echo $p_filedescr_list_size;
1810
+ manual_debug('', 'beforeStartingNextLoop', 0);
1811
+ $p_filedescr_list = array();
1812
  for ($j=($nextCount); ($j<$p_filedescr_list_size) && ($v_result==1); $j++) {
1813
+
1814
+ //new method of getting fileList
1815
+ $p_filedescr_list[$j] = get_from_iwp_files_db($j);
1816
+
1817
  // ----- Format the filename
1818
+ $p_filedescr_list[$j]['filename'] = IWPPclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
 
 
1819
 
1820
  // ----- Skip empty file names
1821
  // TBC : Can this be possible ? not checked in DescrParseAtt ?
1854
  } */
1855
 
1856
  // ----- Add the file
1857
+ echo "|";
1858
+ //global $cur_file;
1859
+ $cur_file = $p_filedescr_list[$j]['filename'];
1860
  $v_result = $archive->privAddFile($p_filedescr_list[$j], $v_header, $p_options);
1861
+ //saving the header in DB
1862
+ if($v_result == 1){
1863
+ $header_save_result = save_in_iwp_files_db(0, array(), $v_header, 'update', $v_nb);
1864
+ }
1865
+ else{
1866
+ $header_save_result = save_in_iwp_files_db(0, array(), array('error' => 1), 'update', $v_nb);
1867
+ }
1868
+ if(is_array($header_save_result) && isset($header_save_result['error'])){
1869
+ return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-error: Error while updating the file "'.$cur_file.'" in the file list table.', 'statusCode' => 'zip_error_while_updating_file_list_table'));
1870
+ }
1871
+ $v_nb++;
1872
+ unset($p_filedescr_list);
1873
  // ----- Store the file infos
1874
+ //$v_header_list[$v_nb++] = $v_header;
1875
 
1876
  if ($v_result != 1) {
1877
  //$this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'SomeError1'));
1878
+ echo "iwpmsg error zipping this file:".$cur_file;
1879
+ echo 'iwpmsg errorCode - '.$v_result;
1880
+ $files_with_error[] = $cur_file;
1881
  if($v_result == -10)
1882
  {
1883
+ return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-error: Error compressing the file "'.$cur_file.'".Try excluding this file and try again.', 'statusCode' => 'zip_error_while_compressing_file'));
1884
  }
1885
  continue;
1886
  //return $v_result;
1897
  {
1898
  $zip_split_part += 1;
1899
  $is_new_zip = true;
1900
+ echo "iwpmsg splitting into new zip";
1901
  }
1902
  break;
1903
  }
1904
  //iwp_mmb_print_flush("|");
1905
  iwp_mmb_auto_print("multiCallZip");
1906
  //echo "|";
1907
+ manual_debug('', "zipLoop", 1000);
1908
  }
1909
+ echo "iwpmsg loopEnded";
1910
+ manual_debug('', 'afterNextLoop', 0);
1911
  $v_offset = @ftell($archive->zip_fd);
1912
  $v_size = $v_central_dir['size'];
1913
  /* while ($v_size != 0)
1931
  $v_buffer = fread($v_zip_temp_fd, $v_central_dir['size']);
1932
  $writeResult = fwrite($archive->zip_fd, $v_buffer);
1933
 
1934
+ manual_debug('', 'beforeStartingNextHeaderWrite', 0);
1935
 
1936
+ $v_header_list = array();
1937
  //array_pop($v_header_list);
1938
  //$v_header_list = $p_result_list;
1939
  // ----- Create the Central Dir files header
1940
+ $total_header_count = get_iwp_files_db_count('headers');
1941
+ for ($i=$v_nb_initial, $v_count=0; $i<$total_header_count; $i++)
1942
  {
1943
+ //getting header list from db
1944
+ $v_header_list[$i] = get_from_iwp_files_db($i, 'thisFileHeader');
1945
+
1946
  // ----- Create the file header
1947
  if ($v_header_list[$i]['status'] == 'ok') {
1948
  if (($v_result = $archive->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
1949
+ echo 'iwpmsg error4';
1950
  fclose($v_zip_temp_fd);
1951
  $archive->privCloseFd();
1952
  @unlink($v_zip_temp_name);
1959
 
1960
  // ----- Transform the header to a 'usable' info
1961
  $archive->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1962
+ unset($v_header_list);
1963
+ unset($p_result_list);
1964
  }
1965
+ manual_debug('', 'afterNextHeaderWrite', 0);
1966
  // ----- Calculate the size of the central header
1967
  $v_size = @ftell($archive->zip_fd)-$v_offset;
1968
 
1970
  if (($v_result = $archive->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
1971
  {
1972
  // ----- Reset the file list
1973
+ echo 'iwpmsg error5';
1974
  unset($v_header_list);
1975
  $archive->privSwapBackMagicQuotes();
1976
  return $this->statusLog($historyID, array('stage' => 'backupFilesMultiCall', 'status' => 'error', 'statusMsg' => 'Zip-Error: Error while writing footer', 'statusCode' => 'zip_error_while_writing_footer'));
2002
 
2003
  $nextCount = $nextCountHere;
2004
 
2005
+ $size_file_des = get_iwp_files_db_count('files');
2006
  if($nextCount == $size_file_des)
2007
  //if(true)
2008
  {
2013
  else{
2014
  $status = "partiallyCompleted";
2015
  }
2016
+ manual_debug('', 'afterWholeHeaderWrite', 0);
2017
  $result_arr = array();
2018
  $result_arr['response_data']['nextCount'] = $nextCount;
2019
  $result_arr['status'] = $status;
2028
  $result_arr['response_data']['is_new_zip'] = $is_new_zip;
2029
  $result_arr['response_data']['files_with_error'] = $files_with_error;
2030
  $result_arr['response_data']['files_excluded_by_size'] = $files_excluded_by_size;
2031
+ $result_arr['response_data']['get_file_list'] = 'completed';
2032
 
2033
  //$result_arr['response_data']['p_filedescr_list'] = $p_filedescr_list;
2034
  $resArray = array (
2051
  }
2052
  if($status == "partiallyCompleted")
2053
  {
2054
+ echo 'iwpmsg filesNextCount: '.$nextCount;
2055
+ echo 'iwpmsg totalFilesCount: '.$p_filedescr_list_size;
2056
+ $result_arr['response_data']['p_filedescr_list'] = array();
2057
  unset($p_filedescr_list);
2058
  $this->statusLog($this -> hisID, array('stage' => 'backupFilesMultiCall', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status,'nextFunc' => 'backupFilesZIP', 'responseParams' => $result_arr));
2059
  unset($result_arr);
2073
  $resArray['status'] = 'partiallyCompleted';
2074
  $result_arr['nextFunc'] = 'backupFiles';
2075
  $result_arr['status'] = 'partiallyCompleted';
2076
+ $result_arr['response_data']['get_file_list'] = '';
2077
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status,'nextFunc' => 'backupFiles', 'responseParams' => $result_arr));
2078
  }
2079
  else
2080
  {
2081
 
2082
  //$this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status, 'responseParams' => $result_arr));
2083
+ refresh_iwp_files_db(); //truncating table on final call.
2084
+ $paths = array();
2085
  $tempPaths = array();
2086
 
2087
  $backup_files_array = $this->get_files_array_from_iwp_part($backup_file);
2119
  {
2120
  //this is where the call goes to upload after backup zip completion ..
2121
  $resArray['status'] = 'completed';
2122
+
2123
+ $tempPath['server']['dbHost'] = DB_HOST;
2124
+ $tempPath['server']['dbName'] = DB_NAME;
2125
+ $tempPath['server']['dbUser'] = DB_USER;
2126
+ $tempPath['server']['dbPassword'] = DB_PASSWORD;
2127
+
2128
+ $resArray['task_results'][$historyID] = $tempPath;
2129
+
2130
  $result_arr['nextFunc'] = 'backupFilesZIPOver';
2131
  $result_arr['status'] = 'completed';
2132
  }
2137
  $result_arr['nextFunc'] = 'backup_uploads';
2138
  $result_arr['status'] = 'partiallyCompleted';
2139
  $result_arr['actual_file_size'] = $size;
2140
+ $result_arr['response_data']['backup_file'] = $backup_file;
2141
  }
2142
 
2143
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'completed', 'statusMsg' => 'nextCall'.$status, 'responseParams' => $result_arr,'task_result' => $paths));
2171
 
2172
  }
2173
  }
 
 
2174
  return $resArray;
2175
 
2176
  }
2224
  }
2225
  }
2226
 
 
 
2227
  function getHashValuesArray($p_filedescr_list)
2228
  {
2229
  $hashValues = array();
2414
  {
2415
  if($statusArray['status'] == 'error')
2416
  {
2417
+ refresh_iwp_files_db(); //truncating the file list table on error
2418
+
2419
  $returnParams = array();
2420
  $returnParams['parentHID'] = $historyID;
2421
  $returnParams['backupRowID'] = $insertID;
2681
  {
2682
  $args['backup_file'] = $value;
2683
  iwp_mmb_print_flush('Amazon S3 download: Start '.$key);
2684
+ if(is_new_s3_compatible()){
2685
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
2686
+ $new_s3_obj = new IWP_MMB_S3_MULTICALL();
2687
+ $backup_file[] = $new_s3_obj->get_amazons3_backup($args);
2688
+ }
2689
+ else{
2690
+ $backup_file[] = $this->get_amazons3_backup_bwd_comp($args);
2691
+ }
2692
  iwp_mmb_print_flush('Amazon S3 download: End '.$key);
2693
  if ($backup_file[$key] == false) {
2694
  return array(
2949
 
2950
  }
2951
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2952
  //Backup file will be extracted to a temporary path
2953
  if(!is_array($backup_file))
2954
  {
3177
  global $wpdb;
3178
 
3179
  $table = $GLOBALS['table_prefix'].'iwp_backup_status';
3180
+ $wpdb->query("SHOW TABLES LIKE '".$table."'");
3181
+ if($wpdb->num_rows == 1){
 
3182
  $delete = $wpdb->query("DROP TABLE '".$table."' ");
3183
  }
3184
 
3345
  function restore_db($new_temp_folder)
3346
  {
3347
  global $wpdb;
3348
+ $paths = $this->check_mysqli_paths();
3349
  $file_path = $new_temp_folder . '/iwp_db';
3350
  @chmod($file_path,0755);
3351
  $file_name = glob($file_path . '/*.sql');
3456
  }
3457
 
3458
  ### Function: Auto Detect MYSQL and MYSQL Dump Paths
3459
+ function check_mysqli_paths()
3460
  {
3461
  global $wpdb;
3462
  $paths = array(
3609
 
3610
  $reqs['Unzip']['pass'] = true;
3611
 
3612
+ $paths = $this->check_mysqli_paths();
3613
 
3614
  if (!empty($paths['mysqldump'])) {
3615
  $reqs['MySQL Dump']['status'] = $paths['mysqldump'];
3921
  return $backup_files_base_name;
3922
  }
3923
 
3924
+ function postUploadVerification(&$obj, $backup_file, $destFile, $type = "", $as3_bucket = "", $as3_access_key = "", $as3_secure_key = "", $as3_bucket_region = "")
3925
  {
3926
  $actual_file_size = iwp_mmb_get_file_size($backup_file);
3927
  $size1 = $actual_file_size-((0.1) * $actual_file_size);
3941
  }
3942
  else if($type == "amazons3")
3943
  {
3944
+ if(is_new_s3_compatible()){
3945
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
3946
+ $new_s3_obj = new IWP_MMB_S3_MULTICALL();
3947
+ return $new_s3_obj->postUploadS3Verification($backup_file, $destFile, $type, $as3_bucket, $as3_access_key, $as3_secure_key, $as3_bucket_region);
 
 
 
 
 
 
 
 
 
 
 
 
3948
  }
3949
+ else{
3950
+ return $this->postUploadS3VerificationBwdComp($backup_file, $destFile, $type, $as3_bucket, $as3_access_key, $as3_secure_key, $as3_bucket_region, $obj, $actual_file_size);
 
3951
  }
3952
  }
3953
  else if($type == "ftp")
3972
  }
3973
  }
3974
 
3975
+ function postUploadS3VerificationBwdComp($backup_file, $destFile, $type = "", $as3_bucket = "", $as3_access_key = "", $as3_secure_key = "", $as3_bucket_region = "", &$obj, $actual_file_size){
3976
+ $response = $obj -> if_object_exists($as3_bucket, $destFile);
3977
+ if($response == true)
3978
+ {
3979
+ $meta = $obj -> get_object_headers($as3_bucket, $destFile);
3980
+ $cfu_obj = new CFUtilities;
3981
+ $meta_response_array = $cfu_obj->convert_response_to_array($meta);
3982
+ $s3_filesize = $meta_response_array['header']['content-length'];
3983
+ echo "S3 fileszie during verification - ".$s3_filesize;
3984
+ if((($s3_filesize >= $size1 && $s3_filesize <= $actual_file_size) || ($s3_filesize <= $size2 && $s3_filesize >= $actual_file_size) || ($s3_filesize == $actual_file_size)) && ($s3_filesize != 0))
3985
+ {
3986
+ return true;
3987
+ }
3988
+ else
3989
+ {
3990
+ return false;
3991
+ }
3992
+ }
3993
+ else
3994
+ {
3995
+ return false;
3996
+ }
3997
+ }
3998
 
3999
  function remove_ftp_backup($args)
4000
  {
4453
 
4454
  */
4455
 
4456
+ function amazons3_backup_bwd_comp($historyID , $args='' )
 
4457
  {
4458
  $s3StartTime = $this->iwpScriptStartTime;
4459
  $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
4466
  {
4467
  $s3_retrace_count = 0;
4468
  }
 
 
 
4469
  //get the settings by other method
4470
  $requestParams = $this -> getRequiredData($historyID,"requestParams");
4471
  $upload_loop_break_time = $requestParams['account_info']['upload_loop_break_time']; //darkcode changed
4481
  @set_time_limit(0);
4482
  $this -> hisID = $historyID;
4483
 
 
 
 
 
 
 
4484
  $uploadLoopCount = 0;
4485
  $upload_id = 'start';
4486
  $partsArray = array();
4488
  $retrace = 'notSet';
4489
  $doComplete = false;
4490
 
 
4491
  if($args == '')
4492
  {
4493
  //on the next call $args would be ''
4533
  $backup_settings_values['s3_retrace_count'][$historyID] = $s3_retrace_count;
4534
  update_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
4535
 
 
 
4536
  }
4537
  else
4538
  {
4540
  }
4541
  }
4542
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4543
  if (!$this->iwp_mmb_function_exists('curl_init')) {
4544
  return array(
4545
  'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
4546
  'partial' => 1, 'error_code' => 'cannot_use_s3_enable_curl_first'
4547
  );
4548
  }
4549
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3_bwd_comp/sdk.class.php');
4550
 
4551
  $tempArgs = $args;
4552
  extract($args);
4695
  $s3ChunkCount = 0;
4696
  $reloop = false;
4697
  $reloopCount = 0;
4698
+ $status = '';
4699
  do
4700
  {
4701
  $uploadLoopCount = 0;
4826
  else
4827
  {
4828
  //to continue zip split parts
4829
+ $status = 'partiallyCompleted';
4830
  $chunkResult = array();
4831
  $chunkResult['partsArray'] = array();
4832
  $chunkResult['nextPart'] = 1;
4931
  }
4932
  }
4933
 
4934
+ function remove_amazons3_backup_bwd_comp($args)
 
 
4935
  {
4936
  if ($this->iwp_mmb_function_exists('curl_init')) {
4937
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3_bwd_comp/sdk.class.php');
4938
  extract($args);
4939
 
4940
  if(!is_array($backup_file))
4977
  }
4978
  }
4979
 
4980
+ function get_amazons3_backup_bwd_comp($args)
4981
  {
4982
  if ($this->iwp_mmb_function_exists('curl_init')) {
4983
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3_bwd_comp/sdk.class.php');
4984
  extract($args);
4985
  $temp = '';
4986
  try{
5060
  $downloadUrl = $file->getDownloadUrl();
5061
 
5062
  $temp = wp_tempnam('iwp_temp_backup.zip');
 
5063
 
5064
  try
5065
  {
5098
 
5099
  */
5100
 
5101
+ function google_drive_backup($historyID = 0, $args = '', $uploadid = null, $offset = 0){
 
5102
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Client.php');
5103
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Http/MediaFileUpload.php');
5104
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Service/Drive.php');
5120
  $resumeURI = false;
5121
  $current_file_num = 0;
5122
 
5123
+ if($args == ''){
 
5124
  //on the next call $args would be ''
5125
  //set $args, $uploadid, $offset from the DB
5126
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
5152
  $refreshToken = $accessToken['refresh_token'];
5153
  $backup_file = $args['backup_file'];
5154
 
5155
+ if(!is_array($backup_file)){
 
5156
  $temp_backup_file = $backup_file;
5157
  $backup_file = array();
5158
  $backup_file[] = $temp_backup_file;
5159
  }
5160
 
5161
+ if(is_array($backup_file)){
 
5162
  $backup_files_count = count($backup_file);
5163
  $backup_file = $backup_file[$current_file_num];
5164
  }
5165
 
5166
+ try{
 
5167
  $client->refreshToken($refreshToken);
5168
  }
5169
+ catch(Exception $e){
 
5170
  echo 'google Error ', $e->getMessage(), "\n";
5171
  return array("error" => $e->getMessage(), "error_code" => "google_error_backup_refresh_token");
5172
  }
5178
  $service = new IWP_google_Service_Drive($client);
5179
 
5180
  //create iwp folder folder if it is not present
5181
+ try{
 
5182
  $parameters = array();
5183
+ $parameters['q'] = "title = 'infinitewp' and trashed = false and 'root' in parents and 'me' in owners and mimeType= 'application/vnd.google-apps.folder'";
5184
  $files = $service->files->listFiles($parameters);
5185
  $list_result = array();
5186
  $list_result = array_merge($list_result, $files->getItems());
5187
  $list_result = (array)$list_result;
5188
 
5189
+ if(empty($list_result)){
 
5190
  $file = new IWP_google_Service_Drive_DriveFile();
5191
  $file->setTitle('infinitewp');
5192
  $file->setMimeType('application/vnd.google-apps.folder');
5194
  $createdFolder = $service->files->insert($file, array(
5195
  'mimeType' => 'application/vnd.google-apps.folder',
5196
  ));
5197
+ if($createdFolder){
 
5198
  $createdFolder = (array)$createdFolder;
5199
  $iwp_folder_id = $createdFolder['id'];
5200
  }
5201
  }
5202
+ else{
 
5203
  foreach($list_result as $k => $v){
5204
  $iwp_folder_id = $v->id;
5205
  }
5210
  }
5211
 
5212
  //create sub folder by site name
5213
+ if($create_sub_folder){
 
5214
  $parameters = array();
5215
+ $parameters['q'] = "title = '$sub_folder_name' and trashed = false and '$iwp_folder_id' in parents and 'me' in owners and mimeType = 'application/vnd.google-apps.folder'";
5216
+ //$parameters['corpus'] = "DEFAULT";
5217
  $files = $service->files->listFiles($parameters);
5218
  $list_result = array();
5219
  $list_result = array_merge($list_result, $files->getItems());
5220
  $list_result = (array)$list_result;
5221
 
5222
+ if(empty($list_result)){
 
5223
  $file = new IWP_google_Service_Drive_DriveFile();
5224
  $file->setTitle($sub_folder_name);
5225
  $file->setMimeType('application/vnd.google-apps.folder');
5238
  $sub_folder_id = $createdFolder['id'];
5239
  }
5240
  }
5241
+ else{
5242
+ foreach($list_result as $k => $v){
5243
+ $sub_folder_id = $v->id;
5244
+ }
 
5245
  }
5246
  }
5247
 
5252
 
5253
  // Set the Parent Folder on Google Drive
5254
  $parent = new IWP_google_Service_Drive_ParentReference();
5255
+ if(empty($sub_folder_id)){
 
5256
  $parent->setId($iwp_folder_id);
5257
  }
5258
+ else{
 
5259
  $parent->setId($sub_folder_id);
5260
  }
5261
  $file->setParents(array($parent));
5262
 
5263
  $gDriveID = '';
5264
+ try{
5265
+ if(false){
 
 
5266
  //single upload
5267
  $data = file_get_contents($backup_file);
5268
  $createdFile = (array)$service->files->insert($file, array(
5274
 
5275
  //multipart upload
5276
 
5277
+ if(true){
 
5278
  // Call the API with the media upload, defer so it doesn't immediately return.
5279
  $client->setDefer(true);
5280
  $request = $service->files->insert($file);
5293
  'backupParentHID' => $historyID,
5294
  );
5295
 
5296
+ while (!$status && !feof($handle)){
 
5297
  iwp_mmb_auto_print('gdrive_chucked_upload');
5298
  $chunk = fread($handle, $upload_file_block_size);
5299
  $statusArray = $media->nextChunk($chunk, $resumeURI, $fileSizeUploaded);
5303
  $fileSizeUploaded = $statusArray['progress'];
5304
 
5305
  $googleTimeTaken = microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
5306
+ if(($googleTimeTaken > 10)&&($status != true)){
 
5307
  $chunkResult['resumeURI'] = $resumeURI;
5308
  $chunkResult['fileSizeUploaded'] = $fileSizeUploaded;
5309
 
5329
  }
5330
 
5331
  $result = false;
5332
+ if($status != false){
5333
  $result = $status;
5334
  }
5335
 
5341
  //$gDriveID = $createdFile['id'];
5342
  $gDriveID = $completeBackupResult['id'];
5343
  }
5344
+ }catch (Exception $e){
 
5345
  echo "An error occurred: " . $e->getMessage();
5346
  return array("error" => "gDrive Error".$e->getMessage(), "error_code" => "google_error_multipart_upload");
5347
  }
5365
  //$task_result['gDrive'] = basename($backup_file);
5366
  $task_result['gDrive'][] = $gDriveID;
5367
 
5368
+ if($current_file_num == $backup_files_count){
 
5369
  $result_arr['nextFunc'] = 'google_drive_completed';
5370
  iwp_mmb_print_flush('Google Drive upload: End');
5371
  unset($task_result['task_results'][$historyID]['server']);
5372
  }
5373
+ else{
 
5374
  $result_arr['status'] = "partiallyCompleted";
5375
  $result_arr['nextFunc'] = 'google_drive_backup';
5376
+ $result_arr['response_data'] = false;
5377
  $resArray['status'] = 'partiallyCompleted';
5378
  }
5379
 
5380
+ if($del_host_file){
 
5381
  @unlink($backup_file);
5382
  }
5383
 
5628
  $amazons3_file = $task_result['task_results'][$backup_data['historyID']]['amazons3'];
5629
  $args = $thisRequestParams['account_info']['iwp_amazon_s3'];
5630
  $args['backup_file'] = $amazons3_file;
5631
+ if(is_new_s3_compatible()){
5632
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
5633
+ $new_s3_obj = new IWP_MMB_S3_MULTICALL();
5634
+ $new_s3_obj->remove_amazons3_backup($args);
5635
+ }
5636
+ else{
5637
+ $this->remove_amazons3_backup_bwd_comp($args);
5638
+ }
5639
  }
5640
 
5641
  if (isset($task_result['task_results'][$backup_data['historyID']]['dropbox']) && isset($thisRequestParams['account_info']['iwp_dropbox'])) {
5798
  $amazons3_file = $backup['amazons3'];
5799
  $args = $args['iwp_amazon_s3'];
5800
  $args['backup_file'] = $amazons3_file;
5801
+ if(is_new_s3_compatible()){
5802
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
5803
+ $new_s3_obj = new IWP_MMB_S3_MULTICALL();
5804
+ $new_s3_obj->remove_amazons3_backup($args);
5805
+ }
5806
+ else{
5807
+ $this->remove_amazons3_backup_bwd_comp($args);
5808
+ }
5809
  }
5810
 
5811
  if (isset($backup['dropbox'])) {
5835
  $old_wpdb = $wpdb;
5836
  //Reconnect to avoid timeout problem after ZIP files
5837
  if(class_exists('wpdb') && function_exists('wp_set_wpdb_vars')){
5838
+ if ($wpdb->use_mysqli) {
5839
+ @mysqli_close($wpdb->dbh);
5840
+ } else {
5841
+ if (function_exists('mysql_close')){
5842
+ @mysql_close($wpdb->dbh);
5843
+ }
5844
+ }
5845
  $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
5846
  wp_set_wpdb_vars();
5847
  $wpdb->options = $old_wpdb->options;//fix for multi site full backup
5925
  else
5926
  return true;
5927
  }
5928
+
5929
+ function prepareBackupFileDetails($args){
5930
+ //Prepare .zip file name
5931
+ extract($args['args']); //{type, what, ..etc}
5932
+ extract($args); //{task_name, secure, mechanism}
5933
+
5934
+ $hash = md5(microtime(true).uniqid('',true).substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, rand(20,60)));
5935
+ $label = $type ? $type : 'manual';
5936
+ $backup_file_name = $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
5937
+ $backup_file = IWP_BACKUP_DIR . '/' . $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
5938
+ $backup_url = content_url() . '/infinitewp/backups/' . $this->site_name . '_' . $label . '_' . $what . '_' . date('Y-m-d') . '_' . $hash . '.zip';
5939
+ $this -> backup_url = $backup_url;
5940
+
5941
+ if(empty($account_info))
5942
+ {
5943
+ $account_info = array();
5944
+ }
5945
+
5946
+ return array(
5947
+ 'backup_file' => $backup_file,
5948
+ 'backup_url' => $backup_url,
5949
+ 'account_info' => $account_info,
5950
+ 'what' => $what
5951
+ );
5952
+ }
5953
+ }
5954
+
5955
+ if( !function_exists('initialize_manual_debug') ){
5956
+ function initialize_manual_debug($conditions = ''){
5957
+ global $debug_count, $every_count;
5958
+ $debug_count = 0;
5959
+ $every_count = 0;
5960
+
5961
+ $this_memory_peak_in_mb = memory_get_peak_usage();
5962
+ $this_memory_peak_in_mb = $this_memory_peak_in_mb / 1048576;
5963
+ $this_memory_in_mb = memory_get_usage();
5964
+ $this_memory_in_mb = $this_memory_in_mb / 1048576;
5965
+ $this_time_taken = microtime(true) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
5966
+
5967
+ file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryPeak.php',$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n");
5968
+ file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryUsage.php',$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n");
5969
+ file_put_contents(WP_CONTENT_DIR . '/DE_clTimeTaken.php',$debug_count . $printText . " " . round($this_time_taken, 2) ."\n");
5970
+ }
5971
+ }
5972
+
5973
+ if( !function_exists('manual_debug') ){
5974
+ function manual_debug($conditions = '', $printText = '', $forEvery = 0){
5975
+ return true;
5976
+ global $debug_count;
5977
+ $debug_count++;
5978
+ $printText = '-' . $printText;
5979
+
5980
+ global $every_count;
5981
+ //$conditions = 'printOnly';
5982
+
5983
+ if(empty($forEvery)){
5984
+ print_memory_debug($debug_count, $conditions, $printText);
5985
+ }
5986
+ else{
5987
+ $every_count++;
5988
+ if($every_count % $forEvery == 0){
5989
+ print_memory_debug($debug_count, $conditions, $printText);
5990
+ return true;
5991
+ }
5992
+ }
5993
+ }
5994
+ }
5995
+
5996
+ if( !function_exists('print_memory_debug') ){
5997
+ function print_memory_debug($debug_count, $conditions = '', $printText = ''){
5998
+
5999
+ $this_memory_peak_in_mb = memory_get_peak_usage();
6000
+ $this_memory_peak_in_mb = $this_memory_peak_in_mb / 1048576;
6001
+ $this_memory_in_mb = memory_get_usage();
6002
+ $this_memory_in_mb = $this_memory_in_mb / 1048576;
6003
+ $this_time_taken = microtime(true) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
6004
+ if($conditions == 'printOnly'){
6005
+ if($this_memory_peak_in_mb >= 34){
6006
+ file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryPeak.php',$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n",FILE_APPEND);
6007
+ file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryUsage.php',$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n",FILE_APPEND);
6008
+ file_put_contents(WP_CONTENT_DIR . '/DE_clTimeTaken.php',$debug_count . $printText . " " . round($this_time_taken, 2) ."\n",FILE_APPEND);
6009
+ }
6010
+ }
6011
+ else{
6012
+ file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryPeak.php',$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n",FILE_APPEND);
6013
+ file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryUsage.php',$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n",FILE_APPEND);
6014
+ file_put_contents(WP_CONTENT_DIR . '/DE_clTimeTaken.php',$debug_count . $printText . " " . round($this_time_taken, 2) ."\n",FILE_APPEND);
6015
+ }
6016
+ }
6017
+ }
6018
+
6019
+ if( !function_exists('print_debugg') ){
6020
+ function print_debugg($printText = '', $printVal = null, $forEvery = 0, $conditions = ''){
6021
+ static $print_count = 0;
6022
+ $print_count++;
6023
+ if($print_count > $forEvery){
6024
+ file_put_contents(WP_CONTENT_DIR . '/DE_clientPluginSIde.php',"\n -----".$printText."------- ".var_export($printVal,true)."\n",FILE_APPEND);
6025
+ $print_count = 0;
6026
+ }
6027
+ }
6028
+ }
6029
+
6030
+ if( !function_exists('refresh_iwp_files_db') ){
6031
+ function refresh_iwp_files_db($this_file_id = 0, $field = 'thisFileDetails' ){
6032
+ global $wpdb;
6033
+ $this_table_name = $wpdb->base_prefix . 'iwp_file_list'; //in case, if we are changing table name.
6034
+ $result = true;
6035
+
6036
+ $IWP_FILE_LIST_TABLE_VERSION = get_site_option('iwp_file_list_table_version');
6037
+
6038
+ //write in db and refresh for_every_count, all_files_detail;
6039
+ if($wpdb->get_var("SHOW TABLES LIKE '$this_table_name'") == $this_table_name) {
6040
+ $result = $wpdb->query('TRUNCATE TABLE ' . $this_table_name );
6041
+ $error_msg = 'Unable to empty File list table : ' . $wpdb->last_error ;
6042
+ if(version_compare($IWP_FILE_LIST_TABLE_VERSION, '1.0') == -1){
6043
+ $result = iwp_create_file_list_table();
6044
+ $error_msg = 'Unable to update File list table : ' . $wpdb->last_error ;
6045
+ }
6046
+ }
6047
+ else{
6048
+ $result = iwp_create_file_list_table();
6049
+ $error_msg = 'Unable to create File list table : ' . $wpdb->last_error ;
6050
+ }
6051
+
6052
+ if($result === false){
6053
+ return array( 'error' => $error_msg);
6054
+ }
6055
+ return true;
6056
+ }
6057
+ }
6058
+
6059
+ if(!function_exists('iwp_create_file_list_table')){
6060
+ function iwp_create_file_list_table(){
6061
+ global $wpdb;
6062
+ if(method_exists($wpdb, 'get_charset_collate')){
6063
+ $charset_collate = $wpdb->get_charset_collate();
6064
+ }
6065
+ $table_created = false;
6066
+
6067
+ $IWP_FILE_LIST_TABLE_VERSION = get_site_option('iwp_file_list_table_version');
6068
+ $table_name = $wpdb->base_prefix . "iwp_file_list";
6069
+
6070
+ if (!empty($charset_collate)){
6071
+ $cachecollation = $charset_collate;
6072
+ }
6073
+ else{
6074
+ $cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
6075
+ }
6076
+
6077
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){
6078
+ $sql = "
6079
+ CREATE TABLE IF NOT EXISTS $table_name (
6080
+ `ID` int(11) NOT NULL AUTO_INCREMENT,
6081
+ `thisFileDetails` text,
6082
+ `thisFileCount` int(11) DEFAULT NULL,
6083
+ `thisFileHeader` text,
6084
+ `thisFileName` varchar(255) DEFAULT NULL,
6085
+ UNIQUE KEY `thisFileName` (`thisFileName`(191)),
6086
+ PRIMARY KEY (`ID`)
6087
+ )".$cachecollation." ;
6088
+ ";
6089
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
6090
+ dbDelta($sql);
6091
+
6092
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name){
6093
+ $table_created = true;
6094
+ update_option( "iwp_file_list_table_version", '1.0');
6095
+ }
6096
+ }
6097
+ else if(version_compare($IWP_FILE_LIST_TABLE_VERSION, '1.0') == -1){
6098
+ $table_created = true;
6099
+ update_option( "iwp_file_list_table_version", '1.0');
6100
+ }
6101
+ return $table_created;
6102
+ }
6103
+ }
6104
+
6105
+ if( !function_exists('get_from_iwp_files_db') ){
6106
+ function get_from_iwp_files_db($this_file_id = 0, $field = 'thisFileDetails' ){
6107
+ global $wpdb;
6108
+ $this_table_name = 'iwp_file_list'; //in case, if we are changing table name.
6109
+ //$field = 'thisFileDetails';
6110
+
6111
+ // $this_obj = new IWP_MMB_Backup_Multicall();
6112
+ // $this_obj->wpdb_reconnect();
6113
+
6114
+ $this_file_id = $this_file_id + 1;
6115
+ //write in db and refresh for_every_count, all_files_detail;
6116
+ $all_files_detail = $wpdb->get_row("SELECT ".$field." FROM " . $wpdb->base_prefix. $this_table_name . " WHERE ID = " . $this_file_id );
6117
+
6118
+ if(!empty($all_files_detail))
6119
+ {
6120
+ $all_files_detail = (array)$all_files_detail;
6121
+ if(!empty($all_files_detail[$field])){
6122
+ return unserialize($all_files_detail[$field]);
6123
+ }
6124
+ else{
6125
+ return array( 'error' => 'emptyValues');
6126
+ }
6127
+ }
6128
+ else{
6129
+ return array( 'error' => $wpdb->last_error);
6130
+ }
6131
+ }
6132
+ }
6133
+
6134
+ if( !function_exists('get_iwp_files_db_count') ){
6135
+ function get_iwp_files_db_count($what_type = 'files', $how_many = 'total'){
6136
+ global $wpdb;
6137
+ $this_table_name = 'iwp_file_list';
6138
+
6139
+ if($what_type == 'files'){
6140
+ $result = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->base_prefix . $this_table_name);
6141
+ }
6142
+ else if($what_type == 'headers'){
6143
+ $result = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->base_prefix . $this_table_name . " WHERE thisFileHeader IS NOT NULL");
6144
+ }
6145
+
6146
+ if($result !== false)
6147
+ {
6148
+ return (int)$result;
6149
+ }
6150
+ else{
6151
+ return array( 'error' => $wpdb->last_error);
6152
+ }
6153
+ }
6154
+ }
6155
+
6156
+ if( !function_exists('delete_in_iwp_files_db') ){
6157
+ function delete_in_iwp_files_db($ID = 0){
6158
+ global $wpdb;
6159
+ $this_table_name = $wpdb->base_prefix . 'iwp_file_list';
6160
+ $ID = $ID + 1;
6161
+ $result = $wpdb->delete( $this_table_name, array( 'ID' => $ID ), array( '%d' ) );
6162
+
6163
+ return $result;
6164
+ }
6165
+ }
6166
+
6167
+ if( !function_exists('save_in_iwp_files_db') ){
6168
+ function save_in_iwp_files_db($for_every = 0, $this_file_details = array(), $this_header_details = array(), $action = 'insert', $ID = 0){
6169
+ //assuming insert only happens for file adding; update happens only for header adding.
6170
+ static $for_every_count; $for_every_count++;
6171
+ static $all_files_header_detail = array();
6172
+ if(!empty($this_file_details)){
6173
+ $all_files_header_detail[] = $this_file_details;
6174
+ }
6175
+ else{
6176
+ $all_files_header_detail[] = $this_header_details;
6177
+ }
6178
+
6179
+ global $wpdb;
6180
+ $this_table_name = 'iwp_file_list'; //in case, if we are changing table name.
6181
+ $this_insertID = 0;
6182
+ $result = true;
6183
+
6184
+ if($for_every_count >= $for_every){
6185
+ //write in db and refresh for_every_count, all_files_header_detail;
6186
+ //$this_obj = new IWP_MMB_Backup_Multicall();
6187
+ //$this_obj->wpdb_reconnect();
6188
+
6189
+ foreach($all_files_header_detail as $k => $v){
6190
+ if($action == 'insert'){
6191
+ $is_already = $wpdb->get_row("SELECT * FROM " . $wpdb->base_prefix. $this_table_name . " WHERE thisFileName = '". $v['stored_filename'].$v['splitFilename']."'" );
6192
+ if(empty($is_already)){
6193
+ $result = $wpdb->insert($wpdb->base_prefix . $this_table_name, array('thisFileDetails' => serialize($v), 'thisFileCount' => $k, 'thisFileName' => $v['stored_filename'].$v['splitFilename']), array( '%s', '%d', '%s' ));
6194
+ }
6195
+ }
6196
+ else if($action == 'update'){
6197
+ $ID = $ID + 1;
6198
+ $result = $wpdb->update($wpdb->base_prefix . $this_table_name, array('thisFileHeader' => serialize($v), ), array( 'ID' => $ID), array('%s'), array('%d'));
6199
+ }
6200
+ if($result)
6201
+ {
6202
+ if($action == 'insert'){
6203
+ $this_insertID = $wpdb->insert_id;
6204
+ }
6205
+ }
6206
+ else{
6207
+ if($action == 'update'){
6208
+ return array('error' => 1);
6209
+ }
6210
+ }
6211
+ }
6212
+ $for_every_count = 0;
6213
+ $all_files_header_detail = array();
6214
+ if($action == 'insert'){
6215
+ $is_break = check_and_break_iwp();
6216
+ if($is_break){
6217
+ return array( 'break' => $this_insertID );
6218
+ }
6219
+ }
6220
+ }
6221
+ return false;
6222
+ }
6223
+ }
6224
+
6225
+ if( !function_exists('check_and_break_iwp') ){
6226
+ function check_and_break_iwp(){
6227
+ if((microtime(true) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START']) > 22){
6228
+ return true;
6229
+ }
6230
+ else{
6231
+ return false;
6232
+ }
6233
+ }
6234
  }
6235
 
6236
+ if( !function_exists('check_and_break_iwp_test') ){
6237
+ function check_and_break_iwp_test(){
6238
+ static $this_count;
6239
+ $this_count++;
6240
+ if($this_count >= 20){
6241
+ $this_count = 0;
6242
+ return true;
6243
+ }
6244
+ else{
6245
+ return false;
6246
+ }
6247
+ }
6248
+ }
6249
+
6250
+ if( !function_exists('debug_put') ){
6251
+ function debug_put($values, $string){
6252
+ file_put_contents(WP_CONTENT_DIR . '/DE_clientPluginSIde.php',"\n -----".$string."------- ".var_export($values,true)."\n",FILE_APPEND);
6253
+ }
6254
+ }
6255
+
6256
+ if( !function_exists('is_new_s3_compatible') ){
6257
+ function is_new_s3_compatible(){
6258
+ if(phpversion() >= '5.3.3'){
6259
+ return true;
6260
+ }
6261
+ return false;
6262
+ }
6263
+ }
6264
  /*if( function_exists('add_filter') ){
6265
  add_filter( 'iwp_website_add', 'IWP_MMB_Backup::readd_tasks' );
6266
  }*/
backup.class.singlecall.php CHANGED
@@ -72,7 +72,6 @@ $unzip_errors = array(
72
  82 => 'No files were found due to bad decryption password(s)'
73
  );
74
 
75
-
76
  class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
77
  {
78
  var $site_name;
@@ -358,7 +357,14 @@ function delete_task_now($task_name){
358
 
359
  $backup_settings['account_info']['iwp_amazon_s3']['backup_file'] = $backup_file;
360
  iwp_mmb_print_flush('Amazon S3 upload: Start');
361
- $amazons3_result = $this->amazons3_backup($backup_settings['account_info']['iwp_amazon_s3']);
 
 
 
 
 
 
 
362
  iwp_mmb_print_flush('Amazon S3 upload: End');
363
  if ($amazons3_result !== true && $del_host_file) {
364
  @unlink($backup_file);
@@ -478,16 +484,16 @@ function delete_task_now($task_name){
478
  iwp_mmb_print_flush('DB ZIP CMD: End');
479
  /*zip_backup_db */
480
  if(!$result){
481
- $zip_archive_db_result = false;
482
- if (class_exists("ZipArchive")) {
483
- $this->_log("DB zip, fallback to ZipArchive");
484
- iwp_mmb_print_flush('DB ZIP Archive: Start');
485
- $zip_archive_db_result = $this->zip_archive_backup_db($task_name, $db_result, $backup_file);
486
- iwp_mmb_print_flush('DB ZIP Archive Result: '.$zip_archive_db_result);
487
- iwp_mmb_print_flush('DB ZIP Archive: End');
488
- }
489
 
490
- if (!$zip_archive_db_result) {
491
  $pcl_result = $this->fail_safe_pcl_db($backup_file,$fail_safe_db,$disable_comp);
492
  if(is_array($pcl_result) && isset($pcl_result['error'])){
493
  return $pcl_result;
@@ -512,7 +518,6 @@ function delete_task_now($task_name){
512
 
513
  function backup_files_alone($task_name, $backup_file, $exclude = array(), $include = array(), $comp_level = 0, $exclude_file_size = 0, $exclude_extensions = "")
514
  {
515
-
516
  global $zip_errors;
517
  $sys = substr(PHP_OS, 0, 3);
518
 
@@ -536,7 +541,16 @@ function delete_task_now($task_name){
536
  trim(basename(WP_CONTENT_DIR)) . "/infinitewp/backups",
537
  trim(basename(WP_CONTENT_DIR)) . "/" . md5('iwp_mmb-client') . "/iwp_backups",
538
  trim(basename(WP_CONTENT_DIR)) . "/cache",
539
- trim(basename(WP_CONTENT_DIR)) . "/w3tc"
 
 
 
 
 
 
 
 
 
540
  );
541
 
542
  //removing files which are larger than the specified size
@@ -676,8 +690,8 @@ function delete_task_now($task_name){
676
  $command = "$zip -q -r $comp_level $backup_file $include_data $exclude_data";
677
  ob_start();
678
  $result_d = $this->iwp_mmb_exec($command, false, true);
679
- ob_get_clean();
680
- if ($result_d && $result_d != 18) {
681
  @unlink($backup_file);
682
  $do_cmd_zip_alternative = true;
683
 
@@ -712,13 +726,13 @@ function delete_task_now($task_name){
712
  iwp_mmb_print_flush('Files ZIP Archive: End');
713
  }
714
 
715
- if (!$zip_archive_result) {
716
- $pcl_result = $this->fail_safe_pcl_files($task_name, $backup_file, $exclude, $include, $fail_safe_files, $disable_comp, $add, $remove);
717
- if(is_array($pcl_result) && isset($pcl_result['error'])){
718
- return $pcl_result;
719
- }
720
  }
721
  }
 
722
  }
723
 
724
  //Reconnect
@@ -873,9 +887,7 @@ function delete_task_now($task_name){
873
  * @return array|bool true if successful or an array with error message if not
874
  */
875
  function zip_archive_backup($task_name, $backup_file, $exclude, $include, $overwrite = false) {
876
-
877
  $filelist = $this->get_backup_files($exclude, $include);
878
-
879
  $disable_comp = $this->tasks['args']['disable_comp'];
880
  if (!$disable_comp) {
881
  $this->_log("Compression is not supported by ZipArchive");
@@ -885,20 +897,54 @@ function delete_task_now($task_name){
885
 
886
  if ($overwrite) {
887
  $result = $zip->open($backup_file, ZipArchive::OVERWRITE); // Tries to open $backup_file for acrhiving
888
- } else {
 
889
  if(file_exists($backup_file)){
890
  $result = $zip->open($backup_file); // Tries to open $backup_file for acrhiving
891
  }else{
892
  $result = $zip->open($backup_file, ZIPARCHIVE::CREATE);
893
  }
894
  }
 
 
895
  if ($result === true) {
 
896
  foreach ($filelist as $file) {
897
  iwp_mmb_auto_print('zip_archive_backup');
898
- $result = $result && $zip->addFile($file, sprintf("%s", str_replace(ABSPATH, '', $file))); // Tries to add a new file to $backup_file
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
899
  }
900
  $result = $result && $zip->close(); // Tries to close $backup_file
901
- } else {
902
  $result = false;
903
  }
904
  return $result; // true if $backup_file iz zipped successfully, false if error is occurred in zip process
@@ -1001,85 +1047,72 @@ function delete_task_now($task_name){
1001
  if(empty($GLOBALS['fail_safe_db'])){
1002
  iwp_mmb_print_flush('DB DUMP PHP Normal: Start');
1003
  $fp = fopen( $file, 'w' );
1004
- if ( !mysql_ping( $wpdb->dbh ) ) {
1005
- mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
1006
- mysql_select_db( DB_NAME );
1007
- }
1008
  $_count = 0;
1009
  $insert_sql = '';
1010
- //$result = mysql_query( 'SHOW TABLES' );
1011
- $result = mysql_query( 'SHOW TABLES LIKE "'.$wpdb->base_prefix.'%"' );
1012
  if(!$result)
1013
  {
1014
  return array(
1015
- 'error' => 'MySQL '.mysql_error()." ", 'error_code' => 'MySQL '.str_replace(" ", "_", mysql_error())." "
1016
  );
1017
  }
1018
- while( $row = mysql_fetch_row( $result ) ) {
1019
- $tables[]=$row[0];
1020
- //array_push( $tables, $row[0] );
 
 
 
1021
  }
1022
 
1023
 
1024
- //$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
1025
  foreach ($tables as $table) {
1026
  iwp_mmb_auto_print('backup_db_php_normal');
1027
-
1028
  $insert_sql .= "DROP TABLE IF EXISTS $table;";
1029
- //create table
1030
- $table_descr_query = mysql_query("SHOW CREATE TABLE `$table`");
1031
- $fetch_table_descr_row = mysql_fetch_array( $table_descr_query );
1032
- $insert_sql .= "\n\n" . $fetch_table_descr_row[1] . ";\n\n";
1033
 
 
1034
  fwrite( $fp, $insert_sql );
1035
  $insert_sql = '';
1036
 
1037
- $table_query = mysql_query("SELECT * FROM `$table`");
1038
- $num_fields = mysql_num_fields($table_query);
1039
- while ( $fetch_row = mysql_fetch_array( $table_query ) ) {
 
 
1040
  $insert_sql .= "INSERT INTO $table VALUES(";
1041
- for ( $n=1; $n<=$num_fields; $n++ ) {
1042
- $m = $n - 1;
1043
 
1044
- if ( $fetch_row[$m] === NULL ) {
1045
- $insert_sql .= "NULL, ";
1046
- } else {
1047
- $insert_sql .= "'" . mysql_real_escape_string( $fetch_row[$m] ) . "', ";
 
 
 
1048
  }
 
1049
  }
1050
  $insert_sql = substr( $insert_sql, 0, -2 );
1051
  $insert_sql .= ");\n";
1052
-
1053
  fwrite( $fp, $insert_sql );
1054
  $insert_sql = '';
1055
-
1056
- // Help keep HTTP alive.
1057
  $_count++;
1058
  if ($_count >= 400) {
1059
  echo ' ';
1060
  flush();
1061
  $_count = 0;
1062
  }
1063
- } // End foreach $tables.
1064
-
1065
  $insert_sql .= "\n\n\n";
1066
 
1067
- // testing: mysql_close( $wpdb->dbh );
1068
- // Verify database is still connected and working properly. Sometimes mysql runs out of memory and dies in the above foreach.
1069
- // No point in reconnecting as we can NOT trust that our dump was succesful anymore (it most likely was not).
1070
- if ( @mysql_ping( $wpdb->dbh ) ) { // Still connected to database.
1071
- mysql_free_result( $table_query ); // Free memory.
1072
- } /*else { // Database not connected.
1073
-
1074
- return false;
1075
- }*/
1076
-
1077
  // Help keep HTTP alive.
1078
  echo ' ';
1079
  flush();
1080
 
1081
  //unset( $tables[$table_key] );
1082
- }
1083
  fclose( $fp );
1084
  unset ($fp);
1085
  iwp_mmb_print_flush('DB DUMP PHP Normal: End');
@@ -1991,11 +2024,10 @@ function ftp_backup($args)
1991
  //return true;
1992
  }
1993
 
1994
-
1995
- function amazons3_backup($args)
1996
  {
1997
  if ($this->iwp_mmb_function_exists('curl_init')) {
1998
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
1999
  extract($args);
2000
 
2001
  if ($as3_site_folder == true)
@@ -2269,11 +2301,10 @@ function ftp_backup($args)
2269
  return $gDriveID;
2270
  }
2271
 
2272
-
2273
- function remove_amazons3_backup($args)
2274
  {
2275
  if ($this->iwp_mmb_function_exists('curl_init')) {
2276
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
2277
  extract($args);
2278
 
2279
  if(!is_array($backup_file))
@@ -2636,7 +2667,14 @@ function ftp_backup($args)
2636
  $amazons3_file = $task_result['task_results'][$backup_data['historyID']]['amazons3'];
2637
  $args = $thisRequestParams['account_info']['iwp_amazon_s3'];
2638
  $args['backup_file'] = $amazons3_file;
2639
- $this->remove_amazons3_backup($args);
 
 
 
 
 
 
 
2640
  }
2641
 
2642
  if (isset($task_result['task_results'][$backup_data['historyID']]['dropbox']) && isset($thisRequestParams['account_info']['iwp_dropbox'])) {
@@ -2714,7 +2752,14 @@ function ftp_backup($args)
2714
  $amazons3_file = $backup['amazons3'];
2715
  $args = $args['iwp_amazon_s3'];
2716
  $args['backup_file'] = $amazons3_file;
2717
- $this->remove_amazons3_backup($args);
 
 
 
 
 
 
 
2718
  }
2719
 
2720
  if (isset($backup['dropbox'])) {
@@ -2754,11 +2799,12 @@ function ftp_backup($args)
2754
  {
2755
  $tasks = $this->get_all_tasks(); //all backups task results array.
2756
 
2757
-
2758
  $backup_folder = WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups/';
2759
  $backup_folder_new = IWP_BACKUP_DIR . '/';
 
2760
  $files = glob($backup_folder . "*");
2761
  $new = glob($backup_folder_new . "*");
 
2762
 
2763
  //Failed db files first
2764
  $db_folder = IWP_DB_DIR . '/';
@@ -2773,7 +2819,7 @@ function ftp_backup($args)
2773
 
2774
 
2775
  //clean_old folder?
2776
- if ((basename($files[0]) == 'index.php' && count($files) == 1) || (!empty($files))) { //USE (!empty($files)
2777
  foreach ($files as $file) {
2778
  @unlink($file);
2779
  }
@@ -2786,6 +2832,11 @@ function ftp_backup($args)
2786
  $files[] = $b;
2787
  }
2788
  }
 
 
 
 
 
2789
  $deleted = array();
2790
 
2791
  if (is_array($files) && count($files)) {
@@ -2814,18 +2865,17 @@ function ftp_backup($args)
2814
  }
2815
  }
2816
  }
2817
-
2818
  $num_deleted = 0;
 
2819
  foreach ($files as $file) {
2820
  if (!in_array($file, $results) && basename($file) != 'index.php') {
2821
  @unlink($file);
2822
- $deleted[] = basename($file);
 
2823
  $num_deleted++;
2824
  }
2825
  }
2826
  }
2827
-
2828
-
2829
  return $deleted;
2830
  }
2831
 
@@ -2936,8 +2986,14 @@ function ftp_backup($args)
2936
  $old_wpdb = $wpdb;
2937
  //Reconnect to avoid timeout problem after ZIP files
2938
  if(class_exists('wpdb') && function_exists('wp_set_wpdb_vars')){
2939
- @mysql_close($wpdb->dbh);
2940
- $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
 
 
 
 
 
 
2941
  wp_set_wpdb_vars();
2942
  $wpdb->options = $old_wpdb->options;//fix for multi site full backup
2943
  }
@@ -3084,4 +3140,14 @@ if (!function_exists('get_all_files_from_dir_recursive')) {
3084
  }
3085
  }
3086
  }
 
 
 
 
 
 
 
 
 
 
3087
  ?>
72
  82 => 'No files were found due to bad decryption password(s)'
73
  );
74
 
 
75
  class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
76
  {
77
  var $site_name;
357
 
358
  $backup_settings['account_info']['iwp_amazon_s3']['backup_file'] = $backup_file;
359
  iwp_mmb_print_flush('Amazon S3 upload: Start');
360
+ if(is_new_s3_compatible()){
361
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
362
+ $new_s3_obj = new IWP_MMB_S3_SINGLECALL();
363
+ $amazons3_result = $new_s3_obj->amazons3_backup($backup_settings['account_info']['iwp_amazon_s3']);
364
+ }
365
+ else{
366
+ $amazons3_result = $this->amazons3_backup_bwd_comp($backup_settings['account_info']['iwp_amazon_s3']);
367
+ }
368
  iwp_mmb_print_flush('Amazon S3 upload: End');
369
  if ($amazons3_result !== true && $del_host_file) {
370
  @unlink($backup_file);
484
  iwp_mmb_print_flush('DB ZIP CMD: End');
485
  /*zip_backup_db */
486
  if(!$result){
487
+ $zip_archive_db_result = false;
488
+ if (class_exists("ZipArchive")) {
489
+ $this->_log("DB zip, fallback to ZipArchive");
490
+ iwp_mmb_print_flush('DB ZIP Archive: Start');
491
+ $zip_archive_db_result = $this->zip_archive_backup_db($task_name, $db_result, $backup_file);
492
+ iwp_mmb_print_flush('DB ZIP Archive Result: '.$zip_archive_db_result);
493
+ iwp_mmb_print_flush('DB ZIP Archive: End');
494
+ }
495
 
496
+ if (!$zip_archive_db_result) {
497
  $pcl_result = $this->fail_safe_pcl_db($backup_file,$fail_safe_db,$disable_comp);
498
  if(is_array($pcl_result) && isset($pcl_result['error'])){
499
  return $pcl_result;
518
 
519
  function backup_files_alone($task_name, $backup_file, $exclude = array(), $include = array(), $comp_level = 0, $exclude_file_size = 0, $exclude_extensions = "")
520
  {
 
521
  global $zip_errors;
522
  $sys = substr(PHP_OS, 0, 3);
523
 
541
  trim(basename(WP_CONTENT_DIR)) . "/infinitewp/backups",
542
  trim(basename(WP_CONTENT_DIR)) . "/" . md5('iwp_mmb-client') . "/iwp_backups",
543
  trim(basename(WP_CONTENT_DIR)) . "/cache",
544
+ trim(basename(WP_CONTENT_DIR)) . "/w3tc",
545
+ trim(basename(WP_CONTENT_DIR)) . "/logs",
546
+ trim(basename(WP_CONTENT_DIR)) . "/widget_cache",
547
+ trim(basename(WP_CONTENT_DIR)) . "/tmp",
548
+ trim(basename(WP_CONTENT_DIR)) . "/updraft",
549
+ trim(basename(WP_CONTENT_DIR)) . "/updraftplus",
550
+ trim(basename(WP_CONTENT_DIR)) . "/backups",
551
+ trim(basename(WP_CONTENT_DIR)) . "/uploads/wp-clone",
552
+ trim(basename(WP_CONTENT_DIR)) . "/uploads/db-backup",
553
+ trim(basename(WP_PLUGIN_DIR)) . "/cache",
554
  );
555
 
556
  //removing files which are larger than the specified size
690
  $command = "$zip -q -r $comp_level $backup_file $include_data $exclude_data";
691
  ob_start();
692
  $result_d = $this->iwp_mmb_exec($command, false, true);
693
+ ob_get_clean();
694
+ if (!$result_d || ($result_d && $result_d != 18)){
695
  @unlink($backup_file);
696
  $do_cmd_zip_alternative = true;
697
 
726
  iwp_mmb_print_flush('Files ZIP Archive: End');
727
  }
728
 
729
+ if (!$zip_archive_result) {
730
+ $pcl_result = $this->fail_safe_pcl_files($task_name, $backup_file, $exclude, $include, $fail_safe_files, $disable_comp, $add, $remove);
731
+ if(is_array($pcl_result) && isset($pcl_result['error'])){
732
+ return $pcl_result;
 
733
  }
734
  }
735
+ }
736
  }
737
 
738
  //Reconnect
887
  * @return array|bool true if successful or an array with error message if not
888
  */
889
  function zip_archive_backup($task_name, $backup_file, $exclude, $include, $overwrite = false) {
 
890
  $filelist = $this->get_backup_files($exclude, $include);
 
891
  $disable_comp = $this->tasks['args']['disable_comp'];
892
  if (!$disable_comp) {
893
  $this->_log("Compression is not supported by ZipArchive");
897
 
898
  if ($overwrite) {
899
  $result = $zip->open($backup_file, ZipArchive::OVERWRITE); // Tries to open $backup_file for acrhiving
900
+ }
901
+ else{
902
  if(file_exists($backup_file)){
903
  $result = $zip->open($backup_file); // Tries to open $backup_file for acrhiving
904
  }else{
905
  $result = $zip->open($backup_file, ZIPARCHIVE::CREATE);
906
  }
907
  }
908
+
909
+ $max_mb_size=1;
910
  if ($result === true) {
911
+ $size_checker = 0;
912
  foreach ($filelist as $file) {
913
  iwp_mmb_auto_print('zip_archive_backup');
914
+ if(is_readable($file)){ //checking file is readable
915
+ $file_size_in_bytes=filesize($file); //getting file size
916
+ if($file_size_in_bytes > $max_mb_size*1024*1024){ //if file size more than 1 MB it will be added sepearately
917
+ $result = $result && $zip->close();
918
+ $size_checker = 0; //reset $size_checker
919
+ if(file_exists($backup_file)){
920
+ $result = $zip->open($backup_file);
921
+ }
922
+ $result = $result && $zip->addFile($file, sprintf("%s", str_replace(ABSPATH, '', $file))); // Tries to add a new file to $backup_file
923
+ $result = $result && $zip->close();
924
+ $size_checker = 0; //reset $size_checker
925
+ if(file_exists($backup_file)){
926
+ $result = $zip->open($backup_file);
927
+ }
928
+ }
929
+ else{
930
+ if($size_checker<$max_mb_size*1024*1024){ //checking $size_checker
931
+ $result = $result && $zip->addFile($file, sprintf("%s", str_replace(ABSPATH, '', $file))); // Tries to add a new file to $backup_file
932
+ $size_checker = $size_checker + $file_size_in_bytes; //adding added file size
933
+ }
934
+ else {
935
+ $result = $result && $zip->close();
936
+ $size_checker = 0; //reset $size_checker
937
+ if(file_exists($backup_file)){
938
+ $result = $zip->open($backup_file);
939
+ }
940
+ $result = $result && $zip->addFile($file, sprintf("%s", str_replace(ABSPATH, '', $file))); // Tries to add a new file to $backup_file
941
+ $size_checker=$size_checker + $file_size_in_bytes; //adding added file size
942
+ }
943
+ }
944
+ }
945
  }
946
  $result = $result && $zip->close(); // Tries to close $backup_file
947
+ }else{
948
  $result = false;
949
  }
950
  return $result; // true if $backup_file iz zipped successfully, false if error is occurred in zip process
1047
  if(empty($GLOBALS['fail_safe_db'])){
1048
  iwp_mmb_print_flush('DB DUMP PHP Normal: Start');
1049
  $fp = fopen( $file, 'w' );
 
 
 
 
1050
  $_count = 0;
1051
  $insert_sql = '';
1052
+ $result = $wpdb->get_results( 'SHOW TABLES LIKE "'.$wpdb->base_prefix.'%"');
 
1053
  if(!$result)
1054
  {
1055
  return array(
1056
+ 'error' => 'MySQL '.$wpdb->print_error()." ", 'error_code' => 'MySQL '.str_replace(" ", "_", $wpdb->print_error())." "
1057
  );
1058
  }
1059
+
1060
+ foreach($result as $index => $value) {
1061
+ foreach($value as $tableName) {
1062
+ //echo $tableName . '<br />';
1063
+ $tables[]=$tableName;
1064
+ }
1065
  }
1066
 
1067
 
 
1068
  foreach ($tables as $table) {
1069
  iwp_mmb_auto_print('backup_db_php_normal');
 
1070
  $insert_sql .= "DROP TABLE IF EXISTS $table;";
1071
+ $table_descr_query = $wpdb->get_results("SHOW CREATE TABLE `$table`", ARRAY_N);
 
 
 
1072
 
1073
+ $insert_sql .= "\n\n" . $table_descr_query[0][1] . ";\n\n";
1074
  fwrite( $fp, $insert_sql );
1075
  $insert_sql = '';
1076
 
1077
+ $table_query = $wpdb->get_results("SELECT * FROM `$table`", ARRAY_N);
1078
+ $num_fields = $wpdb->num_rows;
1079
+
1080
+ foreach ($table_query as $final) {
1081
+ $counts=count($final);
1082
  $insert_sql .= "INSERT INTO $table VALUES(";
 
 
1083
 
1084
+ for ($i=0; $i <$counts ; $i++) {
1085
+ if($final[$i]== NULL) {
1086
+ $insert_sql .= "'', ";
1087
+ }
1088
+ else {
1089
+
1090
+ $insert_sql .= "'" . esc_sql($final[$i]). "', ";
1091
  }
1092
+ //mb_convert_encoding(esc_sql($final[$i] ), "HTML-ENTITIES", "ISO-8859-1")
1093
  }
1094
  $insert_sql = substr( $insert_sql, 0, -2 );
1095
  $insert_sql .= ");\n";
 
1096
  fwrite( $fp, $insert_sql );
1097
  $insert_sql = '';
 
 
1098
  $_count++;
1099
  if ($_count >= 400) {
1100
  echo ' ';
1101
  flush();
1102
  $_count = 0;
1103
  }
1104
+ }
 
1105
  $insert_sql .= "\n\n\n";
1106
 
1107
+ if ( $wpdb->check_connection() ) { // Still connected to database.
1108
+ $wpdb->flush(); // Free memory.
1109
+ }
 
 
 
 
 
 
 
1110
  // Help keep HTTP alive.
1111
  echo ' ';
1112
  flush();
1113
 
1114
  //unset( $tables[$table_key] );
1115
+ }
1116
  fclose( $fp );
1117
  unset ($fp);
1118
  iwp_mmb_print_flush('DB DUMP PHP Normal: End');
2024
  //return true;
2025
  }
2026
 
2027
+ function amazons3_backup_bwd_comp($args)
 
2028
  {
2029
  if ($this->iwp_mmb_function_exists('curl_init')) {
2030
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3_bwd_comp/sdk.class.php');
2031
  extract($args);
2032
 
2033
  if ($as3_site_folder == true)
2301
  return $gDriveID;
2302
  }
2303
 
2304
+ function remove_amazons3_backup_bwd_comp($args)
 
2305
  {
2306
  if ($this->iwp_mmb_function_exists('curl_init')) {
2307
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3_bwd_comp/sdk.class.php');
2308
  extract($args);
2309
 
2310
  if(!is_array($backup_file))
2667
  $amazons3_file = $task_result['task_results'][$backup_data['historyID']]['amazons3'];
2668
  $args = $thisRequestParams['account_info']['iwp_amazon_s3'];
2669
  $args['backup_file'] = $amazons3_file;
2670
+ if(is_new_s3_compatible()){
2671
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
2672
+ $new_s3_obj = new IWP_MMB_S3_SINGLECALL();
2673
+ $new_s3_obj->remove_amazons3_backup($args);
2674
+ }
2675
+ else{
2676
+ $this->remove_amazons3_backup_bwd_comp($args);
2677
+ }
2678
  }
2679
 
2680
  if (isset($task_result['task_results'][$backup_data['historyID']]['dropbox']) && isset($thisRequestParams['account_info']['iwp_dropbox'])) {
2752
  $amazons3_file = $backup['amazons3'];
2753
  $args = $args['iwp_amazon_s3'];
2754
  $args['backup_file'] = $amazons3_file;
2755
+ if(is_new_s3_compatible()){
2756
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/s3IWPBackup.php';
2757
+ $new_s3_obj = new IWP_MMB_S3_SINGLECALL();
2758
+ $new_s3_obj->remove_amazons3_backup($args);
2759
+ }
2760
+ else{
2761
+ $this->remove_amazons3_backup_bwd_comp($args);
2762
+ }
2763
  }
2764
 
2765
  if (isset($backup['dropbox'])) {
2799
  {
2800
  $tasks = $this->get_all_tasks(); //all backups task results array.
2801
 
 
2802
  $backup_folder = WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups/';
2803
  $backup_folder_new = IWP_BACKUP_DIR . '/';
2804
+ $backup_temp_folder = IWP_PCLZIP_TEMPORARY_DIR;
2805
  $files = glob($backup_folder . "*");
2806
  $new = glob($backup_folder_new . "*");
2807
+ $new_temp = glob($backup_temp_folder . "*");
2808
 
2809
  //Failed db files first
2810
  $db_folder = IWP_DB_DIR . '/';
2819
 
2820
 
2821
  //clean_old folder?
2822
+ if ((count($files) == 1 && basename($files[0]) == 'index.php') || (!empty($files))) { //USE (!empty($files)
2823
  foreach ($files as $file) {
2824
  @unlink($file);
2825
  }
2832
  $files[] = $b;
2833
  }
2834
  }
2835
+ if (!empty($new_temp)) {
2836
+ foreach ($new_temp as $c) {
2837
+ $files[] = $c;
2838
+ }
2839
+ }
2840
  $deleted = array();
2841
 
2842
  if (is_array($files) && count($files)) {
2865
  }
2866
  }
2867
  }
 
2868
  $num_deleted = 0;
2869
+
2870
  foreach ($files as $file) {
2871
  if (!in_array($file, $results) && basename($file) != 'index.php') {
2872
  @unlink($file);
2873
+ //$deleted[] = basename($file);
2874
+ $deleted[] = $file;
2875
  $num_deleted++;
2876
  }
2877
  }
2878
  }
 
 
2879
  return $deleted;
2880
  }
2881
 
2986
  $old_wpdb = $wpdb;
2987
  //Reconnect to avoid timeout problem after ZIP files
2988
  if(class_exists('wpdb') && function_exists('wp_set_wpdb_vars')){
2989
+ if ($wpdb->use_mysqli) {
2990
+ @mysqli_close($wpdb->dbh);
2991
+ } else {
2992
+ if (function_exists('mysql_close')){
2993
+ @mysql_close($wpdb->dbh);
2994
+ }
2995
+ }
2996
+ $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
2997
  wp_set_wpdb_vars();
2998
  $wpdb->options = $old_wpdb->options;//fix for multi site full backup
2999
  }
3140
  }
3141
  }
3142
  }
3143
+
3144
+ if( !function_exists('is_new_s3_compatible') ){
3145
+ function is_new_s3_compatible(){
3146
+ if(phpversion() >= '5.3.3'){
3147
+ return true;
3148
+ }
3149
+ return false;
3150
+ }
3151
+ }
3152
+
3153
  ?>
init.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: InfiniteWP - Client
4
  Plugin URI: http://infinitewp.com/
5
  Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
  Author: Revmakx
7
- Version: 1.4.3
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
@@ -28,7 +28,7 @@ if(basename($_SERVER['SCRIPT_FILENAME']) == "init.php"):
28
  exit;
29
  endif;
30
  if(!defined('IWP_MMB_CLIENT_VERSION'))
31
- define('IWP_MMB_CLIENT_VERSION', '1.4.3');
32
 
33
 
34
 
@@ -262,7 +262,7 @@ if( !function_exists('iwp_mmb_convert_wperror_obj_to_arr')){
262
  if( !function_exists ( 'iwp_mmb_response' )) {
263
 
264
  function iwp_mmb_response($response = false, $success = true)
265
- {
266
  $return = array();
267
 
268
  $response = iwp_mmb_convert_wperror_obj_to_arr($response,'initial');
@@ -1694,60 +1694,122 @@ if(!function_exists('iwp_mmb_convert_data')){
1694
  }
1695
  }
1696
 
1697
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1698
 
1699
  if(!function_exists('iwp_mmb_create_backup_table')){
1700
  function iwp_mmb_create_backup_table(){
1701
  global $wpdb;
 
 
 
1702
 
1703
- $IWP_MMB_BACKUP_TABLE_VERSION = get_site_option( 'iwp_backup_table_version' );
1704
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
1705
 
1706
- if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1') == -1){
1707
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1708
-
1709
- $sql = "
1710
- CREATE TABLE IF NOT EXISTS $table_name (
1711
- `ID` int(11) NOT NULL AUTO_INCREMENT,
1712
- `historyID` int(11) NOT NULL,
1713
- `taskName` varchar(255) NOT NULL,
1714
- `action` varchar(50) NOT NULL,
1715
- `type` varchar(50) NOT NULL,
1716
- `category` varchar(50) NOT NULL,
1717
- `stage` varchar(255) NOT NULL,
1718
- `status` varchar(255) NOT NULL,
1719
- `finalStatus` varchar(50) DEFAULT NULL,
1720
- `statusMsg` varchar(255) NOT NULL,
1721
- `requestParams` text NOT NULL,
1722
- `responseParams` longtext,
1723
- `taskResults` text,
1724
- `startTime` int(11) DEFAULT NULL,
1725
- `endTime` int(11) NOT NULL,
1726
- PRIMARY KEY (`ID`)
1727
- ) ENGINE=InnoDB;
1728
- ";
1729
-
1730
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1731
- dbDelta( $sql );
1732
-
1733
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1734
- //echo "table creation failed";
1735
- $table_created = false;
1736
- }
1737
- else{
1738
 
1739
- iwp_mmb_convert_data();
1740
- $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1741
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1742
 
1743
- }else{
1744
- $table_created = true;
1745
- $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
 
 
1746
  }
1747
  }
1748
-
1749
- if(!empty($_NEW_IWP_MMB_BACKUP_TABLE_VERSION)){
1750
- add_option( "iwp_backup_table_version", $_NEW_IWP_MMB_BACKUP_TABLE_VERSION);
1751
  }
1752
  }
1753
  }
4
  Plugin URI: http://infinitewp.com/
5
  Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
  Author: Revmakx
7
+ Version: 1.5.0
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
28
  exit;
29
  endif;
30
  if(!defined('IWP_MMB_CLIENT_VERSION'))
31
+ define('IWP_MMB_CLIENT_VERSION', '1.5.0');
32
 
33
 
34
 
262
  if( !function_exists ( 'iwp_mmb_response' )) {
263
 
264
  function iwp_mmb_response($response = false, $success = true)
265
+ {
266
  $return = array();
267
 
268
  $response = iwp_mmb_convert_wperror_obj_to_arr($response,'initial');
1694
  }
1695
  }
1696
 
1697
+ if(!function_exists('iwp_mmb_alter_backup_table')){
1698
+ function iwp_mmb_alter_backup_table(){
1699
+ $IWP_MMB_BACKUP_TABLE_VERSION = get_site_option('iwp_backup_table_version');
1700
+
1701
+ if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1.1') != -1){
1702
+ return true;
1703
+ }
1704
+ global $wpdb;
1705
+ if(method_exists($wpdb, 'get_charset_collate')){
1706
+ $charset_collate = $wpdb->get_charset_collate();
1707
+ }
1708
+
1709
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
1710
+
1711
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1712
+ if (!empty($charset_collate)){
1713
+ $cachecollation = $charset_collate;
1714
+ }
1715
+ else{
1716
+ $cachecollation = ' CHARACTER SET utf8 COLLATE utf8_general_ci ';
1717
+ }
1718
+
1719
+ $sql = array();
1720
+
1721
+ $sql[] = "alter table " . $table_name . " change `taskName` `taskName` VARBINARY(255);";
1722
+ $sql[] = "alter table " . $table_name . " change `taskName` `taskName` VARCHAR(255) $cachecollation not null;";
1723
+
1724
+ $sql[] = "alter table " . $table_name . " change action action VARBINARY(50);";
1725
+ $sql[] = "alter table " . $table_name . " change action action VARCHAR(50) $cachecollation not null ;";
1726
+
1727
+ $sql[] = "alter table " . $table_name . " change type type VARBINARY(50);";
1728
+ $sql[] = "alter table " . $table_name . " change type type VARCHAR(50) $cachecollation not null ;";
1729
+
1730
+ $sql[] = "alter table " . $table_name . " change category category VARBINARY(50);";
1731
+ $sql[] = "alter table " . $table_name . " change category category VARCHAR(50) $cachecollation not null ;";
1732
+
1733
+ $sql[] = "alter table " . $table_name . " change stage stage VARBINARY(255);";
1734
+ $sql[] = "alter table " . $table_name . " change stage stage VARCHAR(255) $cachecollation not null ;";
1735
+
1736
+ $sql[] = "alter table " . $table_name . " change status status VARBINARY(255);";
1737
+ $sql[] = "alter table " . $table_name . " change status status VARCHAR(255) $cachecollation not null ;";
1738
+
1739
+ $sql[] = "alter table " . $table_name . " change finalStatus finalStatus VARBINARY(50);";
1740
+ $sql[] = "alter table " . $table_name . " change finalStatus finalStatus VARCHAR(50) $cachecollation default null ;";
1741
+
1742
+ $sql[] = "alter table " . $table_name . " change statusMsg statusMsg VARBINARY(255);";
1743
+ $sql[] = "alter table " . $table_name . " change statusMsg statusMsg VARCHAR(255) $cachecollation not null ;";
1744
+
1745
+ $sql[] = "alter table " . $table_name . " change requestParams requestParams BLOB;";
1746
+ $sql[] = "alter table " . $table_name . " change requestParams requestParams TEXT $cachecollation not null;";
1747
+
1748
+ $sql[] = "alter table " . $table_name . " change responseParams responseParams LONGBLOB;";
1749
+ $sql[] = "alter table " . $table_name . " change responseParams responseParams LONGTEXT $cachecollation ;";
1750
+
1751
+ $sql[] = "alter table " . $table_name . " change taskResults taskResults BLOB;";
1752
+ $sql[] = "alter table " . $table_name . " change taskResults taskResults TEXT $cachecollation ;";
1753
+
1754
+ $sql[] = "ALTER TABLE " . $table_name . " CHARACTER SET utf8;";
1755
+ $this_reurn = array();
1756
+ foreach($sql as $v){
1757
+ //global $wpdb;
1758
+ $this_reurn[] = $wpdb->query($v);
1759
+ }
1760
+ update_option( "iwp_backup_table_version", '1.1.1');
1761
+ }
1762
+ }
1763
+ }
1764
 
1765
  if(!function_exists('iwp_mmb_create_backup_table')){
1766
  function iwp_mmb_create_backup_table(){
1767
  global $wpdb;
1768
+ if(method_exists($wpdb, 'get_charset_collate')){
1769
+ $charset_collate = $wpdb->get_charset_collate();
1770
+ }
1771
 
1772
+ $IWP_MMB_BACKUP_TABLE_VERSION = get_site_option('iwp_backup_table_version');
1773
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
1774
 
1775
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){
1776
+ if (!empty($charset_collate)){
1777
+ $cachecollation = $charset_collate;
1778
+ }
1779
+ else{
1780
+ $cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
1781
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1782
 
1783
+ $sql = "
1784
+ CREATE TABLE IF NOT EXISTS $table_name (
1785
+ `ID` int(11) NOT NULL AUTO_INCREMENT,
1786
+ `historyID` int(11) NOT NULL,
1787
+ `taskName` varchar(255) NOT NULL,
1788
+ `action` varchar(50) NOT NULL,
1789
+ `type` varchar(50) NOT NULL,
1790
+ `category` varchar(50) NOT NULL,
1791
+ `stage` varchar(255) NOT NULL,
1792
+ `status` varchar(255) NOT NULL,
1793
+ `finalStatus` varchar(50) DEFAULT NULL,
1794
+ `statusMsg` varchar(255) NOT NULL,
1795
+ `requestParams` text NOT NULL,
1796
+ `responseParams` longtext,
1797
+ `taskResults` text,
1798
+ `startTime` int(11) DEFAULT NULL,
1799
+ `endTime` int(11) NOT NULL,
1800
+ PRIMARY KEY (`ID`)
1801
+ )".$cachecollation." ;
1802
+ ";
1803
 
1804
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1805
+ dbDelta( $sql );
1806
+
1807
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1808
+ update_option( "iwp_backup_table_version", '1.1.1');
1809
  }
1810
  }
1811
+ else if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1.1') == -1){
1812
+ iwp_mmb_alter_backup_table();
 
1813
  }
1814
  }
1815
  }
lib/amazon/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInitc0e9593f4594291c0bfbb43cf84f3f53::getLoader();
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Aws.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common;
18
+
19
+ use Aws\Common\Facade\Facade;
20
+ use Guzzle\Service\Builder\ServiceBuilder;
21
+ use Guzzle\Service\Builder\ServiceBuilderLoader;
22
+
23
+ /**
24
+ * Base class for interacting with web service clients
25
+ */
26
+ class Aws extends ServiceBuilder
27
+ {
28
+ /**
29
+ * @var string Current version of the SDK
30
+ */
31
+ const VERSION = '2.7.27';
32
+
33
+ /**
34
+ * Create a new service locator for the AWS SDK
35
+ *
36
+ * You can configure the service locator is four different ways:
37
+ *
38
+ * 1. Use the default configuration file shipped with the SDK that wires class names with service short names and
39
+ * specify global parameters to add to every definition (e.g. key, secret, credentials, etc)
40
+ *
41
+ * 2. Use a custom configuration file that extends the default config and supplies credentials for each service.
42
+ *
43
+ * 3. Use a custom config file that wires services to custom short names for services.
44
+ *
45
+ * 4. If you are on Amazon EC2, you can use the default configuration file and not provide any credentials so that
46
+ * you are using InstanceProfile credentials.
47
+ *
48
+ * @param array|string $config The full path to a .php or .js|.json file, or an associative array of data
49
+ * to use as global parameters to pass to each service.
50
+ * @param array $globalParameters Global parameters to pass to every service as it is instantiated.
51
+ *
52
+ * @return Aws
53
+ */
54
+ public static function factory($config = null, array $globalParameters = array())
55
+ {
56
+ if (!$config) {
57
+ // If nothing is passed in, then use the default configuration file with credentials from the environment
58
+ $config = self::getDefaultServiceDefinition();
59
+ } elseif (is_array($config)) {
60
+ // If an array was passed, then use the default configuration file with parameter overrides
61
+ $globalParameters = $config;
62
+ $config = self::getDefaultServiceDefinition();
63
+ }
64
+
65
+ $loader = new ServiceBuilderLoader();
66
+ $loader->addAlias('_aws', self::getDefaultServiceDefinition())
67
+ ->addAlias('_sdk1', __DIR__ . '/Resources/sdk1-config.php');
68
+
69
+ return $loader->load($config, $globalParameters);
70
+ }
71
+
72
+ /**
73
+ * Get the full path to the default service builder definition file
74
+ *
75
+ * @return string
76
+ */
77
+ public static function getDefaultServiceDefinition()
78
+ {
79
+ return __DIR__ . '/Resources/aws-config.php';
80
+ }
81
+
82
+ /**
83
+ * Returns the configuration for the service builder
84
+ *
85
+ * @return array
86
+ */
87
+ public function getConfig()
88
+ {
89
+ return $this->builderConfig;
90
+ }
91
+
92
+ /**
93
+ * Enables the facades for the clients defined in the service builder
94
+ *
95
+ * @param string|null $namespace The namespace that the facades should be mounted to. Defaults to global namespace
96
+ *
97
+ * @return Aws
98
+ */
99
+ public function enableFacades($namespace = null)
100
+ {
101
+ Facade::mountFacades($this, $namespace);
102
+
103
+ return $this;
104
+ }
105
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Aws\Common\Aws;
20
+ use Aws\Common\Credentials\CredentialsInterface;
21
+ use Aws\Common\Enum\ClientOptions as Options;
22
+ use Aws\Common\Exception\InvalidArgumentException;
23
+ use Aws\Common\Exception\TransferException;
24
+ use Aws\Common\RulesEndpointProvider;
25
+ use Aws\Common\Signature\EndpointSignatureInterface;
26
+ use Aws\Common\Signature\SignatureInterface;
27
+ use Aws\Common\Signature\SignatureListener;
28
+ use Aws\Common\Waiter\WaiterClassFactory;
29
+ use Aws\Common\Waiter\CompositeWaiterFactory;
30
+ use Aws\Common\Waiter\WaiterFactoryInterface;
31
+ use Aws\Common\Waiter\WaiterConfigFactory;
32
+ use Guzzle\Common\Collection;
33
+ use Guzzle\Http\Exception\CurlException;
34
+ use Guzzle\Http\QueryAggregator\DuplicateAggregator;
35
+ use Guzzle\Service\Client;
36
+ use Guzzle\Service\Description\ServiceDescriptionInterface;
37
+
38
+ /**
39
+ * Abstract AWS client
40
+ */
41
+ abstract class AbstractClient extends Client implements AwsClientInterface
42
+ {
43
+ /** @var CredentialsInterface AWS credentials */
44
+ protected $credentials;
45
+
46
+ /** @var SignatureInterface Signature implementation of the service */
47
+ protected $signature;
48
+
49
+ /** @var WaiterFactoryInterface Factory used to create waiter classes */
50
+ protected $waiterFactory;
51
+
52
+ /** @var DuplicateAggregator Cached query aggregator*/
53
+ protected $aggregator;
54
+
55
+ /**
56
+ * {@inheritdoc}
57
+ */
58
+ public static function getAllEvents()
59
+ {
60
+ return array_merge(Client::getAllEvents(), array(
61
+ 'client.region_changed',
62
+ 'client.credentials_changed',
63
+ ));
64
+ }
65
+
66
+ /**
67
+ * @param CredentialsInterface $credentials AWS credentials
68
+ * @param SignatureInterface $signature Signature implementation
69
+ * @param Collection $config Configuration options
70
+ *
71
+ * @throws InvalidArgumentException if an endpoint provider isn't provided
72
+ */
73
+ public function __construct(CredentialsInterface $credentials, SignatureInterface $signature, Collection $config)
74
+ {
75
+ // Bootstrap with Guzzle
76
+ parent::__construct($config->get(Options::BASE_URL), $config);
77
+ $this->credentials = $credentials;
78
+ $this->signature = $signature;
79
+ $this->aggregator = new DuplicateAggregator();
80
+
81
+ // Make sure the user agent is prefixed by the SDK version
82
+ $this->setUserAgent('aws-sdk-php2/' . Aws::VERSION, true);
83
+
84
+ // Add the event listener so that requests are signed before they are sent
85
+ $dispatcher = $this->getEventDispatcher();
86
+ $dispatcher->addSubscriber(new SignatureListener($credentials, $signature));
87
+
88
+ if ($backoff = $config->get(Options::BACKOFF)) {
89
+ $dispatcher->addSubscriber($backoff, -255);
90
+ }
91
+ }
92
+
93
+ public function __call($method, $args)
94
+ {
95
+ if (substr($method, 0, 3) === 'get' && substr($method, -8) === 'Iterator') {
96
+ // Allow magic method calls for iterators (e.g. $client->get<CommandName>Iterator($params))
97
+ $commandOptions = isset($args[0]) ? $args[0] : null;
98
+ $iteratorOptions = isset($args[1]) ? $args[1] : array();
99
+ return $this->getIterator(substr($method, 3, -8), $commandOptions, $iteratorOptions);
100
+ } elseif (substr($method, 0, 9) == 'waitUntil') {
101
+ // Allow magic method calls for waiters (e.g. $client->waitUntil<WaiterName>($params))
102
+ return $this->waitUntil(substr($method, 9), isset($args[0]) ? $args[0]: array());
103
+ } else {
104
+ return parent::__call(ucfirst($method), $args);
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Get an endpoint for a specific region from a service description
110
+ * @deprecated This function will no longer be updated to work with new regions.
111
+ */
112
+ public static function getEndpoint(ServiceDescriptionInterface $description, $region, $scheme)
113
+ {
114
+ try {
115
+ $service = $description->getData('endpointPrefix');
116
+ $provider = RulesEndpointProvider::fromDefaults();
117
+ $result = $provider(array(
118
+ 'service' => $service,
119
+ 'region' => $region,
120
+ 'scheme' => $scheme
121
+ ));
122
+ return $result['endpoint'];
123
+ } catch (\InvalidArgumentException $e) {
124
+ throw new InvalidArgumentException($e->getMessage(), 0, $e);
125
+ }
126
+ }
127
+
128
+ public function getCredentials()
129
+ {
130
+ return $this->credentials;
131
+ }
132
+
133
+ public function setCredentials(CredentialsInterface $credentials)
134
+ {
135
+ $formerCredentials = $this->credentials;
136
+ $this->credentials = $credentials;
137
+
138
+ // Dispatch an event that the credentials have been changed
139
+ $this->dispatch('client.credentials_changed', array(
140
+ 'credentials' => $credentials,
141
+ 'former_credentials' => $formerCredentials,
142
+ ));
143
+
144
+ return $this;
145
+ }
146
+
147
+ public function getSignature()
148
+ {
149
+ return $this->signature;
150
+ }
151
+
152
+ public function getRegions()
153
+ {
154
+ return $this->serviceDescription->getData('regions');
155
+ }
156
+
157
+ public function getRegion()
158
+ {
159
+ return $this->getConfig(Options::REGION);
160
+ }
161
+
162
+ public function setRegion($region)
163
+ {
164
+ $config = $this->getConfig();
165
+ $formerRegion = $config->get(Options::REGION);
166
+ $global = $this->serviceDescription->getData('globalEndpoint');
167
+ $provider = $config->get('endpoint_provider');
168
+
169
+ if (!$provider) {
170
+ throw new \RuntimeException('No endpoint provider configured');
171
+ }
172
+
173
+ // Only change the region if the service does not have a global endpoint
174
+ if (!$global || $this->serviceDescription->getData('namespace') === 'S3') {
175
+
176
+ $endpoint = call_user_func(
177
+ $provider,
178
+ array(
179
+ 'scheme' => $config->get(Options::SCHEME),
180
+ 'region' => $region,
181
+ 'service' => $config->get(Options::SERVICE)
182
+ )
183
+ );
184
+
185
+ $this->setBaseUrl($endpoint['endpoint']);
186
+ $config->set(Options::BASE_URL, $endpoint['endpoint']);
187
+ $config->set(Options::REGION, $region);
188
+
189
+ // Update the signature if necessary
190
+ $signature = $this->getSignature();
191
+ if ($signature instanceof EndpointSignatureInterface) {
192
+ /** @var $signature EndpointSignatureInterface */
193
+ $signature->setRegionName($region);
194
+ }
195
+
196
+ // Dispatch an event that the region has been changed
197
+ $this->dispatch('client.region_changed', array(
198
+ 'region' => $region,
199
+ 'former_region' => $formerRegion,
200
+ ));
201
+ }
202
+
203
+ return $this;
204
+ }
205
+
206
+ public function waitUntil($waiter, array $input = array())
207
+ {
208
+ $this->getWaiter($waiter, $input)->wait();
209
+
210
+ return $this;
211
+ }
212
+
213
+ public function getWaiter($waiter, array $input = array())
214
+ {
215
+ return $this->getWaiterFactory()->build($waiter)
216
+ ->setClient($this)
217
+ ->setConfig($input);
218
+ }
219
+
220
+ public function setWaiterFactory(WaiterFactoryInterface $waiterFactory)
221
+ {
222
+ $this->waiterFactory = $waiterFactory;
223
+
224
+ return $this;
225
+ }
226
+
227
+ public function getWaiterFactory()
228
+ {
229
+ if (!$this->waiterFactory) {
230
+ $clientClass = get_class($this);
231
+ // Use a composite factory that checks for classes first, then config waiters
232
+ $this->waiterFactory = new CompositeWaiterFactory(array(
233
+ new WaiterClassFactory(substr($clientClass, 0, strrpos($clientClass, '\\')) . '\\Waiter')
234
+ ));
235
+ if ($this->getDescription()) {
236
+ $waiterConfig = $this->getDescription()->getData('waiters') ?: array();
237
+ $this->waiterFactory->addFactory(new WaiterConfigFactory($waiterConfig));
238
+ }
239
+ }
240
+
241
+ return $this->waiterFactory;
242
+ }
243
+
244
+ public function getApiVersion()
245
+ {
246
+ return $this->serviceDescription->getApiVersion();
247
+ }
248
+
249
+ /**
250
+ * {@inheritdoc}
251
+ * @throws \Aws\Common\Exception\TransferException
252
+ */
253
+ public function send($requests)
254
+ {
255
+ try {
256
+ return parent::send($requests);
257
+ } catch (CurlException $e) {
258
+ $wrapped = new TransferException($e->getMessage(), null, $e);
259
+ $wrapped->setCurlHandle($e->getCurlHandle())
260
+ ->setCurlInfo($e->getCurlInfo())
261
+ ->setError($e->getError(), $e->getErrorNo())
262
+ ->setRequest($e->getRequest());
263
+ throw $wrapped;
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Ensures that the duplicate query string aggregator is used so that
269
+ * query string values are sent over the wire as foo=bar&foo=baz.
270
+ * {@inheritdoc}
271
+ */
272
+ public function createRequest(
273
+ $method = 'GET',
274
+ $uri = null,
275
+ $headers = null,
276
+ $body = null,
277
+ array $options = array()
278
+ ) {
279
+ $request = parent::createRequest($method, $uri, $headers, $body, $options);
280
+ $request->getQuery()->setAggregator($this->aggregator);
281
+ return $request;
282
+ }
283
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/AwsClientInterface.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Aws\Common\Signature\SignatureInterface;
21
+ use Aws\Common\Waiter\WaiterFactoryInterface;
22
+ use Aws\Common\Waiter\WaiterInterface;
23
+ use Guzzle\Service\ClientInterface;
24
+
25
+ /**
26
+ * Interface that all AWS clients implement
27
+ */
28
+ interface AwsClientInterface extends ClientInterface
29
+ {
30
+ /**
31
+ * Returns the AWS credentials associated with the client
32
+ *
33
+ * @return CredentialsInterface
34
+ */
35
+ public function getCredentials();
36
+
37
+ /**
38
+ * Sets the credentials object associated with the client
39
+ *
40
+ * @param CredentialsInterface $credentials Credentials object to use
41
+ *
42
+ * @return self
43
+ */
44
+ public function setCredentials(CredentialsInterface $credentials);
45
+
46
+ /**
47
+ * Returns the signature implementation used with the client
48
+ *
49
+ * @return SignatureInterface
50
+ */
51
+ public function getSignature();
52
+
53
+ /**
54
+ * Get a list of available regions and region data
55
+ *
56
+ * @return array
57
+ */
58
+ public function getRegions();
59
+
60
+ /**
61
+ * Get the name of the region to which the client is configured to send requests
62
+ *
63
+ * @return string
64
+ */
65
+ public function getRegion();
66
+
67
+ /**
68
+ * Change the region to which the client is configured to send requests
69
+ *
70
+ * @param string $region Name of the region
71
+ *
72
+ * @return self
73
+ */
74
+ public function setRegion($region);
75
+
76
+ /**
77
+ * Get the waiter factory being used by the client
78
+ *
79
+ * @return WaiterFactoryInterface
80
+ */
81
+ public function getWaiterFactory();
82
+
83
+ /**
84
+ * Set the waiter factory to use with the client
85
+ *
86
+ * @param WaiterFactoryInterface $waiterFactory Factory used to create waiters
87
+ *
88
+ * @return self
89
+ */
90
+ public function setWaiterFactory(WaiterFactoryInterface $waiterFactory);
91
+
92
+ /**
93
+ * Wait until a resource is available or an associated waiter returns true
94
+ *
95
+ * @param string $waiter Name of the waiter
96
+ * @param array $input Values used as input for the underlying operation and to control the waiter
97
+ *
98
+ * @return self
99
+ */
100
+ public function waitUntil($waiter, array $input = array());
101
+
102
+ /**
103
+ * Get a named waiter object
104
+ *
105
+ * @param string $waiter Name of the waiter
106
+ * @param array $input Values used as input for the underlying operation and to control the waiter
107
+ *
108
+ * @return WaiterInterface
109
+ */
110
+ public function getWaiter($waiter, array $input = array());
111
+
112
+ /**
113
+ * Get the API version of the client (e.g. 2006-03-01)
114
+ *
115
+ * @return string
116
+ */
117
+ public function getApiVersion();
118
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/ClientBuilder.php ADDED
@@ -0,0 +1,526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Aws\Common\Credentials\Credentials;
20
+ use Aws\Common\Credentials\CredentialsInterface;
21
+ use Aws\Common\Credentials\NullCredentials;
22
+ use Aws\Common\Enum\ClientOptions as Options;
23
+ use Aws\Common\Exception\ExceptionListener;
24
+ use Aws\Common\Exception\InvalidArgumentException;
25
+ use Aws\Common\Exception\NamespaceExceptionFactory;
26
+ use Aws\Common\Exception\Parser\DefaultXmlExceptionParser;
27
+ use Aws\Common\Exception\Parser\ExceptionParserInterface;
28
+ use Aws\Common\Iterator\AwsResourceIteratorFactory;
29
+ use Aws\Common\RulesEndpointProvider;
30
+ use Aws\Common\Signature\EndpointSignatureInterface;
31
+ use Aws\Common\Signature\SignatureInterface;
32
+ use Aws\Common\Signature\SignatureV2;
33
+ use Aws\Common\Signature\SignatureV3Https;
34
+ use Aws\Common\Signature\SignatureV4;
35
+ use Guzzle\Common\Collection;
36
+ use Guzzle\Plugin\Backoff\BackoffPlugin;
37
+ use Guzzle\Plugin\Backoff\CurlBackoffStrategy;
38
+ use Guzzle\Plugin\Backoff\ExponentialBackoffStrategy;
39
+ use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
40
+ use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy;
41
+ use Guzzle\Service\Description\ServiceDescription;
42
+ use Guzzle\Service\Resource\ResourceIteratorClassFactory;
43
+ use Guzzle\Log\LogAdapterInterface;
44
+ use Guzzle\Log\ClosureLogAdapter;
45
+ use Guzzle\Plugin\Backoff\BackoffLogger;
46
+
47
+ /**
48
+ * Builder for creating AWS service clients
49
+ */
50
+ class ClientBuilder
51
+ {
52
+ /**
53
+ * @var array Default client config
54
+ */
55
+ protected static $commonConfigDefaults = array('scheme' => 'https');
56
+
57
+ /**
58
+ * @var array Default client requirements
59
+ */
60
+ protected static $commonConfigRequirements = array(Options::SERVICE_DESCRIPTION);
61
+
62
+ /**
63
+ * @var string The namespace of the client
64
+ */
65
+ protected $clientNamespace;
66
+
67
+ /**
68
+ * @var array The config options
69
+ */
70
+ protected $config = array();
71
+
72
+ /**
73
+ * @var array The config defaults
74
+ */
75
+ protected $configDefaults = array();
76
+
77
+ /**
78
+ * @var array The config requirements
79
+ */
80
+ protected $configRequirements = array();
81
+
82
+ /**
83
+ * @var ExceptionParserInterface The Parser interface for the client
84
+ */
85
+ protected $exceptionParser;
86
+
87
+ /**
88
+ * @var array Array of configuration data for iterators available for the client
89
+ */
90
+ protected $iteratorsConfig = array();
91
+
92
+ /** @var string */
93
+ private $clientClass;
94
+
95
+ /** @var string */
96
+ private $serviceName;
97
+
98
+ /**
99
+ * Factory method for creating the client builder
100
+ *
101
+ * @param string $namespace The namespace of the client
102
+ *
103
+ * @return ClientBuilder
104
+ */
105
+ public static function factory($namespace = null)
106
+ {
107
+ return new static($namespace);
108
+ }
109
+
110
+ /**
111
+ * Constructs a client builder
112
+ *
113
+ * @param string $namespace The namespace of the client
114
+ */
115
+ public function __construct($namespace = null)
116
+ {
117
+ $this->clientNamespace = $namespace;
118
+
119
+ // Determine service and class name
120
+ $this->clientClass = 'Aws\Common\Client\DefaultClient';
121
+
122
+ if ($this->clientNamespace) {
123
+ $this->serviceName = substr($this->clientNamespace, strrpos($this->clientNamespace, '\\') + 1);
124
+ $this->clientClass = $this->clientNamespace . '\\' . $this->serviceName . 'Client';
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Sets the config options
130
+ *
131
+ * @param array|Collection $config The config options
132
+ *
133
+ * @return ClientBuilder
134
+ */
135
+ public function setConfig($config)
136
+ {
137
+ $this->config = $this->processArray($config);
138
+
139
+ return $this;
140
+ }
141
+
142
+ /**
143
+ * Sets the config options' defaults
144
+ *
145
+ * @param array|Collection $defaults The default values
146
+ *
147
+ * @return ClientBuilder
148
+ */
149
+ public function setConfigDefaults($defaults)
150
+ {
151
+ $this->configDefaults = $this->processArray($defaults);
152
+
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Sets the required config options
158
+ *
159
+ * @param array|Collection $required The required config options
160
+ *
161
+ * @return ClientBuilder
162
+ */
163
+ public function setConfigRequirements($required)
164
+ {
165
+ $this->configRequirements = $this->processArray($required);
166
+
167
+ return $this;
168
+ }
169
+
170
+ /**
171
+ * Sets the exception parser. If one is not provided the builder will use
172
+ * the default XML exception parser.
173
+ *
174
+ * @param ExceptionParserInterface $parser The exception parser
175
+ *
176
+ * @return ClientBuilder
177
+ */
178
+ public function setExceptionParser(ExceptionParserInterface $parser)
179
+ {
180
+ $this->exceptionParser = $parser;
181
+
182
+ return $this;
183
+ }
184
+
185
+ /**
186
+ * Set the configuration for the client's iterators
187
+ *
188
+ * @param array $config Configuration data for client's iterators
189
+ *
190
+ * @return ClientBuilder
191
+ */
192
+ public function setIteratorsConfig(array $config)
193
+ {
194
+ $this->iteratorsConfig = $config;
195
+
196
+ return $this;
197
+ }
198
+
199
+ /**
200
+ * Performs the building logic using all of the parameters that have been
201
+ * set and falling back to default values. Returns an instantiate service
202
+ * client with credentials prepared and plugins attached.
203
+ *
204
+ * @return AwsClientInterface
205
+ * @throws InvalidArgumentException
206
+ */
207
+ public function build()
208
+ {
209
+ // Resolve configuration
210
+ $config = Collection::fromConfig(
211
+ $this->config,
212
+ array_merge(self::$commonConfigDefaults, $this->configDefaults),
213
+ (self::$commonConfigRequirements + $this->configRequirements)
214
+ );
215
+
216
+ if ($config[Options::VERSION] === 'latest') {
217
+ $config[Options::VERSION] = constant("{$this->clientClass}::LATEST_API_VERSION");
218
+ }
219
+
220
+ if (!isset($config['endpoint_provider'])) {
221
+ $config['endpoint_provider'] = RulesEndpointProvider::fromDefaults();
222
+ }
223
+
224
+ // Resolve the endpoint, signature, and credentials
225
+ $description = $this->updateConfigFromDescription($config);
226
+ $signature = $this->getSignature($description, $config);
227
+ $credentials = $this->getCredentials($config);
228
+ $this->extractHttpConfig($config);
229
+
230
+ // Resolve exception parser
231
+ if (!$this->exceptionParser) {
232
+ $this->exceptionParser = new DefaultXmlExceptionParser();
233
+ }
234
+
235
+ // Resolve backoff strategy
236
+ $backoff = $config->get(Options::BACKOFF);
237
+ if ($backoff === null) {
238
+ $backoff = $this->createDefaultBackoff();
239
+ $config->set(Options::BACKOFF, $backoff);
240
+ }
241
+
242
+ if ($backoff) {
243
+ $this->addBackoffLogger($backoff, $config);
244
+ }
245
+
246
+ /** @var $client AwsClientInterface */
247
+ $client = new $this->clientClass($credentials, $signature, $config);
248
+ $client->setDescription($description);
249
+
250
+ // Add exception marshaling so that more descriptive exception are thrown
251
+ if ($this->clientNamespace) {
252
+ $exceptionFactory = new NamespaceExceptionFactory(
253
+ $this->exceptionParser,
254
+ "{$this->clientNamespace}\\Exception",
255
+ "{$this->clientNamespace}\\Exception\\{$this->serviceName}Exception"
256
+ );
257
+ $client->addSubscriber(new ExceptionListener($exceptionFactory));
258
+ }
259
+
260
+ // Add the UserAgentPlugin to append to the User-Agent header of requests
261
+ $client->addSubscriber(new UserAgentListener());
262
+
263
+ // Filters used for the cache plugin
264
+ $client->getConfig()->set(
265
+ 'params.cache.key_filter',
266
+ 'header=date,x-amz-date,x-amz-security-token,x-amzn-authorization'
267
+ );
268
+
269
+ // Set the iterator resource factory based on the provided iterators config
270
+ $client->setResourceIteratorFactory(new AwsResourceIteratorFactory(
271
+ $this->iteratorsConfig,
272
+ new ResourceIteratorClassFactory($this->clientNamespace . '\\Iterator')
273
+ ));
274
+
275
+ // Disable parameter validation if needed
276
+ if ($config->get(Options::VALIDATION) === false) {
277
+ $params = $config->get('command.params') ?: array();
278
+ $params['command.disable_validation'] = true;
279
+ $config->set('command.params', $params);
280
+ }
281
+
282
+ return $client;
283
+ }
284
+
285
+ /**
286
+ * Add backoff logging to the backoff plugin if needed
287
+ *
288
+ * @param BackoffPlugin $plugin Backoff plugin
289
+ * @param Collection $config Configuration settings
290
+ *
291
+ * @throws InvalidArgumentException
292
+ */
293
+ protected function addBackoffLogger(BackoffPlugin $plugin, Collection $config)
294
+ {
295
+ // The log option can be set to `debug` or an instance of a LogAdapterInterface
296
+ if ($logger = $config->get(Options::BACKOFF_LOGGER)) {
297
+ $format = $config->get(Options::BACKOFF_LOGGER_TEMPLATE);
298
+ if ($logger === 'debug') {
299
+ $logger = new ClosureLogAdapter(function ($message) {
300
+ trigger_error($message . "\n");
301
+ });
302
+ } elseif (!($logger instanceof LogAdapterInterface)) {
303
+ throw new InvalidArgumentException(
304
+ Options::BACKOFF_LOGGER . ' must be set to `debug` or an instance of '
305
+ . 'Guzzle\\Common\\Log\\LogAdapterInterface'
306
+ );
307
+ }
308
+ // Create the plugin responsible for logging exponential backoff retries
309
+ $logPlugin = new BackoffLogger($logger);
310
+ // You can specify a custom format or use the default
311
+ if ($format) {
312
+ $logPlugin->setTemplate($format);
313
+ }
314
+ $plugin->addSubscriber($logPlugin);
315
+ }
316
+ }
317
+
318
+ /**
319
+ * Ensures that an array (e.g. for config data) is actually in array form
320
+ *
321
+ * @param array|Collection $array The array data
322
+ *
323
+ * @return array
324
+ * @throws InvalidArgumentException if the arg is not an array or Collection
325
+ */
326
+ protected function processArray($array)
327
+ {
328
+ if ($array instanceof Collection) {
329
+ $array = $array->getAll();
330
+ }
331
+
332
+ if (!is_array($array)) {
333
+ throw new InvalidArgumentException('The config must be provided as an array or Collection.');
334
+ }
335
+
336
+ return $array;
337
+ }
338
+
339
+ /**
340
+ * Update a configuration object from a service description
341
+ *
342
+ * @param Collection $config Config to update
343
+ *
344
+ * @return ServiceDescription
345
+ * @throws InvalidArgumentException
346
+ */
347
+ protected function updateConfigFromDescription(Collection $config)
348
+ {
349
+ $description = $config->get(Options::SERVICE_DESCRIPTION);
350
+ if (!($description instanceof ServiceDescription)) {
351
+ // Inject the version into the sprintf template if it is a string
352
+ if (is_string($description)) {
353
+ $description = sprintf($description, $config->get(Options::VERSION));
354
+ }
355
+ $description = ServiceDescription::factory($description);
356
+ $config->set(Options::SERVICE_DESCRIPTION, $description);
357
+ }
358
+
359
+ if (!$config->get(Options::SERVICE)) {
360
+ $config->set(Options::SERVICE, $description->getData('endpointPrefix'));
361
+ }
362
+
363
+ if ($iterators = $description->getData('iterators')) {
364
+ $this->setIteratorsConfig($iterators);
365
+ }
366
+
367
+ $this->handleRegion($config);
368
+ $this->handleEndpoint($config);
369
+
370
+ return $description;
371
+ }
372
+
373
+ /**
374
+ * Return an appropriate signature object for a a client based on the
375
+ * "signature" configuration setting, or the default signature specified in
376
+ * a service description. The signature can be set to a valid signature
377
+ * version identifier string or an instance of Aws\Common\Signature\SignatureInterface.
378
+ *
379
+ * @param ServiceDescription $description Description that holds a signature option
380
+ * @param Collection $config Configuration options
381
+ *
382
+ * @return SignatureInterface
383
+ * @throws InvalidArgumentException
384
+ */
385
+ protected function getSignature(ServiceDescription $description, Collection $config)
386
+ {
387
+ // If a custom signature has not been provided, then use the default
388
+ // signature setting specified in the service description.
389
+ $signature = $config->get(Options::SIGNATURE) ?: $description->getData('signatureVersion');
390
+
391
+ if (is_string($signature)) {
392
+ if ($signature == 'v4') {
393
+ $signature = new SignatureV4();
394
+ } elseif ($signature == 'v2') {
395
+ $signature = new SignatureV2();
396
+ } elseif ($signature == 'v3https') {
397
+ $signature = new SignatureV3Https();
398
+ } else {
399
+ throw new InvalidArgumentException("Invalid signature type: {$signature}");
400
+ }
401
+ } elseif (!($signature instanceof SignatureInterface)) {
402
+ throw new InvalidArgumentException('The provided signature is not '
403
+ . 'a signature version string or an instance of '
404
+ . 'Aws\\Common\\Signature\\SignatureInterface');
405
+ }
406
+
407
+ // Allow a custom service name or region value to be provided
408
+ if ($signature instanceof EndpointSignatureInterface) {
409
+
410
+ // Determine the service name to use when signing
411
+ $signature->setServiceName($config->get(Options::SIGNATURE_SERVICE)
412
+ ?: $description->getData('signingName')
413
+ ?: $description->getData('endpointPrefix'));
414
+
415
+ // Determine the region to use when signing requests
416
+ $signature->setRegionName($config->get(Options::SIGNATURE_REGION) ?: $config->get(Options::REGION));
417
+ }
418
+
419
+ return $signature;
420
+ }
421
+
422
+ protected function getCredentials(Collection $config)
423
+ {
424
+ $credentials = $config->get(Options::CREDENTIALS);
425
+
426
+ if (is_array($credentials)) {
427
+ $credentials = Credentials::factory($credentials);
428
+ } elseif ($credentials === false) {
429
+ $credentials = new NullCredentials();
430
+ } elseif (!$credentials instanceof CredentialsInterface) {
431
+ $credentials = Credentials::factory($config);
432
+ }
433
+
434
+ return $credentials;
435
+ }
436
+
437
+ private function handleRegion(Collection $config)
438
+ {
439
+ // Make sure a valid region is set
440
+ $region = $config[Options::REGION];
441
+ $description = $config[Options::SERVICE_DESCRIPTION];
442
+ $global = $description->getData('globalEndpoint');
443
+
444
+ if (!$global && !$region) {
445
+ throw new InvalidArgumentException(
446
+ 'A region is required when using ' . $description->getData('serviceFullName')
447
+ );
448
+ } elseif ($global && !$region) {
449
+ $config[Options::REGION] = 'us-east-1';
450
+ }
451
+ }
452
+
453
+ private function handleEndpoint(Collection $config)
454
+ {
455
+ // Alias "endpoint" with "base_url" for forwards compatibility.
456
+ if ($config['endpoint']) {
457
+ $config[Options::BASE_URL] = $config['endpoint'];
458
+ return;
459
+ }
460
+
461
+ if ($config[Options::BASE_URL]) {
462
+ return;
463
+ }
464
+
465
+ $endpoint = call_user_func(
466
+ $config['endpoint_provider'],
467
+ array(
468
+ 'scheme' => $config[Options::SCHEME],
469
+ 'region' => $config[Options::REGION],
470
+ 'service' => $config[Options::SERVICE]
471
+ )
472
+ );
473
+
474
+ $config[Options::BASE_URL] = $endpoint['endpoint'];
475
+
476
+ // Set a signature if one was not explicitly provided.
477
+ if (!$config->hasKey(Options::SIGNATURE)
478
+ && isset($endpoint['signatureVersion'])
479
+ ) {
480
+ $config->set(Options::SIGNATURE, $endpoint['signatureVersion']);
481
+ }
482
+
483
+ // The the signing region if endpoint rule specifies one.
484
+ if (isset($endpoint['credentialScope'])) {
485
+ $scope = $endpoint['credentialScope'];
486
+ if (isset($scope['region'])) {
487
+ $config->set(Options::SIGNATURE_REGION, $scope['region']);
488
+ }
489
+ }
490
+ }
491
+
492
+ private function createDefaultBackoff()
493
+ {
494
+ return new BackoffPlugin(
495
+ // Retry failed requests up to 3 times if it is determined that the request can be retried
496
+ new TruncatedBackoffStrategy(3,
497
+ // Retry failed requests with 400-level responses due to throttling
498
+ new ThrottlingErrorChecker($this->exceptionParser,
499
+ // Retry failed requests due to transient network or cURL problems
500
+ new CurlBackoffStrategy(null,
501
+ // Retry failed requests with 500-level responses
502
+ new HttpBackoffStrategy(array(500, 503, 509),
503
+ // Retry requests that failed due to expired credentials
504
+ new ExpiredCredentialsChecker($this->exceptionParser,
505
+ new ExponentialBackoffStrategy()
506
+ )
507
+ )
508
+ )
509
+ )
510
+ )
511
+ );
512
+ }
513
+
514
+ private function extractHttpConfig(Collection $config)
515
+ {
516
+ $http = $config['http'];
517
+
518
+ if (!is_array($http)) {
519
+ return;
520
+ }
521
+
522
+ if (isset($http['verify'])) {
523
+ $config[Options::SSL_CERT] = $http['verify'];
524
+ }
525
+ }
526
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/DefaultClient.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Aws\Common\Enum\ClientOptions as Options;
20
+ use Guzzle\Common\Collection;
21
+
22
+ /**
23
+ * Generic client for interacting with an AWS service
24
+ */
25
+ class DefaultClient extends AbstractClient
26
+ {
27
+ /**
28
+ * Factory method to create a default client using an array of configuration options.
29
+ *
30
+ * The following array keys and values are available options:
31
+ *
32
+ * Credential options ((`key`, `secret`, and optional `token`) OR `credentials` is required):
33
+ *
34
+ * - key: AWS Access Key ID
35
+ * - secret: AWS secret access key
36
+ * - credentials: You can optionally provide a custom `Aws\Common\Credentials\CredentialsInterface` object
37
+ * - token: Custom AWS security token to use with request authentication. Please note that not all services accept temporary credentials. See http://docs.aws.amazon.com/STS/latest/UsingSTS/UsingTokens.html
38
+ * - token.ttd: UNIX timestamp for when the custom credentials expire
39
+ * - credentials.cache.key: Optional custom cache key to use with the credentials
40
+ * - credentials.client: Pass this option to specify a custom `Guzzle\Http\ClientInterface` to use if your credentials require a HTTP request (e.g. RefreshableInstanceProfileCredentials)
41
+ *
42
+ * Region and endpoint options (Some services do not require a region while others do. Check the service specific user guide documentation for details):
43
+ *
44
+ * - region: Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
45
+ * - scheme: URI Scheme of the base URL (e.g. 'https', 'http') used when endpoint is not supplied
46
+ * - endpoint: Allows you to specify a custom endpoint instead of building one from the region and scheme
47
+ *
48
+ * Generic client options:
49
+ *
50
+ * - signature: Overrides the signature used by the client. Clients will always choose an appropriate default signature. However, it can be useful to override this with a custom setting. This can be set to "v4", "v3https", "v2" or an instance of Aws\Common\Signature\SignatureInterface.
51
+ * - ssl.certificate_authority: Set to true to use the bundled CA cert or pass the full path to an SSL certificate bundle
52
+ * - curl.options: Associative of CURLOPT_* cURL options to add to each request
53
+ * - client.backoff.logger: `Guzzle\Log\LogAdapterInterface` object used to log backoff retries. Use 'debug' to emit PHP warnings when a retry is issued.
54
+ * - client.backoff.logger.template: Optional template to use for exponential backoff log messages. See `Guzzle\Plugin\Backoff\BackoffLogger` for formatting information.
55
+ *
56
+ * @param array|Collection $config Client configuration data
57
+ *
58
+ * @return self
59
+ */
60
+ public static function factory($config = array())
61
+ {
62
+ return ClientBuilder::factory()
63
+ ->setConfig($config)
64
+ ->setConfigDefaults(array(Options::SCHEME => 'https'))
65
+ ->build();
66
+ }
67
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/ExpiredCredentialsChecker.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Aws\Common\Credentials\AbstractRefreshableCredentials;
20
+ use Aws\Common\Client\AwsClientInterface;
21
+ use Aws\Common\Exception\Parser\ExceptionParserInterface;
22
+ use Guzzle\Http\Exception\HttpException;
23
+ use Guzzle\Http\Message\RequestInterface;
24
+ use Guzzle\Http\Message\Response;
25
+ use Guzzle\Plugin\Backoff\BackoffStrategyInterface;
26
+ use Guzzle\Plugin\Backoff\AbstractBackoffStrategy;
27
+
28
+ /**
29
+ * Backoff logic that handles retrying requests when credentials expire
30
+ */
31
+ class ExpiredCredentialsChecker extends AbstractBackoffStrategy
32
+ {
33
+ /**
34
+ * @var array Array of known retrying exception codes
35
+ */
36
+ protected $retryable = array(
37
+ 'RequestExpired' => true,
38
+ 'ExpiredTokenException' => true,
39
+ 'ExpiredToken' => true
40
+ );
41
+
42
+ /**
43
+ * @var ExceptionParserInterface Exception parser used to parse exception responses
44
+ */
45
+ protected $exceptionParser;
46
+
47
+ public function __construct(ExceptionParserInterface $exceptionParser, BackoffStrategyInterface $next = null) {
48
+ $this->exceptionParser = $exceptionParser;
49
+ $this->next = $next;
50
+ }
51
+
52
+ public function makesDecision()
53
+ {
54
+ return true;
55
+ }
56
+
57
+ protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null)
58
+ {
59
+ if ($response && $response->isClientError()) {
60
+
61
+ $parts = $this->exceptionParser->parse($request, $response);
62
+ if (!isset($this->retryable[$parts['code']]) || !$request->getClient()) {
63
+ return null;
64
+ }
65
+
66
+ /** @var $client AwsClientInterface */
67
+ $client = $request->getClient();
68
+ // Only retry if the credentials can be refreshed
69
+ if (!($client->getCredentials() instanceof AbstractRefreshableCredentials)) {
70
+ return null;
71
+ }
72
+
73
+ // Resign the request using new credentials
74
+ $client->getSignature()->signRequest($request, $client->getCredentials()->setExpiration(-1));
75
+
76
+ // Retry immediately with no delay
77
+ return 0;
78
+ }
79
+ }
80
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/ThrottlingErrorChecker.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Aws\Common\Exception\Parser\ExceptionParserInterface;
20
+ use Guzzle\Http\Exception\HttpException;
21
+ use Guzzle\Http\Message\RequestInterface;
22
+ use Guzzle\Http\Message\Response;
23
+ use Guzzle\Plugin\Backoff\BackoffStrategyInterface;
24
+ use Guzzle\Plugin\Backoff\AbstractBackoffStrategy;
25
+
26
+ /**
27
+ * Backoff logic that handles throttling exceptions from services
28
+ */
29
+ class ThrottlingErrorChecker extends AbstractBackoffStrategy
30
+ {
31
+ /** @var array Whitelist of exception codes (as indexes) that indicate throttling */
32
+ protected static $throttlingExceptions = array(
33
+ 'RequestLimitExceeded' => true,
34
+ 'Throttling' => true,
35
+ 'ThrottlingException' => true,
36
+ 'ProvisionedThroughputExceededException' => true,
37
+ 'RequestThrottled' => true,
38
+ );
39
+
40
+ /**
41
+ * @var ExceptionParserInterface Exception parser used to parse exception responses
42
+ */
43
+ protected $exceptionParser;
44
+
45
+ public function __construct(ExceptionParserInterface $exceptionParser, BackoffStrategyInterface $next = null)
46
+ {
47
+ $this->exceptionParser = $exceptionParser;
48
+ if ($next) {
49
+ $this->setNext($next);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * {@inheritdoc}
55
+ */
56
+ public function makesDecision()
57
+ {
58
+ return true;
59
+ }
60
+
61
+ /**
62
+ * {@inheritdoc}
63
+ */
64
+ protected function getDelay(
65
+ $retries,
66
+ RequestInterface $request,
67
+ Response $response = null,
68
+ HttpException $e = null
69
+ ) {
70
+ if ($response && $response->isClientError()) {
71
+ $parts = $this->exceptionParser->parse($request, $response);
72
+ return isset(self::$throttlingExceptions[$parts['code']]) ? true : null;
73
+ }
74
+ }
75
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/UploadBodyListener.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+ use Guzzle\Common\Event;
21
+ use Guzzle\Http\EntityBody;
22
+ use Guzzle\Service\Command\AbstractCommand as Command;
23
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
24
+
25
+ /**
26
+ * Prepares the body parameter of a command such that the parameter is more flexible (e.g. accepts file handles) with
27
+ * the value it accepts but converts it to the correct format for the command. Also looks for a "Filename" parameter.
28
+ */
29
+ class UploadBodyListener implements EventSubscriberInterface
30
+ {
31
+ /**
32
+ * @var array The names of the commands of which to modify the body parameter
33
+ */
34
+ protected $commands;
35
+
36
+ /**
37
+ * @var string The key for the upload body parameter
38
+ */
39
+ protected $bodyParameter;
40
+
41
+ /**
42
+ * @var string The key for the source file parameter
43
+ */
44
+ protected $sourceParameter;
45
+
46
+ /**
47
+ * @param array $commands The commands to modify
48
+ * @param string $bodyParameter The key for the body parameter
49
+ * @param string $sourceParameter The key for the source file parameter
50
+ */
51
+ public function __construct(array $commands, $bodyParameter = 'Body', $sourceParameter = 'SourceFile')
52
+ {
53
+ $this->commands = $commands;
54
+ $this->bodyParameter = (string) $bodyParameter;
55
+ $this->sourceParameter = (string) $sourceParameter;
56
+ }
57
+
58
+ /**
59
+ * {@inheritdoc}
60
+ */
61
+ public static function getSubscribedEvents()
62
+ {
63
+ return array('command.before_prepare' => array('onCommandBeforePrepare'));
64
+ }
65
+
66
+ /**
67
+ * Converts filenames and file handles into EntityBody objects before the command is validated
68
+ *
69
+ * @param Event $event Event emitted
70
+ * @throws InvalidArgumentException
71
+ */
72
+ public function onCommandBeforePrepare(Event $event)
73
+ {
74
+ /** @var $command Command */
75
+ $command = $event['command'];
76
+ if (in_array($command->getName(), $this->commands)) {
77
+ // Get the interesting parameters
78
+ $source = $command->get($this->sourceParameter);
79
+ $body = $command->get($this->bodyParameter);
80
+
81
+ // If a file path is passed in then get the file handle
82
+ if (is_string($source) && file_exists($source)) {
83
+ $body = fopen($source, 'r');
84
+ }
85
+
86
+ // Prepare the body parameter and remove the source file parameter
87
+ if (null !== $body) {
88
+ $command->remove($this->sourceParameter);
89
+ $command->set($this->bodyParameter, EntityBody::factory($body));
90
+ } else {
91
+ throw new InvalidArgumentException("You must specify a non-null value for the {$this->bodyParameter} or {$this->sourceParameter} parameters.");
92
+ }
93
+ }
94
+ }
95
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Client/UserAgentListener.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Client;
18
+
19
+ use Guzzle\Common\Event;
20
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
21
+
22
+ /**
23
+ * Listener used to append strings to the User-Agent header of a request based
24
+ * on the `ua.append` option. `ua.append` can contain a string or array of values.
25
+ */
26
+ class UserAgentListener implements EventSubscriberInterface
27
+ {
28
+ /**
29
+ * @var string Option used to store User-Agent modifiers
30
+ */
31
+ const OPTION = 'ua.append';
32
+
33
+ /**
34
+ * {@inheritdoc}
35
+ */
36
+ public static function getSubscribedEvents()
37
+ {
38
+ return array('command.before_send' => 'onBeforeSend');
39
+ }
40
+
41
+ /**
42
+ * Adds strings to the User-Agent header using the `ua.append` parameter of a command
43
+ *
44
+ * @param Event $event Event emitted
45
+ */
46
+ public function onBeforeSend(Event $event)
47
+ {
48
+ $command = $event['command'];
49
+ if ($userAgentAppends = $command->get(self::OPTION)) {
50
+ $request = $command->getRequest();
51
+ $userAgent = (string) $request->getHeader('User-Agent');
52
+ foreach ((array) $userAgentAppends as $append) {
53
+ $append = ' ' . $append;
54
+ if (strpos($userAgent, $append) === false) {
55
+ $userAgent .= $append;
56
+ }
57
+ }
58
+ $request->setHeader('User-Agent', $userAgent);
59
+ }
60
+ }
61
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/AwsQueryVisitor.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Aws\Common\Command;
4
+
5
+ use Guzzle\Http\Message\RequestInterface;
6
+ use Guzzle\Service\Description\Parameter;
7
+ use Guzzle\Service\Command\CommandInterface;
8
+ use Guzzle\Service\Command\LocationVisitor\Request\AbstractRequestVisitor;
9
+
10
+ /**
11
+ * Location visitor used to serialize AWS query parameters (e.g. EC2, SES, SNS, SQS, etc) as POST fields
12
+ */
13
+ class AwsQueryVisitor extends AbstractRequestVisitor
14
+ {
15
+ private $fqname;
16
+
17
+ public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
18
+ {
19
+ $this->fqname = $command->getName();
20
+ $query = array();
21
+ $this->customResolver($value, $param, $query, $param->getWireName());
22
+ $request->addPostFields($query);
23
+ }
24
+
25
+ /**
26
+ * Map nested parameters into the location_key based parameters
27
+ *
28
+ * @param array $value Value to map
29
+ * @param Parameter $param Parameter that holds information about the current key
30
+ * @param array $query Built up query string values
31
+ * @param string $prefix String to prepend to sub query values
32
+ */
33
+ protected function customResolver($value, Parameter $param, array &$query, $prefix = '')
34
+ {
35
+ switch ($param->getType()) {
36
+ case 'object':
37
+ $this->resolveObject($param, $value, $prefix, $query);
38
+ break;
39
+ case 'array':
40
+ $this->resolveArray($param, $value, $prefix, $query);
41
+ break;
42
+ default:
43
+ $query[$prefix] = $param->filter($value);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Custom handling for objects
49
+ *
50
+ * @param Parameter $param Parameter for the object
51
+ * @param array $value Value that is set for this parameter
52
+ * @param string $prefix Prefix for the resulting key
53
+ * @param array $query Query string array passed by reference
54
+ */
55
+ protected function resolveObject(Parameter $param, array $value, $prefix, array &$query)
56
+ {
57
+ // Maps are implemented using additional properties
58
+ $hasAdditionalProperties = ($param->getAdditionalProperties() instanceof Parameter);
59
+ $additionalPropertyCount = 0;
60
+
61
+ foreach ($value as $name => $v) {
62
+ if ($subParam = $param->getProperty($name)) {
63
+ // if the parameter was found by name as a regular property
64
+ $key = $prefix . '.' . $subParam->getWireName();
65
+ $this->customResolver($v, $subParam, $query, $key);
66
+ } elseif ($hasAdditionalProperties) {
67
+ // Handle map cases like &Attribute.1.Name=<name>&Attribute.1.Value=<value>
68
+ $additionalPropertyCount++;
69
+ $data = $param->getData();
70
+ $keyName = isset($data['keyName']) ? $data['keyName'] : 'key';
71
+ $valueName = isset($data['valueName']) ? $data['valueName'] : 'value';
72
+ $query["{$prefix}.{$additionalPropertyCount}.{$keyName}"] = $name;
73
+ $newPrefix = "{$prefix}.{$additionalPropertyCount}.{$valueName}";
74
+ if (is_array($v)) {
75
+ $this->customResolver($v, $param->getAdditionalProperties(), $query, $newPrefix);
76
+ } else {
77
+ $query[$newPrefix] = $param->filter($v);
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Custom handling for arrays
85
+ *
86
+ * @param Parameter $param Parameter for the object
87
+ * @param array $value Value that is set for this parameter
88
+ * @param string $prefix Prefix for the resulting key
89
+ * @param array $query Query string array passed by reference
90
+ */
91
+ protected function resolveArray(Parameter $param, array $value, $prefix, array &$query)
92
+ {
93
+ static $serializeEmpty = array(
94
+ 'SetLoadBalancerPoliciesForBackendServer' => 1,
95
+ 'SetLoadBalancerPoliciesOfListener' => 1,
96
+ 'UpdateStack' => 1
97
+ );
98
+
99
+ // For BC, serialize empty lists for specific operations
100
+ if (!$value) {
101
+ if (isset($serializeEmpty[$this->fqname])) {
102
+ $query[$prefix] = '';
103
+ }
104
+ return;
105
+ }
106
+
107
+ $offset = $param->getData('offset') ?: 1;
108
+ foreach ($value as $index => $v) {
109
+ $index += $offset;
110
+ if (is_array($v) && $items = $param->getItems()) {
111
+ $this->customResolver($v, $items, $query, $prefix . '.' . $index);
112
+ } else {
113
+ $query[$prefix . '.' . $index] = $param->filter($v);
114
+ }
115
+ }
116
+ }
117
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/JsonCommand.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Command;
18
+
19
+ use Guzzle\Service\Command\OperationCommand;
20
+ use Guzzle\Http\Curl\CurlHandle;
21
+
22
+ /**
23
+ * Adds AWS JSON body functionality to dynamically generated HTTP requests
24
+ */
25
+ class JsonCommand extends OperationCommand
26
+ {
27
+ /**
28
+ * {@inheritdoc}
29
+ */
30
+ protected function build()
31
+ {
32
+ parent::build();
33
+
34
+ // Ensure that the body of the request ALWAYS includes some JSON. By default, this is an empty object.
35
+ if (!$this->request->getBody()) {
36
+ $this->request->setBody('{}');
37
+ }
38
+
39
+ // Never send the Expect header when interacting with a JSON query service
40
+ $this->request->removeHeader('Expect');
41
+
42
+ // Always send JSON requests as a raw string rather than using streams to avoid issues with
43
+ // cURL error code 65: "necessary data rewind wasn't possible".
44
+ // This could be removed after PHP addresses https://bugs.php.net/bug.php?id=47204
45
+ $this->request->getCurlOptions()->set(CurlHandle::BODY_AS_STRING, true);
46
+ }
47
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/QueryCommand.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Command;
18
+
19
+ use Guzzle\Service\Command\OperationCommand;
20
+
21
+ /**
22
+ * Adds AWS Query service serialization
23
+ */
24
+ class QueryCommand extends OperationCommand
25
+ {
26
+ /**
27
+ * @var AwsQueryVisitor
28
+ */
29
+ protected static $queryVisitor;
30
+
31
+ /**
32
+ * @var XmlResponseLocationVisitor
33
+ */
34
+ protected static $xmlVisitor;
35
+
36
+ /**
37
+ * Register the aws.query visitor
38
+ */
39
+ protected function init()
40
+ {
41
+ // @codeCoverageIgnoreStart
42
+ if (!self::$queryVisitor) {
43
+ self::$queryVisitor = new AwsQueryVisitor();
44
+ }
45
+ if (!self::$xmlVisitor) {
46
+ self::$xmlVisitor = new XmlResponseLocationVisitor();
47
+ }
48
+ // @codeCoverageIgnoreEnd
49
+
50
+ $this->getRequestSerializer()->addVisitor('aws.query', self::$queryVisitor);
51
+ $this->getResponseParser()->addVisitor('xml', self::$xmlVisitor);
52
+ }
53
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Command/XmlResponseLocationVisitor.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Aws\Common\Command;
4
+
5
+ use Guzzle\Service\Description\Operation;
6
+ use Guzzle\Service\Command\CommandInterface;
7
+ use Guzzle\Http\Message\Response;
8
+ use Guzzle\Service\Description\Parameter;
9
+ use Guzzle\Service\Command\LocationVisitor\Response\XmlVisitor;
10
+
11
+ /**
12
+ * Class used for custom AWS XML response parsing of query services
13
+ */
14
+ class XmlResponseLocationVisitor extends XmlVisitor
15
+ {
16
+ /**
17
+ * {@inheritdoc}
18
+ */
19
+ public function before(CommandInterface $command, array &$result)
20
+ {
21
+ parent::before($command, $result);
22
+
23
+ // Unwrapped wrapped responses
24
+ $operation = $command->getOperation();
25
+ if ($operation->getServiceDescription()->getData('resultWrapped')) {
26
+ $wrappingNode = $operation->getName() . 'Result';
27
+ if (isset($result[$wrappingNode])) {
28
+ $result = $result[$wrappingNode] + $result;
29
+ unset($result[$wrappingNode]);
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Accounts for wrapper nodes
36
+ * {@inheritdoc}
37
+ */
38
+ public function visit(
39
+ CommandInterface $command,
40
+ Response $response,
41
+ Parameter $param,
42
+ &$value,
43
+ $context = null
44
+ ) {
45
+ parent::visit($command, $response, $param, $value, $context);
46
+
47
+ // Account for wrapper nodes (e.g. RDS, ElastiCache, etc)
48
+ if ($param->getData('wrapper')) {
49
+ $wireName = $param->getWireName();
50
+ $value += $value[$wireName];
51
+ unset($value[$wireName]);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Filter used when converting XML maps into associative arrays in service descriptions
57
+ *
58
+ * @param array $value Value to filter
59
+ * @param string $entryName Name of each entry
60
+ * @param string $keyName Name of each key
61
+ * @param string $valueName Name of each value
62
+ *
63
+ * @return array Returns the map of the XML data
64
+ */
65
+ public static function xmlMap($value, $entryName, $keyName, $valueName)
66
+ {
67
+ $result = array();
68
+ foreach ($value as $entry) {
69
+ $result[$entry[$keyName]] = $entry[$valueName];
70
+ }
71
+
72
+ return $result;
73
+ }
74
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/AbstractCredentialsDecorator.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Credentials;
18
+
19
+ /**
20
+ * Abstract credentials decorator
21
+ */
22
+ class AbstractCredentialsDecorator implements CredentialsInterface
23
+ {
24
+ /**
25
+ * @var CredentialsInterface Wrapped credentials object
26
+ */
27
+ protected $credentials;
28
+
29
+ /**
30
+ * Constructs a new BasicAWSCredentials object, with the specified AWS
31
+ * access key and AWS secret key
32
+ *
33
+ * @param CredentialsInterface $credentials
34
+ */
35
+ public function __construct(CredentialsInterface $credentials)
36
+ {
37
+ $this->credentials = $credentials;
38
+ }
39
+
40
+ /**
41
+ * {@inheritdoc}
42
+ */
43
+ public function serialize()
44
+ {
45
+ return $this->credentials->serialize();
46
+ }
47
+
48
+ /**
49
+ * {@inheritdoc}
50
+ */
51
+ public function unserialize($serialized)
52
+ {
53
+ $this->credentials = new Credentials('', '');
54
+ $this->credentials->unserialize($serialized);
55
+ }
56
+
57
+ /**
58
+ * {@inheritdoc}
59
+ */
60
+ public function getAccessKeyId()
61
+ {
62
+ return $this->credentials->getAccessKeyId();
63
+ }
64
+
65
+ /**
66
+ * {@inheritdoc}
67
+ */
68
+ public function getSecretKey()
69
+ {
70
+ return $this->credentials->getSecretKey();
71
+ }
72
+
73
+ /**
74
+ * {@inheritdoc}
75
+ */
76
+ public function getSecurityToken()
77
+ {
78
+ return $this->credentials->getSecurityToken();
79
+ }
80
+
81
+ /**
82
+ * {@inheritdoc}
83
+ */
84
+ public function getExpiration()
85
+ {
86
+ return $this->credentials->getExpiration();
87
+ }
88
+
89
+ /**
90
+ * {@inheritdoc}
91
+ */
92
+ public function isExpired()
93
+ {
94
+ return $this->credentials->isExpired();
95
+ }
96
+
97
+ /**
98
+ * {@inheritdoc}
99
+ */
100
+ public function setAccessKeyId($key)
101
+ {
102
+ $this->credentials->setAccessKeyId($key);
103
+
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * {@inheritdoc}
109
+ */
110
+ public function setSecretKey($secret)
111
+ {
112
+ $this->credentials->setSecretKey($secret);
113
+
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * {@inheritdoc}
119
+ */
120
+ public function setSecurityToken($token)
121
+ {
122
+ $this->credentials->setSecurityToken($token);
123
+
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * {@inheritdoc}
129
+ */
130
+ public function setExpiration($timestamp)
131
+ {
132
+ $this->credentials->setExpiration($timestamp);
133
+
134
+ return $this;
135
+ }
136
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/AbstractRefreshableCredentials.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Credentials;
18
+
19
+ /**
20
+ * Abstract decorator to provide a foundation for refreshable credentials
21
+ */
22
+ abstract class AbstractRefreshableCredentials extends AbstractCredentialsDecorator
23
+ {
24
+ /**
25
+ * {@inheritdoc}
26
+ */
27
+ public function getAccessKeyId()
28
+ {
29
+ if ($this->credentials->isExpired()) {
30
+ $this->refresh();
31
+ }
32
+
33
+ return $this->credentials->getAccessKeyId();
34
+ }
35
+
36
+ /**
37
+ * {@inheritdoc}
38
+ */
39
+ public function getSecretKey()
40
+ {
41
+ if ($this->credentials->isExpired()) {
42
+ $this->refresh();
43
+ }
44
+
45
+ return $this->credentials->getSecretKey();
46
+ }
47
+
48
+ /**
49
+ * {@inheritdoc}
50
+ */
51
+ public function getSecurityToken()
52
+ {
53
+ if ($this->credentials->isExpired()) {
54
+ $this->refresh();
55
+ }
56
+
57
+ return $this->credentials->getSecurityToken();
58
+ }
59
+
60
+ /**
61
+ * {@inheritdoc}
62
+ */
63
+ public function serialize()
64
+ {
65
+ if ($this->credentials->isExpired()) {
66
+ $this->refresh();
67
+ }
68
+
69
+ return $this->credentials->serialize();
70
+ }
71
+
72
+ /**
73
+ * Attempt to get new credentials
74
+ */
75
+ abstract protected function refresh();
76
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/CacheableCredentials.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Credentials;
18
+
19
+ use Guzzle\Cache\CacheAdapterInterface;
20
+
21
+ /**
22
+ * Credentials decorator used to implement caching credentials
23
+ */
24
+ class CacheableCredentials extends AbstractRefreshableCredentials
25
+ {
26
+ /**
27
+ * @var CacheAdapterInterface Cache adapter used to store credentials
28
+ */
29
+ protected $cache;
30
+
31
+ /**
32
+ * @var string Cache key used to store the credentials
33
+ */
34
+ protected $cacheKey;
35
+
36
+ /**
37
+ * CacheableCredentials is a decorator that decorates other credentials
38
+ *
39
+ * @param CredentialsInterface $credentials Credentials to adapt
40
+ * @param CacheAdapterInterface $cache Cache to use to store credentials
41
+ * @param string $cacheKey Cache key of the credentials
42
+ */
43
+ public function __construct(CredentialsInterface $credentials, CacheAdapterInterface $cache, $cacheKey)
44
+ {
45
+ $this->credentials = $credentials;
46
+ $this->cache = $cache;
47
+ $this->cacheKey = $cacheKey;
48
+ }
49
+
50
+ /**
51
+ * Attempt to get new credentials from cache or from the adapted object
52
+ */
53
+ protected function refresh()
54
+ {
55
+ if (!$cache = $this->cache->fetch($this->cacheKey)) {
56
+ // The credentials were not found, so try again and cache if new
57
+ $this->credentials->getAccessKeyId();
58
+ if (!$this->credentials->isExpired()) {
59
+ // The credentials were updated, so cache them
60
+ $this->cache->save($this->cacheKey, $this->credentials, $this->credentials->getExpiration() - time());
61
+ }
62
+ } else {
63
+ // The credentials were found in cache, so update the adapter object
64
+ // if the cached credentials are not expired
65
+ if (!$cache->isExpired()) {
66
+ $this->credentials->setAccessKeyId($cache->getAccessKeyId());
67
+ $this->credentials->setSecretKey($cache->getSecretKey());
68
+ $this->credentials->setSecurityToken($cache->getSecurityToken());
69
+ $this->credentials->setExpiration($cache->getExpiration());
70
+ }
71
+ }
72
+ }
73
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/Credentials.php ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Credentials;
18
+
19
+ use Aws\Common\Enum\ClientOptions as Options;
20
+ use Aws\Common\Exception\InvalidArgumentException;
21
+ use Aws\Common\Exception\RequiredExtensionNotLoadedException;
22
+ use Aws\Common\Exception\RuntimeException;
23
+ use Guzzle\Common\FromConfigInterface;
24
+ use Guzzle\Cache\CacheAdapterInterface;
25
+ use Guzzle\Cache\DoctrineCacheAdapter;
26
+ use Guzzle\Common\Collection;
27
+
28
+ /**
29
+ * Basic implementation of the AWSCredentials interface that allows callers to
30
+ * pass in the AWS access key and secret access in the constructor.
31
+ */
32
+ class Credentials implements CredentialsInterface, FromConfigInterface
33
+ {
34
+ const ENV_KEY = 'AWS_ACCESS_KEY_ID';
35
+ const ENV_SECRET = 'AWS_SECRET_KEY';
36
+ const ENV_SECRET_ACCESS_KEY = 'AWS_SECRET_ACCESS_KEY';
37
+ const ENV_PROFILE = 'AWS_PROFILE';
38
+
39
+ /** @var string AWS Access Key ID */
40
+ protected $key;
41
+
42
+ /** @var string AWS Secret Access Key */
43
+ protected $secret;
44
+
45
+ /** @var string AWS Security Token */
46
+ protected $token;
47
+
48
+ /** @var int Time to die of token */
49
+ protected $ttd;
50
+
51
+ /**
52
+ * Get the available keys for the factory method
53
+ *
54
+ * @return array
55
+ */
56
+ public static function getConfigDefaults()
57
+ {
58
+ return array(
59
+ Options::KEY => null,
60
+ Options::SECRET => null,
61
+ Options::TOKEN => null,
62
+ Options::TOKEN_TTD => null,
63
+ Options::PROFILE => null,
64
+ Options::CREDENTIALS_CACHE => null,
65
+ Options::CREDENTIALS_CACHE_KEY => null,
66
+ Options::CREDENTIALS_CLIENT => null
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Factory method for creating new credentials. This factory method will
72
+ * create the appropriate credentials object with appropriate decorators
73
+ * based on the passed configuration options.
74
+ *
75
+ * @param array $config Options to use when instantiating the credentials
76
+ *
77
+ * @return CredentialsInterface
78
+ * @throws InvalidArgumentException If the caching options are invalid
79
+ * @throws RuntimeException If using the default cache and APC is disabled
80
+ */
81
+ public static function factory($config = array())
82
+ {
83
+ // Add default key values
84
+ foreach (self::getConfigDefaults() as $key => $value) {
85
+ if (!isset($config[$key])) {
86
+ $config[$key] = $value;
87
+ }
88
+ }
89
+
90
+ // Start tracking the cache key
91
+ $cacheKey = $config[Options::CREDENTIALS_CACHE_KEY];
92
+
93
+ // Create the credentials object
94
+ if (!$config[Options::KEY] || !$config[Options::SECRET]) {
95
+ $credentials = self::createFromEnvironment($config);
96
+ // If no cache key was set, use the crc32 hostname of the server
97
+ $cacheKey = $cacheKey ?: 'credentials_' . crc32(gethostname());
98
+ } else {
99
+ // Instantiate using short or long term credentials
100
+ $credentials = new static(
101
+ $config[Options::KEY],
102
+ $config[Options::SECRET],
103
+ $config[Options::TOKEN],
104
+ $config[Options::TOKEN_TTD]
105
+ );
106
+ // If no cache key was set, use the access key ID
107
+ $cacheKey = $cacheKey ?: 'credentials_' . $config[Options::KEY];
108
+ }
109
+
110
+ // Check if the credentials are refreshable, and if so, configure caching
111
+ $cache = $config[Options::CREDENTIALS_CACHE];
112
+ if ($cacheKey && $cache) {
113
+ $credentials = self::createCache($credentials, $cache, $cacheKey);
114
+ }
115
+
116
+ return $credentials;
117
+ }
118
+
119
+ /**
120
+ * Create credentials from the credentials ini file in the HOME directory.
121
+ *
122
+ * @param string|null $profile Pass a specific profile to use. If no
123
+ * profile is specified we will attempt to use
124
+ * the value specified in the AWS_PROFILE
125
+ * environment variable. If AWS_PROFILE is not
126
+ * set, the "default" profile is used.
127
+ * @param string|null $filename Pass a string to specify the location of the
128
+ * credentials files. If null is passed, the
129
+ * SDK will attempt to find the configuration
130
+ * file at in your HOME directory at
131
+ * ~/.aws/credentials.
132
+ * @return CredentialsInterface
133
+ * @throws \RuntimeException if the file cannot be found, if the file is
134
+ * invalid, or if the profile is invalid.
135
+ */
136
+ public static function fromIni($profile = null, $filename = null)
137
+ {
138
+ if (!$filename) {
139
+ $filename = self::getHomeDir() . '/.aws/credentials';
140
+ }
141
+
142
+ if (!$profile) {
143
+ $profile = self::getEnvVar(self::ENV_PROFILE) ?: 'default';
144
+ }
145
+
146
+ if (!file_exists($filename) || !($data = parse_ini_file($filename, true))) {
147
+ throw new \RuntimeException("Invalid AWS credentials file: {$filename}.");
148
+ }
149
+
150
+ if (empty($data[$profile])) {
151
+ throw new \RuntimeException("Invalid AWS credentials profile {$profile} in {$filename}.");
152
+ }
153
+
154
+ return new self(
155
+ $data[$profile]['aws_access_key_id'],
156
+ $data[$profile]['aws_secret_access_key'],
157
+ isset($data[$profile]['aws_security_token'])
158
+ ? $data[$profile]['aws_security_token']
159
+ : null
160
+ );
161
+ }
162
+
163
+ /**
164
+ * Constructs a new BasicAWSCredentials object, with the specified AWS
165
+ * access key and AWS secret key
166
+ *
167
+ * @param string $accessKeyId AWS access key ID
168
+ * @param string $secretAccessKey AWS secret access key
169
+ * @param string $token Security token to use
170
+ * @param int $expiration UNIX timestamp for when credentials expire
171
+ */
172
+ public function __construct($accessKeyId, $secretAccessKey, $token = null, $expiration = null)
173
+ {
174
+ $this->key = trim($accessKeyId);
175
+ $this->secret = trim($secretAccessKey);
176
+ $this->token = $token;
177
+ $this->ttd = $expiration;
178
+ }
179
+
180
+ public function serialize()
181
+ {
182
+ return json_encode(array(
183
+ Options::KEY => $this->key,
184
+ Options::SECRET => $this->secret,
185
+ Options::TOKEN => $this->token,
186
+ Options::TOKEN_TTD => $this->ttd
187
+ ));
188
+ }
189
+
190
+ public function unserialize($serialized)
191
+ {
192
+ $data = json_decode($serialized, true);
193
+ $this->key = $data[Options::KEY];
194
+ $this->secret = $data[Options::SECRET];
195
+ $this->token = $data[Options::TOKEN];
196
+ $this->ttd = $data[Options::TOKEN_TTD];
197
+ }
198
+
199
+ public function getAccessKeyId()
200
+ {
201
+ return $this->key;
202
+ }
203
+
204
+ public function getSecretKey()
205
+ {
206
+ return $this->secret;
207
+ }
208
+
209
+ public function getSecurityToken()
210
+ {
211
+ return $this->token;
212
+ }
213
+
214
+ public function getExpiration()
215
+ {
216
+ return $this->ttd;
217
+ }
218
+
219
+ public function isExpired()
220
+ {
221
+ return $this->ttd !== null && time() >= $this->ttd;
222
+ }
223
+
224
+ public function setAccessKeyId($key)
225
+ {
226
+ $this->key = $key;
227
+
228
+ return $this;
229
+ }
230
+
231
+ public function setSecretKey($secret)
232
+ {
233
+ $this->secret = $secret;
234
+
235
+ return $this;
236
+ }
237
+
238
+ public function setSecurityToken($token)
239
+ {
240
+ $this->token = $token;
241
+
242
+ return $this;
243
+ }
244
+
245
+ public function setExpiration($timestamp)
246
+ {
247
+ $this->ttd = $timestamp;
248
+
249
+ return $this;
250
+ }
251
+
252
+ /**
253
+ * When no keys are provided, attempt to create them based on the
254
+ * environment or instance profile credentials.
255
+ *
256
+ * @param array|Collection $config
257
+ *
258
+ * @return CredentialsInterface
259
+ */
260
+ private static function createFromEnvironment($config)
261
+ {
262
+ // Get key and secret from ENV variables
263
+ $envKey = self::getEnvVar(self::ENV_KEY);
264
+ if (!($envSecret = self::getEnvVar(self::ENV_SECRET))) {
265
+ // Use AWS_SECRET_ACCESS_KEY if AWS_SECRET_KEY was not set.
266
+ $envSecret = self::getEnvVar(self::ENV_SECRET_ACCESS_KEY);
267
+ }
268
+
269
+ // Use credentials from the environment variables if available
270
+ if ($envKey && $envSecret) {
271
+ return new static($envKey, $envSecret);
272
+ }
273
+
274
+ // Use credentials from the ini file in HOME directory if available
275
+ $home = self::getHomeDir();
276
+ if ($home && file_exists("{$home}/.aws/credentials")) {
277
+ return self::fromIni($config[Options::PROFILE], "{$home}/.aws/credentials");
278
+ }
279
+
280
+ // Use instance profile credentials (available on EC2 instances)
281
+ return new RefreshableInstanceProfileCredentials(
282
+ new static('', '', '', 1),
283
+ $config[Options::CREDENTIALS_CLIENT]
284
+ );
285
+ }
286
+
287
+ private static function createCache(CredentialsInterface $credentials, $cache, $cacheKey)
288
+ {
289
+ if ($cache === 'true' || $cache === true) {
290
+ // If no cache adapter was provided, then create one for the user
291
+ // @codeCoverageIgnoreStart
292
+ if (!extension_loaded('apc')) {
293
+ throw new RequiredExtensionNotLoadedException('PHP has not been compiled with APC. Unable to cache '
294
+ . 'the credentials.');
295
+ } elseif (!class_exists('Doctrine\Common\Cache\ApcCache')) {
296
+ throw new RuntimeException(
297
+ 'Cannot set ' . Options::CREDENTIALS_CACHE . ' to true because the Doctrine cache component is '
298
+ . 'not installed. Either install doctrine/cache or pass in an instantiated '
299
+ . 'Guzzle\Cache\CacheAdapterInterface object'
300
+ );
301
+ }
302
+ // @codeCoverageIgnoreEnd
303
+ $cache = new DoctrineCacheAdapter(new \Doctrine\Common\Cache\ApcCache());
304
+ } elseif (!($cache instanceof CacheAdapterInterface)) {
305
+ throw new InvalidArgumentException('Unable to utilize caching with the specified options');
306
+ }
307
+
308
+ // Decorate the credentials with a cache
309
+ return new CacheableCredentials($credentials, $cache, $cacheKey);
310
+ }
311
+
312
+ private static function getHomeDir()
313
+ {
314
+ // On Linux/Unix-like systems, use the HOME environment variable
315
+ if ($homeDir = self::getEnvVar('HOME')) {
316
+ return $homeDir;
317
+ }
318
+
319
+ // Get the HOMEDRIVE and HOMEPATH values for Windows hosts
320
+ $homeDrive = self::getEnvVar('HOMEDRIVE');
321
+ $homePath = self::getEnvVar('HOMEPATH');
322
+
323
+ return ($homeDrive && $homePath) ? $homeDrive . $homePath : null;
324
+ }
325
+
326
+ /**
327
+ * Fetches the value of an environment variable by checking $_SERVER and getenv().
328
+ *
329
+ * @param string $var Name of the environment variable
330
+ *
331
+ * @return mixed|null
332
+ */
333
+ private static function getEnvVar($var)
334
+ {
335
+ return isset($_SERVER[$var]) ? $_SERVER[$var] : getenv($var);
336
+ }
337
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/CredentialsInterface.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Credentials;
18
+
19
+ /**
20
+ * Provides access to the AWS credentials used for accessing AWS services: AWS
21
+ * access key ID, secret access key, and security token. These credentials are
22
+ * used to securely sign requests to AWS services.
23
+ */
24
+ interface CredentialsInterface extends \Serializable
25
+ {
26
+ /**
27
+ * Returns the AWS access key ID for this credentials object.
28
+ *
29
+ * @return string
30
+ */
31
+ public function getAccessKeyId();
32
+
33
+ /**
34
+ * Returns the AWS secret access key for this credentials object.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getSecretKey();
39
+
40
+ /**
41
+ * Get the associated security token if available
42
+ *
43
+ * @return string|null
44
+ */
45
+ public function getSecurityToken();
46
+
47
+ /**
48
+ * Get the UNIX timestamp in which the credentials will expire
49
+ *
50
+ * @return int|null
51
+ */
52
+ public function getExpiration();
53
+
54
+ /**
55
+ * Set the AWS access key ID for this credentials object.
56
+ *
57
+ * @param string $key AWS access key ID
58
+ *
59
+ * @return self
60
+ */
61
+ public function setAccessKeyId($key);
62
+
63
+ /**
64
+ * Set the AWS secret access key for this credentials object.
65
+ *
66
+ * @param string $secret AWS secret access key
67
+ *
68
+ * @return CredentialsInterface
69
+ */
70
+ public function setSecretKey($secret);
71
+
72
+ /**
73
+ * Set the security token to use with this credentials object
74
+ *
75
+ * @param string $token Security token
76
+ *
77
+ * @return self
78
+ */
79
+ public function setSecurityToken($token);
80
+
81
+ /**
82
+ * Set the UNIX timestamp in which the credentials will expire
83
+ *
84
+ * @param int $timestamp UNIX timestamp expiration
85
+ *
86
+ * @return self
87
+ */
88
+ public function setExpiration($timestamp);
89
+
90
+ /**
91
+ * Check if the credentials are expired
92
+ *
93
+ * @return bool
94
+ */
95
+ public function isExpired();
96
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/NullCredentials.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Aws\Common\Credentials;
3
+
4
+ /**
5
+ * A blank set of credentials. AWS clients must be provided credentials, but
6
+ * there are some types of requests that do not need authentication. This class
7
+ * can be used to pivot on that scenario, and also serve as a mock credentials
8
+ * object when testing
9
+ *
10
+ * @codeCoverageIgnore
11
+ */
12
+ class NullCredentials implements CredentialsInterface
13
+ {
14
+ public function getAccessKeyId()
15
+ {
16
+ return '';
17
+ }
18
+
19
+ public function getSecretKey()
20
+ {
21
+ return '';
22
+ }
23
+
24
+ public function getSecurityToken()
25
+ {
26
+ return null;
27
+ }
28
+
29
+ public function getExpiration()
30
+ {
31
+ return null;
32
+ }
33
+
34
+ public function isExpired()
35
+ {
36
+ return false;
37
+ }
38
+
39
+ public function serialize()
40
+ {
41
+ return 'N;';
42
+ }
43
+
44
+ public function unserialize($serialized)
45
+ {
46
+ // Nothing to do here.
47
+ }
48
+
49
+ public function setAccessKeyId($key)
50
+ {
51
+ // Nothing to do here.
52
+ }
53
+
54
+ public function setSecretKey($secret)
55
+ {
56
+ // Nothing to do here.
57
+ }
58
+
59
+ public function setSecurityToken($token)
60
+ {
61
+ // Nothing to do here.
62
+ }
63
+
64
+ public function setExpiration($timestamp)
65
+ {
66
+ // Nothing to do here.
67
+ }
68
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Credentials/RefreshableInstanceProfileCredentials.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Credentials;
18
+
19
+ use Aws\Common\InstanceMetadata\InstanceMetadataClient;
20
+ use Aws\Common\Exception\InstanceProfileCredentialsException;
21
+
22
+ /**
23
+ * Credentials decorator used to implement retrieving credentials from the
24
+ * EC2 metadata server
25
+ */
26
+ class RefreshableInstanceProfileCredentials extends AbstractRefreshableCredentials
27
+ {
28
+ /**
29
+ * @var InstanceMetadataClient
30
+ */
31
+ protected $client;
32
+
33
+ /**
34
+ * Constructs a new instance profile credentials decorator
35
+ *
36
+ * @param CredentialsInterface $credentials Credentials to adapt
37
+ * @param InstanceMetadataClient $client Client used to get new credentials
38
+ */
39
+ public function __construct(CredentialsInterface $credentials, InstanceMetadataClient $client = null)
40
+ {
41
+ $this->credentials = $credentials;
42
+ $this->client = $client ?: InstanceMetadataClient::factory();
43
+ }
44
+
45
+ /**
46
+ * Attempt to get new credentials from the instance profile
47
+ *
48
+ * @throws InstanceProfileCredentialsException On error
49
+ */
50
+ protected function refresh()
51
+ {
52
+ $credentials = $this->client->getInstanceProfileCredentials();
53
+ // Expire the token 1 minute before it actually expires to pre-fetch before expiring
54
+ $this->credentials->setAccessKeyId($credentials->getAccessKeyId())
55
+ ->setSecretKey($credentials->getSecretKey())
56
+ ->setSecurityToken($credentials->getSecurityToken())
57
+ ->setExpiration($credentials->getExpiration());
58
+ }
59
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common;
18
+
19
+ /**
20
+ * Represents an enumerable set of values
21
+ */
22
+ abstract class Enum
23
+ {
24
+ /**
25
+ * @var array A cache of all enum values to increase performance
26
+ */
27
+ protected static $cache = array();
28
+
29
+ /**
30
+ * Returns the names (or keys) of all of constants in the enum
31
+ *
32
+ * @return array
33
+ */
34
+ public static function keys()
35
+ {
36
+ return array_keys(static::values());
37
+ }
38
+
39
+ /**
40
+ * Return the names and values of all the constants in the enum
41
+ *
42
+ * @return array
43
+ */
44
+ public static function values()
45
+ {
46
+ $class = get_called_class();
47
+
48
+ if (!isset(self::$cache[$class])) {
49
+ $reflected = new \ReflectionClass($class);
50
+ self::$cache[$class] = $reflected->getConstants();
51
+ }
52
+
53
+ return self::$cache[$class];
54
+ }
55
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/ClientOptions.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable default factory options that can be passed to a client's factory method
23
+ */
24
+ class ClientOptions extends Enum
25
+ {
26
+ /**
27
+ * AWS Access Key ID
28
+ *
29
+ * @deprecated Use "credentials" instead.
30
+ */
31
+ const KEY = 'key';
32
+
33
+ /**
34
+ * AWS secret access key
35
+ *
36
+ * @deprecated Use "credentials" instead.
37
+ */
38
+ const SECRET = 'secret';
39
+
40
+ /**
41
+ * Custom AWS security token to use with request authentication.
42
+ *
43
+ * @deprecated Use "credentials" instead.
44
+ */
45
+ const TOKEN = 'token';
46
+
47
+ /**
48
+ * Provide an array of "key", "secret", and "token" or an instance of
49
+ * `Aws\Common\Credentials\CredentialsInterface`.
50
+ */
51
+ const CREDENTIALS = 'credentials';
52
+
53
+ /**
54
+ * @var string Name of a credential profile to read from your ~/.aws/credentials file
55
+ */
56
+ const PROFILE = 'profile';
57
+
58
+ /**
59
+ * @var string UNIX timestamp for when the custom credentials expire
60
+ */
61
+ const TOKEN_TTD = 'token.ttd';
62
+
63
+ /**
64
+ * @var string Used to cache credentials when using providers that require HTTP requests. Set the trueto use the
65
+ * default APC cache or provide a `Guzzle\Cache\CacheAdapterInterface` object.
66
+ */
67
+ const CREDENTIALS_CACHE = 'credentials.cache';
68
+
69
+ /**
70
+ * @var string Optional custom cache key to use with the credentials
71
+ */
72
+ const CREDENTIALS_CACHE_KEY = 'credentials.cache.key';
73
+
74
+ /**
75
+ * @var string Pass this option to specify a custom `Guzzle\Http\ClientInterface` to use if your credentials require
76
+ * a HTTP request (e.g. RefreshableInstanceProfileCredentials)
77
+ */
78
+ const CREDENTIALS_CLIENT = 'credentials.client';
79
+
80
+ /**
81
+ * @var string Region name (e.g. 'us-east-1', 'us-west-1', 'us-west-2', 'eu-west-1', etc...)
82
+ */
83
+ const REGION = 'region';
84
+
85
+ /**
86
+ * @var string URI Scheme of the base URL (e.g. 'https', 'http').
87
+ */
88
+ const SCHEME = 'scheme';
89
+
90
+ /**
91
+ * @var string Specify the name of the service
92
+ */
93
+ const SERVICE = 'service';
94
+
95
+ /**
96
+ * Instead of using a `region` and `scheme`, you can specify a custom base
97
+ * URL for the client.
98
+ *
99
+ * @deprecated Use the "endpoint" option instead.
100
+ */
101
+ const BASE_URL = 'base_url';
102
+
103
+ /**
104
+ * @var string You can optionally provide a custom signature implementation used to sign requests
105
+ */
106
+ const SIGNATURE = 'signature';
107
+
108
+ /**
109
+ * @var string Set to explicitly override the service name used in signatures
110
+ */
111
+ const SIGNATURE_SERVICE = 'signature.service';
112
+
113
+ /**
114
+ * @var string Set to explicitly override the region name used in signatures
115
+ */
116
+ const SIGNATURE_REGION = 'signature.region';
117
+
118
+ /**
119
+ * @var string Option key holding an exponential backoff plugin
120
+ */
121
+ const BACKOFF = 'client.backoff';
122
+
123
+ /**
124
+ * @var string `Guzzle\Log\LogAdapterInterface` object used to log backoff retries. Use 'debug' to emit PHP
125
+ * warnings when a retry is issued.
126
+ */
127
+ const BACKOFF_LOGGER = 'client.backoff.logger';
128
+
129
+ /**
130
+ * @var string Optional template to use for exponential backoff log messages. See
131
+ * `Guzzle\Plugin\Backoff\BackoffLogger` for formatting information.
132
+ */
133
+ const BACKOFF_LOGGER_TEMPLATE = 'client.backoff.logger.template';
134
+
135
+ /**
136
+ * Set to true to use the bundled CA cert or pass the full path to an SSL
137
+ * certificate bundle. This option should be modified when you encounter
138
+ * curl error code 60. Set to "system" to use the cacert bundle on your
139
+ * system.
140
+ */
141
+ const SSL_CERT = 'ssl.certificate_authority';
142
+
143
+ /**
144
+ * @var string Service description to use with the client
145
+ */
146
+ const SERVICE_DESCRIPTION = 'service.description';
147
+
148
+ /**
149
+ * @var string Whether or not modeled responses have transformations applied to them
150
+ */
151
+ const MODEL_PROCESSING = 'command.model_processing';
152
+
153
+ /**
154
+ * @var bool Set to false to disable validation
155
+ */
156
+ const VALIDATION = 'validation';
157
+
158
+ /**
159
+ * @var string API version used by the client
160
+ */
161
+ const VERSION = 'version';
162
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/DateFormat.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable date format values used in the SDK
23
+ */
24
+ class DateFormat extends Enum
25
+ {
26
+ const ISO8601 = 'Ymd\THis\Z';
27
+ const ISO8601_S3 = 'Y-m-d\TH:i:s\Z';
28
+ const RFC1123 = 'D, d M Y H:i:s \G\M\T';
29
+ const RFC2822 = \DateTime::RFC2822;
30
+ const SHORT = 'Ymd';
31
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/Region.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable region code values. These should be useful in most cases,
23
+ * with Amazon S3 being the most notable exception
24
+ *
25
+ * @link http://docs.aws.amazon.com/general/latest/gr/rande.html AWS Regions and Endpoints
26
+ */
27
+ class Region extends Enum
28
+ {
29
+ const US_EAST_1 = 'us-east-1';
30
+ const VIRGINIA = 'us-east-1';
31
+ const NORTHERN_VIRGINIA = 'us-east-1';
32
+
33
+ const US_WEST_1 = 'us-west-1';
34
+ const CALIFORNIA = 'us-west-1';
35
+ const NORTHERN_CALIFORNIA = 'us-west-1';
36
+
37
+ const US_WEST_2 = 'us-west-2';
38
+ const OREGON = 'us-west-2';
39
+
40
+ const EU_WEST_1 = 'eu-west-1';
41
+ const IRELAND = 'eu-west-1';
42
+
43
+ const EU_CENTRAL_1 = 'eu-central-1';
44
+ const FRANKFURT = 'eu-central-1';
45
+
46
+ const AP_SOUTHEAST_1 = 'ap-southeast-1';
47
+ const SINGAPORE = 'ap-southeast-1';
48
+
49
+ const AP_SOUTHEAST_2 = 'ap-southeast-2';
50
+ const SYDNEY = 'ap-southeast-2';
51
+
52
+ const AP_NORTHEAST_1 = 'ap-northeast-1';
53
+ const TOKYO = 'ap-northeast-1';
54
+
55
+ const SA_EAST_1 = 'sa-east-1';
56
+ const SAO_PAULO = 'sa-east-1';
57
+
58
+ const CN_NORTH_1 = 'cn-north-1';
59
+ const BEIJING = 'cn-north-1';
60
+
61
+ const US_GOV_WEST_1 = 'us-gov-west-1';
62
+ const GOV_CLOUD_US = 'us-gov-west-1';
63
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/Size.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable byte-size values
23
+ */
24
+ class Size extends Enum
25
+ {
26
+ const B = 1;
27
+ const BYTE = 1;
28
+ const BYTES = 1;
29
+
30
+ const KB = 1024;
31
+ const KILOBYTE = 1024;
32
+ const KILOBYTES = 1024;
33
+
34
+ const MB = 1048576;
35
+ const MEGABYTE = 1048576;
36
+ const MEGABYTES = 1048576;
37
+
38
+ const GB = 1073741824;
39
+ const GIGABYTE = 1073741824;
40
+ const GIGABYTES = 1073741824;
41
+
42
+ const TB = 1099511627776;
43
+ const TERABYTE = 1099511627776;
44
+ const TERABYTES = 1099511627776;
45
+
46
+ const PB = 1125899906842624;
47
+ const PETABYTE = 1125899906842624;
48
+ const PETABYTES = 1125899906842624;
49
+
50
+ const EB = 1152921504606846976;
51
+ const EXABYTE = 1152921504606846976;
52
+ const EXABYTES = 1152921504606846976;
53
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/Time.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable time values
23
+ */
24
+ class Time extends Enum
25
+ {
26
+ const SECOND = 1;
27
+ const SECONDS = 1;
28
+
29
+ const MINUTE = 60;
30
+ const MINUTES = 60;
31
+
32
+ const HOUR = 3600;
33
+ const HOURS = 3600;
34
+
35
+ const DAY = 86400;
36
+ const DAYS = 86400;
37
+
38
+ const WEEK = 604800;
39
+ const WEEKS = 604800;
40
+
41
+ const MONTH = 2592000;
42
+ const MONTHS = 2592000;
43
+
44
+ const YEAR = 31557600;
45
+ const YEARS = 31557600;
46
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Enum/UaString.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * User-Agent header strings for various high level operations
23
+ */
24
+ class UaString extends Enum
25
+ {
26
+ /**
27
+ * @var string Name of the option used to add to the UA string
28
+ */
29
+ const OPTION = 'ua.append';
30
+
31
+ /**
32
+ * @var string Resource iterator
33
+ */
34
+ const ITERATOR = 'ITR';
35
+
36
+ /**
37
+ * @var string Resource waiter
38
+ */
39
+ const WAITER = 'WTR';
40
+
41
+ /**
42
+ * @var string Session handlers (e.g. Amazon DynamoDB session handler)
43
+ */
44
+ const SESSION = 'SES';
45
+
46
+ /**
47
+ * @var string Multipart upload helper for Amazon S3
48
+ */
49
+ const MULTIPART_UPLOAD = 'MUP';
50
+
51
+ /**
52
+ * @var string Command executed during a batch transfer
53
+ */
54
+ const BATCH = 'BAT';
55
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/AwsExceptionInterface.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * "Marker Interface" implemented by every exception in the AWS SDK
21
+ */
22
+ interface AwsExceptionInterface
23
+ {
24
+ public function getCode();
25
+ public function getLine();
26
+ public function getFile();
27
+ public function getMessage();
28
+ public function getPrevious();
29
+ public function getTrace();
30
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/BadMethodCallException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL BadMethodCallException.
21
+ */
22
+ class BadMethodCallException extends \BadMethodCallException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/DomainException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL DomainException.
21
+ */
22
+ class DomainException extends \DomainException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/ExceptionFactoryInterface.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ use Guzzle\Http\Message\RequestInterface;
20
+ use Guzzle\Http\Message\Response;
21
+
22
+ /**
23
+ * Interface used to create AWS exception
24
+ */
25
+ interface ExceptionFactoryInterface
26
+ {
27
+ /**
28
+ * Returns an AWS service specific exception
29
+ *
30
+ * @param RequestInterface $request Unsuccessful request
31
+ * @param Response $response Unsuccessful response that was encountered
32
+ *
33
+ * @return \Exception|AwsExceptionInterface
34
+ */
35
+ public function fromResponse(RequestInterface $request, Response $response);
36
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/ExceptionListener.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ use Guzzle\Common\Event;
20
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
21
+
22
+ /**
23
+ * Converts generic Guzzle response exceptions into AWS specific exceptions
24
+ */
25
+ class ExceptionListener implements EventSubscriberInterface
26
+ {
27
+ /**
28
+ * @var ExceptionFactoryInterface Factory used to create new exceptions
29
+ */
30
+ protected $factory;
31
+
32
+ /**
33
+ * @param ExceptionFactoryInterface $factory Factory used to create exceptions
34
+ */
35
+ public function __construct(ExceptionFactoryInterface $factory)
36
+ {
37
+ $this->factory = $factory;
38
+ }
39
+
40
+ /**
41
+ * {@inheritdoc}
42
+ */
43
+ public static function getSubscribedEvents()
44
+ {
45
+ return array('request.error' => array('onRequestError', -1));
46
+ }
47
+
48
+ /**
49
+ * Throws a more meaningful request exception if available
50
+ *
51
+ * @param Event $event Event emitted
52
+ */
53
+ public function onRequestError(Event $event)
54
+ {
55
+ $e = $this->factory->fromResponse($event['request'], $event['response']);
56
+ $event->stopPropagation();
57
+ throw $e;
58
+ }
59
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/InstanceProfileCredentialsException.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+
21
+ /**
22
+ * Exception thrown when an error occurs with instance profile credentials
23
+ */
24
+ class InstanceProfileCredentialsException extends RuntimeException
25
+ {
26
+ /**
27
+ * @var string
28
+ */
29
+ protected $statusCode;
30
+
31
+ /**
32
+ * Set the error response code received from the instance metadata
33
+ *
34
+ * @param string $code Response code
35
+ */
36
+ public function setStatusCode($code)
37
+ {
38
+ $this->statusCode = $code;
39
+ }
40
+
41
+ /**
42
+ * Get the error response code from the service
43
+ *
44
+ * @return string|null
45
+ */
46
+ public function getStatusCode()
47
+ {
48
+ return $this->statusCode;
49
+ }
50
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/InvalidArgumentException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL InvalidArgumentException.
21
+ */
22
+ class InvalidArgumentException extends \InvalidArgumentException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/LogicException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL LogicException.
21
+ */
22
+ class LogicException extends \LogicException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/MultipartUploadException.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ use Aws\Common\Model\MultipartUpload\TransferStateInterface;
20
+
21
+ /**
22
+ * Thrown when a {@see Aws\Common\MultipartUpload\TransferInterface} object encounters an error during transfer
23
+ */
24
+ class MultipartUploadException extends RuntimeException
25
+ {
26
+ /**
27
+ * @var TransferStateInterface State of the transfer when the error was encountered
28
+ */
29
+ protected $state;
30
+
31
+ /**
32
+ * @param TransferStateInterface $state Transfer state
33
+ * @param \Exception $exception Last encountered exception
34
+ */
35
+ public function __construct(TransferStateInterface $state, \Exception $exception = null)
36
+ {
37
+ parent::__construct(
38
+ 'An error was encountered while performing a multipart upload: ' . $exception->getMessage(),
39
+ 0,
40
+ $exception
41
+ );
42
+
43
+ $this->state = $state;
44
+ }
45
+
46
+ /**
47
+ * Get the state of the transfer
48
+ *
49
+ * @return TransferStateInterface
50
+ */
51
+ public function getState()
52
+ {
53
+ return $this->state;
54
+ }
55
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ use Aws\Common\Exception\Parser\ExceptionParserInterface;
20
+ use Guzzle\Http\Message\RequestInterface;
21
+ use Guzzle\Http\Message\Response;
22
+
23
+ /**
24
+ * Attempts to create exceptions by inferring the name from the code and a base
25
+ * namespace that contains exceptions. Exception classes are expected to be in
26
+ * upper camelCase and always end in 'Exception'. 'Exception' will be appended
27
+ * if it is not present in the exception code.
28
+ */
29
+ class NamespaceExceptionFactory implements ExceptionFactoryInterface
30
+ {
31
+ /**
32
+ * @var ExceptionParserInterface $parser Parser used to parse responses
33
+ */
34
+ protected $parser;
35
+
36
+ /**
37
+ * @var string Base namespace containing exception classes
38
+ */
39
+ protected $baseNamespace;
40
+
41
+ /**
42
+ * @var string Default class to instantiate if a match is not found
43
+ */
44
+ protected $defaultException;
45
+
46
+ /**
47
+ * @param ExceptionParserInterface $parser Parser used to parse exceptions
48
+ * @param string $baseNamespace Namespace containing exceptions
49
+ * @param string $defaultException Default class to use if one is not mapped
50
+ */
51
+ public function __construct(
52
+ ExceptionParserInterface $parser,
53
+ $baseNamespace,
54
+ $defaultException = 'Aws\Common\Exception\ServiceResponseException'
55
+ ) {
56
+ $this->parser = $parser;
57
+ $this->baseNamespace = $baseNamespace;
58
+ $this->defaultException = $defaultException;
59
+ }
60
+
61
+ /**
62
+ * {@inheritdoc}
63
+ */
64
+ public function fromResponse(RequestInterface $request, Response $response)
65
+ {
66
+ $parts = $this->parser->parse($request, $response);
67
+
68
+ // Removing leading 'AWS.' and embedded periods
69
+ $className = $this->baseNamespace . '\\' . str_replace(array('AWS.', '.'), '', $parts['code']);
70
+ if (substr($className, -9) !== 'Exception') {
71
+ $className .= 'Exception';
72
+ }
73
+
74
+ $className = class_exists($className) ? $className : $this->defaultException;
75
+
76
+ return $this->createException($className, $request, $response, $parts);
77
+ }
78
+
79
+ /**
80
+ * Create an prepare an exception object
81
+ *
82
+ * @param string $className Name of the class to create
83
+ * @param RequestInterface $request Request
84
+ * @param Response $response Response received
85
+ * @param array $parts Parsed exception data
86
+ *
87
+ * @return \Exception
88
+ */
89
+ protected function createException($className, RequestInterface $request, Response $response, array $parts)
90
+ {
91
+ $class = new $className($parts['message']);
92
+
93
+ if ($class instanceof ServiceResponseException) {
94
+ $class->setExceptionCode($parts['code']);
95
+ $class->setExceptionType($parts['type']);
96
+ $class->setResponse($response);
97
+ $class->setRequest($request);
98
+ $class->setRequestId($parts['request_id']);
99
+ }
100
+
101
+ return $class;
102
+ }
103
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/OutOfBoundsException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL OverflowException.
21
+ */
22
+ class OutOfBoundsException extends \OutOfBoundsException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/OverflowException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL OverflowException.
21
+ */
22
+ class OverflowException extends \OverflowException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/AbstractJsonExceptionParser.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception\Parser;
18
+
19
+ use Guzzle\Http\Message\RequestInterface;
20
+ use Guzzle\Http\Message\Response;
21
+
22
+ /**
23
+ * Parses JSON encoded exception responses
24
+ */
25
+ abstract class AbstractJsonExceptionParser implements ExceptionParserInterface
26
+ {
27
+ /**
28
+ * {@inheritdoc}
29
+ */
30
+ public function parse(RequestInterface $request, Response $response)
31
+ {
32
+ // Build array of default error data
33
+ $data = array(
34
+ 'code' => null,
35
+ 'message' => null,
36
+ 'type' => $response->isClientError() ? 'client' : 'server',
37
+ 'request_id' => (string) $response->getHeader('x-amzn-RequestId'),
38
+ 'parsed' => null
39
+ );
40
+
41
+ // Parse the json and normalize key casings
42
+ if (null !== $json = json_decode($response->getBody(true), true)) {
43
+ $data['parsed'] = array_change_key_case($json);
44
+ }
45
+
46
+ // Do additional, protocol-specific parsing and return the result
47
+ $data = $this->doParse($data, $response);
48
+
49
+ // Remove "Fault" suffix from exception names
50
+ if (isset($data['code']) && strpos($data['code'], 'Fault')) {
51
+ $data['code'] = preg_replace('/^([a-zA-Z]+)Fault$/', '$1', $data['code']);
52
+ }
53
+
54
+ return $data;
55
+ }
56
+
57
+ /**
58
+ * Pull relevant exception data out of the parsed json
59
+ *
60
+ * @param array $data The exception data
61
+ * @param Response $response The response from the service containing the error
62
+ *
63
+ * @return array
64
+ */
65
+ abstract protected function doParse(array $data, Response $response);
66
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/DefaultXmlExceptionParser.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception\Parser;
18
+
19
+ use Guzzle\Http\Message\RequestInterface;
20
+ use Guzzle\Http\Message\Response;
21
+
22
+ /**
23
+ * Parses default XML exception responses
24
+ */
25
+ class DefaultXmlExceptionParser implements ExceptionParserInterface
26
+ {
27
+ /**
28
+ * {@inheritdoc}
29
+ */
30
+ public function parse(RequestInterface $request, Response $response)
31
+ {
32
+ $data = array(
33
+ 'code' => null,
34
+ 'message' => null,
35
+ 'type' => $response->isClientError() ? 'client' : 'server',
36
+ 'request_id' => null,
37
+ 'parsed' => null
38
+ );
39
+
40
+ if ($body = $response->getBody(true)) {
41
+ $this->parseBody(new \SimpleXMLElement($body), $data);
42
+ } else {
43
+ $this->parseHeaders($request, $response, $data);
44
+ }
45
+
46
+ return $data;
47
+ }
48
+
49
+ /**
50
+ * Parses additional exception information from the response headers
51
+ *
52
+ * @param RequestInterface $request Request that was issued
53
+ * @param Response $response The response from the request
54
+ * @param array $data The current set of exception data
55
+ */
56
+ protected function parseHeaders(RequestInterface $request, Response $response, array &$data)
57
+ {
58
+ $data['message'] = $response->getStatusCode() . ' ' . $response->getReasonPhrase();
59
+ if ($requestId = $response->getHeader('x-amz-request-id')) {
60
+ $data['request_id'] = $requestId;
61
+ $data['message'] .= " (Request-ID: $requestId)";
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Parses additional exception information from the response body
67
+ *
68
+ * @param \SimpleXMLElement $body The response body as XML
69
+ * @param array $data The current set of exception data
70
+ */
71
+ protected function parseBody(\SimpleXMLElement $body, array &$data)
72
+ {
73
+ $data['parsed'] = $body;
74
+
75
+ $namespaces = $body->getDocNamespaces();
76
+ if (isset($namespaces[''])) {
77
+ // Account for the default namespace being defined and PHP not being able to handle it :(
78
+ $body->registerXPathNamespace('ns', $namespaces['']);
79
+ $prefix = 'ns:';
80
+ } else {
81
+ $prefix = '';
82
+ }
83
+
84
+ if ($tempXml = $body->xpath("//{$prefix}Code[1]")) {
85
+ $data['code'] = (string) $tempXml[0];
86
+ }
87
+
88
+ if ($tempXml = $body->xpath("//{$prefix}Message[1]")) {
89
+ $data['message'] = (string) $tempXml[0];
90
+ }
91
+
92
+ $tempXml = $body->xpath("//{$prefix}RequestId[1]");
93
+ if (empty($tempXml)) {
94
+ $tempXml = $body->xpath("//{$prefix}RequestID[1]");
95
+ }
96
+ if (isset($tempXml[0])) {
97
+ $data['request_id'] = (string) $tempXml[0];
98
+ }
99
+ }
100
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/ExceptionParserInterface.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception\Parser;
18
+
19
+ use Guzzle\Http\Message\RequestInterface;
20
+ use Guzzle\Http\Message\Response;
21
+
22
+ /**
23
+ * Interface used to parse exceptions into an associative array of data
24
+ */
25
+ interface ExceptionParserInterface
26
+ {
27
+ /**
28
+ * Parses an exception into an array of data containing at minimum the
29
+ * following array keys:
30
+ * - type: Exception type
31
+ * - code: Exception code
32
+ * - message: Exception message
33
+ * - request_id: Request ID
34
+ * - parsed: The parsed representation of the data (array, SimpleXMLElement, etc)
35
+ *
36
+ * @param RequestInterface $request
37
+ * @param Response $response Unsuccessful response
38
+ *
39
+ * @return array
40
+ */
41
+ public function parse(RequestInterface $request, Response $response);
42
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/JsonQueryExceptionParser.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception\Parser;
18
+
19
+ use Guzzle\Http\Message\Response;
20
+
21
+ /**
22
+ * Parses JSON encoded exception responses from query services
23
+ */
24
+ class JsonQueryExceptionParser extends AbstractJsonExceptionParser
25
+ {
26
+ /**
27
+ * {@inheritdoc}
28
+ */
29
+ protected function doParse(array $data, Response $response)
30
+ {
31
+ if ($json = $data['parsed']) {
32
+ if (isset($json['__type'])) {
33
+ $parts = explode('#', $json['__type']);
34
+ $data['code'] = isset($parts[1]) ? $parts[1] : $parts[0];
35
+ }
36
+ $data['message'] = isset($json['message']) ? $json['message'] : null;
37
+ }
38
+
39
+ return $data;
40
+ }
41
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/Parser/JsonRestExceptionParser.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception\Parser;
18
+
19
+ use Guzzle\Http\Message\Response;
20
+
21
+ /**
22
+ * Parses JSON encoded exception responses from REST services
23
+ */
24
+ class JsonRestExceptionParser extends AbstractJsonExceptionParser
25
+ {
26
+ /**
27
+ * {@inheritdoc}
28
+ */
29
+ protected function doParse(array $data, Response $response)
30
+ {
31
+ // Merge in error data from the JSON body
32
+ if ($json = $data['parsed']) {
33
+ $data = array_replace($data, $json);
34
+ }
35
+
36
+ // Correct error type from services like Amazon Glacier
37
+ if (!empty($data['type'])) {
38
+ $data['type'] = strtolower($data['type']);
39
+ }
40
+
41
+ // Retrieve the error code from services like Amazon Elastic Transcoder
42
+ if ($code = (string) $response->getHeader('x-amzn-ErrorType')) {
43
+ $data['code'] = substr($code, 0, strpos($code, ':'));
44
+ }
45
+
46
+ return $data;
47
+ }
48
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/RequiredExtensionNotLoadedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * Thrown when a particular PHP extension is required to execute the guarded logic, but the extension is not loaded
21
+ */
22
+ class RequiredExtensionNotLoadedException extends RuntimeException {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/RuntimeException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL RuntimeException.
21
+ */
22
+ class RuntimeException extends \RuntimeException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/ServiceResponseException.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ use Guzzle\Http\Message\RequestInterface;
20
+ use Guzzle\Http\Message\Response;
21
+
22
+ /**
23
+ * Default AWS exception
24
+ */
25
+ class ServiceResponseException extends RuntimeException
26
+ {
27
+ /**
28
+ * @var Response Response
29
+ */
30
+ protected $response;
31
+
32
+ /**
33
+ * @var RequestInterface Request
34
+ */
35
+ protected $request;
36
+
37
+ /**
38
+ * @var string Request ID
39
+ */
40
+ protected $requestId;
41
+
42
+ /**
43
+ * @var string Exception type (client / server)
44
+ */
45
+ protected $exceptionType;
46
+
47
+ /**
48
+ * @var string Exception code
49
+ */
50
+ protected $exceptionCode;
51
+
52
+ /**
53
+ * Set the exception code
54
+ *
55
+ * @param string $code Exception code
56
+ */
57
+ public function setExceptionCode($code)
58
+ {
59
+ $this->exceptionCode = $code;
60
+ }
61
+
62
+ /**
63
+ * Get the exception code
64
+ *
65
+ * @return string|null
66
+ */
67
+ public function getExceptionCode()
68
+ {
69
+ return $this->exceptionCode;
70
+ }
71
+
72
+ /**
73
+ * Set the exception type
74
+ *
75
+ * @param string $type Exception type
76
+ */
77
+ public function setExceptionType($type)
78
+ {
79
+ $this->exceptionType = $type;
80
+ }
81
+
82
+ /**
83
+ * Get the exception type (one of client or server)
84
+ *
85
+ * @return string|null
86
+ */
87
+ public function getExceptionType()
88
+ {
89
+ return $this->exceptionType;
90
+ }
91
+
92
+ /**
93
+ * Set the request ID
94
+ *
95
+ * @param string $id Request ID
96
+ */
97
+ public function setRequestId($id)
98
+ {
99
+ $this->requestId = $id;
100
+ }
101
+
102
+ /**
103
+ * Get the Request ID
104
+ *
105
+ * @return string|null
106
+ */
107
+ public function getRequestId()
108
+ {
109
+ return $this->requestId;
110
+ }
111
+
112
+ /**
113
+ * Set the associated response
114
+ *
115
+ * @param Response $response Response
116
+ */
117
+ public function setResponse(Response $response)
118
+ {
119
+ $this->response = $response;
120
+ }
121
+
122
+ /**
123
+ * Get the associated response object
124
+ *
125
+ * @return Response|null
126
+ */
127
+ public function getResponse()
128
+ {
129
+ return $this->response;
130
+ }
131
+
132
+ /**
133
+ * Set the associated request
134
+ *
135
+ * @param RequestInterface $request
136
+ */
137
+ public function setRequest(RequestInterface $request)
138
+ {
139
+ $this->request = $request;
140
+ }
141
+
142
+ /**
143
+ * Get the associated request object
144
+ *
145
+ * @return RequestInterface|null
146
+ */
147
+ public function getRequest()
148
+ {
149
+ return $this->request;
150
+ }
151
+
152
+ /**
153
+ * Get the status code of the response
154
+ *
155
+ * @return int|null
156
+ */
157
+ public function getStatusCode()
158
+ {
159
+ return $this->response ? $this->response->getStatusCode() : null;
160
+ }
161
+
162
+ /**
163
+ * Cast to a string
164
+ *
165
+ * @return string
166
+ */
167
+ public function __toString()
168
+ {
169
+ $message = get_class($this) . ': '
170
+ . 'AWS Error Code: ' . $this->getExceptionCode() . ', '
171
+ . 'Status Code: ' . $this->getStatusCode() . ', '
172
+ . 'AWS Request ID: ' . $this->getRequestId() . ', '
173
+ . 'AWS Error Type: ' . $this->getExceptionType() . ', '
174
+ . 'AWS Error Message: ' . $this->getMessage();
175
+
176
+ // Add the User-Agent if available
177
+ if ($this->request) {
178
+ $message .= ', ' . 'User-Agent: ' . $this->request->getHeader('User-Agent');
179
+ }
180
+
181
+ return $message;
182
+ }
183
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/TransferException.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ use Guzzle\Http\Exception\CurlException;
20
+
21
+ /**
22
+ * Transfer request exception
23
+ */
24
+ class TransferException extends CurlException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Exception/UnexpectedValueException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Exception;
18
+
19
+ /**
20
+ * AWS SDK namespaced version of the SPL UnexpectedValueException.
21
+ */
22
+ class UnexpectedValueException extends \UnexpectedValueException implements AwsExceptionInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Facade/Facade.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Facade;
18
+
19
+ use Aws\Common\Aws;
20
+
21
+ /**
22
+ * Base facade class that handles the delegation logic
23
+ */
24
+ abstract class Facade implements FacadeInterface
25
+ {
26
+ /** @var Aws */
27
+ protected static $serviceBuilder;
28
+
29
+ /**
30
+ * Mounts the facades by extracting information from the service builder config and using creating class aliases
31
+ *
32
+ * @param string|null $targetNamespace Namespace that the facades should be mounted to. Defaults to global namespace
33
+ *
34
+ * @param Aws $serviceBuilder
35
+ */
36
+ public static function mountFacades(Aws $serviceBuilder, $targetNamespace = null)
37
+ {
38
+ self::$serviceBuilder = $serviceBuilder;
39
+ require_once __DIR__ . '/facade-classes.php';
40
+ foreach ($serviceBuilder->getConfig() as $service) {
41
+ if (isset($service['alias'], $service['class'])) {
42
+ $facadeClass = __NAMESPACE__ . '\\' . $service['alias'];
43
+ $facadeAlias = ltrim($targetNamespace . '\\' . $service['alias'], '\\');
44
+ if (!class_exists($facadeAlias) && class_exists($facadeClass)) {
45
+ // @codeCoverageIgnoreStart
46
+ class_alias($facadeClass, $facadeAlias);
47
+ // @codeCoverageIgnoreEnd
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Returns the instance of the client that the facade operates on
55
+ *
56
+ * @return \Aws\Common\Client\AwsClientInterface
57
+ */
58
+ public static function getClient()
59
+ {
60
+ return self::$serviceBuilder->get(static::getServiceBuilderKey());
61
+ }
62
+
63
+ public static function __callStatic($method, $args)
64
+ {
65
+ return call_user_func_array(array(self::getClient(), $method), $args);
66
+ }
67
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Facade/FacadeInterface.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Facade;
18
+
19
+ /**
20
+ * Interface that defines a client facade. Facades are convenient static classes that allow you to run client methods
21
+ * statically on a default instance from the service builder. The facades themselves are aliased into the global
22
+ * namespace for ease of use.
23
+ */
24
+ interface FacadeInterface
25
+ {
26
+ /**
27
+ * Returns the key used to access the client instance from the Service Builder
28
+ *
29
+ * @return string
30
+ */
31
+ public static function getServiceBuilderKey();
32
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Facade/facade-classes.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Facade;
18
+
19
+ /**
20
+ * The following classes are used to implement the static client facades and are aliased into the global namespaced. We
21
+ * discourage the use of these classes directly by their full namespace since they are not autoloaded and are considered
22
+ * an implementation detail that could possibly be changed in the future.
23
+ */
24
+
25
+ // @codeCoverageIgnoreStart
26
+
27
+ class AutoScaling extends Facade
28
+ {
29
+ public static function getServiceBuilderKey()
30
+ {
31
+ return 'autoscaling';
32
+ }
33
+ }
34
+
35
+ class CloudFormation extends Facade
36
+ {
37
+ public static function getServiceBuilderKey()
38
+ {
39
+ return 'cloudformation';
40
+ }
41
+ }
42
+
43
+ class CloudFront extends Facade
44
+ {
45
+ public static function getServiceBuilderKey()
46
+ {
47
+ return 'cloudfront';
48
+ }
49
+ }
50
+
51
+ class CloudSearch extends Facade
52
+ {
53
+ public static function getServiceBuilderKey()
54
+ {
55
+ return 'cloudsearch';
56
+ }
57
+ }
58
+
59
+ class CloudTrail extends Facade
60
+ {
61
+ public static function getServiceBuilderKey()
62
+ {
63
+ return 'cloudtrail';
64
+ }
65
+ }
66
+
67
+ class CloudWatch extends Facade
68
+ {
69
+ public static function getServiceBuilderKey()
70
+ {
71
+ return 'cloudwatch';
72
+ }
73
+ }
74
+
75
+ class DataPipeline extends Facade
76
+ {
77
+ public static function getServiceBuilderKey()
78
+ {
79
+ return 'datapipeline';
80
+ }
81
+ }
82
+
83
+ class DirectConnect extends Facade
84
+ {
85
+ public static function getServiceBuilderKey()
86
+ {
87
+ return 'directconnect';
88
+ }
89
+ }
90
+
91
+ class DynamoDb extends Facade
92
+ {
93
+ public static function getServiceBuilderKey()
94
+ {
95
+ return 'dynamodb';
96
+ }
97
+ }
98
+
99
+ class Ec2 extends Facade
100
+ {
101
+ public static function getServiceBuilderKey()
102
+ {
103
+ return 'ec2';
104
+ }
105
+ }
106
+
107
+ class ElastiCache extends Facade
108
+ {
109
+ public static function getServiceBuilderKey()
110
+ {
111
+ return 'elasticache';
112
+ }
113
+ }
114
+
115
+ class ElasticBeanstalk extends Facade
116
+ {
117
+ public static function getServiceBuilderKey()
118
+ {
119
+ return 'elasticbeanstalk';
120
+ }
121
+ }
122
+
123
+ class ElasticLoadBalancing extends Facade
124
+ {
125
+ public static function getServiceBuilderKey()
126
+ {
127
+ return 'elasticloadbalancing';
128
+ }
129
+ }
130
+
131
+ class ElasticTranscoder extends Facade
132
+ {
133
+ public static function getServiceBuilderKey()
134
+ {
135
+ return 'elastictranscoder';
136
+ }
137
+ }
138
+
139
+ class Emr extends Facade
140
+ {
141
+ public static function getServiceBuilderKey()
142
+ {
143
+ return 'emr';
144
+ }
145
+ }
146
+
147
+ class Glacier extends Facade
148
+ {
149
+ public static function getServiceBuilderKey()
150
+ {
151
+ return 'glacier';
152
+ }
153
+ }
154
+
155
+ class Iam extends Facade
156
+ {
157
+ public static function getServiceBuilderKey()
158
+ {
159
+ return 'iam';
160
+ }
161
+ }
162
+
163
+ class ImportExport extends Facade
164
+ {
165
+ public static function getServiceBuilderKey()
166
+ {
167
+ return 'importexport';
168
+ }
169
+ }
170
+
171
+ class Kinesis extends Facade
172
+ {
173
+ public static function getServiceBuilderKey()
174
+ {
175
+ return 'kinesis';
176
+ }
177
+ }
178
+
179
+ class OpsWorks extends Facade
180
+ {
181
+ public static function getServiceBuilderKey()
182
+ {
183
+ return 'opsworks';
184
+ }
185
+ }
186
+
187
+ class Rds extends Facade
188
+ {
189
+ public static function getServiceBuilderKey()
190
+ {
191
+ return 'rds';
192
+ }
193
+ }
194
+
195
+ class Redshift extends Facade
196
+ {
197
+ public static function getServiceBuilderKey()
198
+ {
199
+ return 'redshift';
200
+ }
201
+ }
202
+
203
+ class Route53 extends Facade
204
+ {
205
+ public static function getServiceBuilderKey()
206
+ {
207
+ return 'route53';
208
+ }
209
+ }
210
+
211
+ class S3 extends Facade
212
+ {
213
+ public static function getServiceBuilderKey()
214
+ {
215
+ return 's3';
216
+ }
217
+ }
218
+
219
+ class SimpleDb extends Facade
220
+ {
221
+ public static function getServiceBuilderKey()
222
+ {
223
+ return 'sdb';
224
+ }
225
+ }
226
+
227
+ class Ses extends Facade
228
+ {
229
+ public static function getServiceBuilderKey()
230
+ {
231
+ return 'ses';
232
+ }
233
+ }
234
+
235
+ class Sns extends Facade
236
+ {
237
+ public static function getServiceBuilderKey()
238
+ {
239
+ return 'sns';
240
+ }
241
+ }
242
+
243
+ class Sqs extends Facade
244
+ {
245
+ public static function getServiceBuilderKey()
246
+ {
247
+ return 'sqs';
248
+ }
249
+ }
250
+
251
+ class StorageGateway extends Facade
252
+ {
253
+ public static function getServiceBuilderKey()
254
+ {
255
+ return 'storagegateway';
256
+ }
257
+ }
258
+
259
+ class Sts extends Facade
260
+ {
261
+ public static function getServiceBuilderKey()
262
+ {
263
+ return 'sts';
264
+ }
265
+ }
266
+
267
+ class Support extends Facade
268
+ {
269
+ public static function getServiceBuilderKey()
270
+ {
271
+ return 'support';
272
+ }
273
+ }
274
+
275
+ class Swf extends Facade
276
+ {
277
+ public static function getServiceBuilderKey()
278
+ {
279
+ return 'swf';
280
+ }
281
+ }
282
+
283
+ // @codeCoverageIgnoreEnd
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/ChunkHash.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Hash;
18
+
19
+ use Aws\Common\Exception\LogicException;
20
+
21
+ /**
22
+ * Encapsulates the creation of a hash from streamed chunks of data
23
+ */
24
+ class ChunkHash implements ChunkHashInterface
25
+ {
26
+ /**
27
+ * @var resource The hash context as created by `hash_init()`
28
+ */
29
+ protected $context;
30
+
31
+ /**
32
+ * @var string The resulting hash in hex form
33
+ */
34
+ protected $hash;
35
+
36
+ /**
37
+ * @var string The resulting hash in binary form
38
+ */
39
+ protected $hashRaw;
40
+
41
+ /**
42
+ * {@inheritdoc}
43
+ */
44
+ public function __construct($algorithm = self::DEFAULT_ALGORITHM)
45
+ {
46
+ HashUtils::validateAlgorithm($algorithm);
47
+ $this->context = hash_init($algorithm);
48
+ }
49
+
50
+ /**
51
+ * {@inheritdoc}
52
+ */
53
+ public function addData($data)
54
+ {
55
+ if (!$this->context) {
56
+ throw new LogicException('You may not add more data to a finalized chunk hash.');
57
+ }
58
+
59
+ hash_update($this->context, $data);
60
+
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * {@inheritdoc}
66
+ */
67
+ public function getHash($returnBinaryForm = false)
68
+ {
69
+ if (!$this->hash) {
70
+ $this->hashRaw = hash_final($this->context, true);
71
+ $this->hash = HashUtils::binToHex($this->hashRaw);
72
+ $this->context = null;
73
+ }
74
+
75
+ return $returnBinaryForm ? $this->hashRaw : $this->hash;
76
+ }
77
+
78
+ /**
79
+ * {@inheritdoc}
80
+ */
81
+ public function __clone()
82
+ {
83
+ if ($this->context) {
84
+ $this->context = hash_copy($this->context);
85
+ }
86
+ }
87
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/ChunkHashInterface.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Hash;
18
+
19
+ /**
20
+ * Interface for objects that encapsulate the creation of a hash from streamed chunks of data
21
+ */
22
+ interface ChunkHashInterface
23
+ {
24
+ const DEFAULT_ALGORITHM = 'sha256';
25
+
26
+ /**
27
+ * Constructs the chunk hash and sets the algorithm to use for hashing
28
+ *
29
+ * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
30
+ *
31
+ * @return self
32
+ */
33
+ public function __construct($algorithm = 'sha256');
34
+
35
+ /**
36
+ * Add a chunk of data to be hashed
37
+ *
38
+ * @param string $data Data to be hashed
39
+ *
40
+ * @return self
41
+ */
42
+ public function addData($data);
43
+
44
+ /**
45
+ * Return the results of the hash
46
+ *
47
+ * @param bool $returnBinaryForm If true, returns the hash in binary form instead of hex form
48
+ *
49
+ * @return string
50
+ */
51
+ public function getHash($returnBinaryForm = false);
52
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/HashUtils.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Hash;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+
21
+ /**
22
+ * Contains hashing utilities
23
+ */
24
+ class HashUtils
25
+ {
26
+ /**
27
+ * Converts a hash in hex form to binary form
28
+ *
29
+ * @param string $hash Hash in hex form
30
+ *
31
+ * @return string Hash in binary form
32
+ */
33
+ public static function hexToBin($hash)
34
+ {
35
+ // If using PHP 5.4, there is a native function to convert from hex to binary
36
+ static $useNative;
37
+ if ($useNative === null) {
38
+ $useNative = function_exists('hex2bin');
39
+ }
40
+
41
+ if (!$useNative && strlen($hash) % 2 !== 0) {
42
+ $hash = '0' . $hash;
43
+ }
44
+
45
+ return $useNative ? hex2bin($hash) : pack("H*", $hash);
46
+ }
47
+
48
+ /**
49
+ * Converts a hash in binary form to hex form
50
+ *
51
+ * @param string $hash Hash in binary form
52
+ *
53
+ * @return string Hash in hex form
54
+ */
55
+ public static function binToHex($hash)
56
+ {
57
+ return bin2hex($hash);
58
+ }
59
+
60
+ /**
61
+ * Checks if the algorithm specified exists and throws an exception if it does not
62
+ *
63
+ * @param string $algorithm Name of the algorithm to validate
64
+ *
65
+ * @return bool
66
+ * @throws InvalidArgumentException if the algorithm doesn't exist
67
+ */
68
+ public static function validateAlgorithm($algorithm)
69
+ {
70
+ if (!in_array($algorithm, hash_algos(), true)) {
71
+ throw new InvalidArgumentException("The hashing algorithm specified ({$algorithm}) does not exist.");
72
+ }
73
+
74
+ return true;
75
+ }
76
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Hash/TreeHash.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Hash;
18
+
19
+ use Aws\Common\Enum\Size;
20
+ use Aws\Common\Exception\InvalidArgumentException;
21
+ use Aws\Common\Exception\LogicException;
22
+ use Guzzle\Http\EntityBody;
23
+
24
+ /**
25
+ * Encapsulates the creation of a tree hash from streamed chunks of data
26
+ */
27
+ class TreeHash implements ChunkHashInterface
28
+ {
29
+ /**
30
+ * @var string The algorithm used for hashing
31
+ */
32
+ protected $algorithm;
33
+
34
+ /**
35
+ * @var array Set of binary checksums from which the tree hash is derived
36
+ */
37
+ protected $checksums = array();
38
+
39
+ /**
40
+ * @var string The resulting hash in hex form
41
+ */
42
+ protected $hash;
43
+
44
+ /**
45
+ * @var string The resulting hash in binary form
46
+ */
47
+ protected $hashRaw;
48
+
49
+ /**
50
+ * Create a tree hash from an array of existing tree hash checksums
51
+ *
52
+ * @param array $checksums Set of checksums
53
+ * @param bool $inBinaryForm Whether or not the checksums are already in binary form
54
+ * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
55
+ *
56
+ * @return TreeHash
57
+ */
58
+ public static function fromChecksums(array $checksums, $inBinaryForm = false, $algorithm = self::DEFAULT_ALGORITHM)
59
+ {
60
+ $treeHash = new self($algorithm);
61
+
62
+ // Convert checksums to binary form if provided in hex form and add them to the tree hash
63
+ $treeHash->checksums = $inBinaryForm ? $checksums : array_map('Aws\Common\Hash\HashUtils::hexToBin', $checksums);
64
+
65
+ // Pre-calculate hash
66
+ $treeHash->getHash();
67
+
68
+ return $treeHash;
69
+ }
70
+
71
+ /**
72
+ * Create a tree hash from a content body
73
+ *
74
+ * @param string|resource|EntityBody $content Content to create a tree hash for
75
+ * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
76
+ *
77
+ * @return TreeHash
78
+ */
79
+ public static function fromContent($content, $algorithm = self::DEFAULT_ALGORITHM)
80
+ {
81
+ $treeHash = new self($algorithm);
82
+
83
+ // Read the data in 1MB chunks and add to tree hash
84
+ $content = EntityBody::factory($content);
85
+ while ($data = $content->read(Size::MB)) {
86
+ $treeHash->addData($data);
87
+ }
88
+
89
+ // Pre-calculate hash
90
+ $treeHash->getHash();
91
+
92
+ return $treeHash;
93
+ }
94
+
95
+ /**
96
+ * Validates an entity body with a tree hash checksum
97
+ *
98
+ * @param string|resource|EntityBody $content Content to create a tree hash for
99
+ * @param string $checksum The checksum to use for validation
100
+ * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
101
+ *
102
+ * @return bool
103
+ */
104
+ public static function validateChecksum($content, $checksum, $algorithm = self::DEFAULT_ALGORITHM)
105
+ {
106
+ $treeHash = self::fromContent($content, $algorithm);
107
+
108
+ return ($checksum === $treeHash->getHash());
109
+ }
110
+
111
+ /**
112
+ * {@inheritdoc}
113
+ */
114
+ public function __construct($algorithm = self::DEFAULT_ALGORITHM)
115
+ {
116
+ HashUtils::validateAlgorithm($algorithm);
117
+ $this->algorithm = $algorithm;
118
+ }
119
+
120
+ /**
121
+ * {@inheritdoc}
122
+ * @throws LogicException if the root tree hash is already calculated
123
+ * @throws InvalidArgumentException if the data is larger than 1MB
124
+ */
125
+ public function addData($data)
126
+ {
127
+ // Error if hash is already calculated
128
+ if ($this->hash) {
129
+ throw new LogicException('You may not add more data to a finalized tree hash.');
130
+ }
131
+
132
+ // Make sure that only 1MB chunks or smaller get passed in
133
+ if (strlen($data) > Size::MB) {
134
+ throw new InvalidArgumentException('The chunk of data added is too large for tree hashing.');
135
+ }
136
+
137
+ // Store the raw hash of this data segment
138
+ $this->checksums[] = hash($this->algorithm, $data, true);
139
+
140
+ return $this;
141
+ }
142
+
143
+ /**
144
+ * Add a checksum to the tree hash directly
145
+ *
146
+ * @param string $checksum The checksum to add
147
+ * @param bool $inBinaryForm Whether or not the checksum is already in binary form
148
+ *
149
+ * @return self
150
+ * @throws LogicException if the root tree hash is already calculated
151
+ */
152
+ public function addChecksum($checksum, $inBinaryForm = false)
153
+ {
154
+ // Error if hash is already calculated
155
+ if ($this->hash) {
156
+ throw new LogicException('You may not add more checksums to a finalized tree hash.');
157
+ }
158
+
159
+ // Convert the checksum to binary form if necessary
160
+ $this->checksums[] = $inBinaryForm ? $checksum : HashUtils::hexToBin($checksum);
161
+
162
+ return $this;
163
+ }
164
+
165
+ /**
166
+ * {@inheritdoc}
167
+ */
168
+ public function getHash($returnBinaryForm = false)
169
+ {
170
+ if (!$this->hash) {
171
+ // Perform hashes up the tree to arrive at the root checksum of the tree hash
172
+ $hashes = $this->checksums;
173
+ while (count($hashes) > 1) {
174
+ $sets = array_chunk($hashes, 2);
175
+ $hashes = array();
176
+ foreach ($sets as $set) {
177
+ $hashes[] = (count($set) === 1) ? $set[0] : hash($this->algorithm, $set[0] . $set[1], true);
178
+ }
179
+ }
180
+
181
+ $this->hashRaw = $hashes[0];
182
+ $this->hash = HashUtils::binToHex($this->hashRaw);
183
+ }
184
+
185
+ return $returnBinaryForm ? $this->hashRaw : $this->hash;
186
+ }
187
+
188
+ /**
189
+ * @return array Array of raw checksums composing the tree hash
190
+ */
191
+ public function getChecksums()
192
+ {
193
+ return $this->checksums;
194
+ }
195
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/HostNameUtils.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common;
18
+
19
+ use Guzzle\Http\Url;
20
+
21
+ /**
22
+ * Utility class for parsing regions and services from URLs
23
+ */
24
+ class HostNameUtils
25
+ {
26
+ const DEFAULT_REGION = 'us-east-1';
27
+ const DEFAULT_GOV_REGION = 'us-gov-west-1';
28
+
29
+ /**
30
+ * Parse the AWS region name from a URL
31
+ *
32
+ *
33
+ * @param Url $url HTTP URL
34
+ *
35
+ * @return string
36
+ * @link http://docs.aws.amazon.com/general/latest/gr/rande.html
37
+ */
38
+ public static function parseRegionName(Url $url)
39
+ {
40
+ // If we don't recognize the domain, just return the default
41
+ if (substr($url->getHost(), -14) != '.amazonaws.com') {
42
+ return self::DEFAULT_REGION;
43
+ }
44
+
45
+ $serviceAndRegion = substr($url->getHost(), 0, -14);
46
+ // Special handling for S3 regions
47
+ $separator = strpos($serviceAndRegion, 's3') === 0 ? '-' : '.';
48
+ $separatorPos = strpos($serviceAndRegion, $separator);
49
+
50
+ // If don't detect a separator, then return the default region
51
+ if ($separatorPos === false) {
52
+ return self::DEFAULT_REGION;
53
+ }
54
+
55
+ $region = substr($serviceAndRegion, $separatorPos + 1);
56
+
57
+ // All GOV regions currently use the default GOV region
58
+ if ($region == 'us-gov') {
59
+ return self::DEFAULT_GOV_REGION;
60
+ }
61
+
62
+ return $region;
63
+ }
64
+
65
+ /**
66
+ * Parse the AWS service name from a URL
67
+ *
68
+ * @param Url $url HTTP URL
69
+ *
70
+ * @return string Returns a service name (or empty string)
71
+ * @link http://docs.aws.amazon.com/general/latest/gr/rande.html
72
+ */
73
+ public static function parseServiceName(Url $url)
74
+ {
75
+ // The service name is the first part of the host
76
+ $parts = explode('.', $url->getHost(), 2);
77
+
78
+ // Special handling for S3
79
+ if (stripos($parts[0], 's3') === 0) {
80
+ return 's3';
81
+ }
82
+
83
+ return $parts[0];
84
+ }
85
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/InstanceMetadata/InstanceMetadataClient.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\InstanceMetadata;
18
+
19
+ use Aws\Common\Enum\ClientOptions as Options;
20
+ use Aws\Common\Exception\InstanceProfileCredentialsException;
21
+ use Aws\Common\Credentials\Credentials;
22
+ use Aws\Common\Client\AbstractClient;
23
+ use Guzzle\Common\Collection;
24
+ use Guzzle\Http\Message\RequestFactory;
25
+
26
+ /**
27
+ * Client used for interacting with the Amazon EC2 instance metadata server
28
+ */
29
+ class InstanceMetadataClient extends AbstractClient
30
+ {
31
+ /**
32
+ * Factory method to create a new InstanceMetadataClient using an array
33
+ * of configuration options.
34
+ *
35
+ * The configuration options accepts the following array keys and values:
36
+ * - base_url: Override the base URL of the instance metadata server
37
+ * - version: Version of the metadata server to interact with
38
+ *
39
+ * @param array|Collection $config Configuration options
40
+ *
41
+ * @return InstanceMetadataClient
42
+ */
43
+ public static function factory($config = array())
44
+ {
45
+ $config = Collection::fromConfig($config, array(
46
+ Options::BASE_URL => 'http://169.254.169.254/{version}/',
47
+ 'version' => 'latest',
48
+ 'request.options' => array(
49
+ 'connect_timeout' => 5,
50
+ 'timeout' => 10
51
+ )
52
+ ), array('base_url', 'version'));
53
+
54
+ return new self($config);
55
+ }
56
+
57
+ /**
58
+ * Constructor override
59
+ */
60
+ public function __construct(Collection $config)
61
+ {
62
+ $this->setConfig($config);
63
+ $this->setBaseUrl($config->get(Options::BASE_URL));
64
+ $this->defaultHeaders = new Collection();
65
+ $this->setRequestFactory(RequestFactory::getInstance());
66
+ }
67
+
68
+ /**
69
+ * Get instance profile credentials
70
+ *
71
+ * @return Credentials
72
+ * @throws InstanceProfileCredentialsException
73
+ */
74
+ public function getInstanceProfileCredentials()
75
+ {
76
+ try {
77
+ $request = $this->get('meta-data/iam/security-credentials/');
78
+ $credentials = trim($request->send()->getBody(true));
79
+ $result = $this->get("meta-data/iam/security-credentials/{$credentials}")->send()->json();
80
+ } catch (\Exception $e) {
81
+ $message = sprintf('Error retrieving credentials from the instance profile metadata server. When you are'
82
+ . ' not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in'
83
+ . ' the "key" and "secret" options when creating a client or provide an instantiated'
84
+ . ' Aws\\Common\\Credentials\\CredentialsInterface object. (%s)', $e->getMessage());
85
+ throw new InstanceProfileCredentialsException($message, $e->getCode());
86
+ }
87
+
88
+ // Ensure that the status code was successful
89
+ if ($result['Code'] !== 'Success') {
90
+ $e = new InstanceProfileCredentialsException('Unexpected response code: ' . $result['Code']);
91
+ $e->setStatusCode($result['Code']);
92
+ throw $e;
93
+ }
94
+
95
+ return new Credentials(
96
+ $result['AccessKeyId'],
97
+ $result['SecretAccessKey'],
98
+ $result['Token'],
99
+ strtotime($result['Expiration'])
100
+ );
101
+ }
102
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/InstanceMetadata/Waiter/ServiceAvailable.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\InstanceMetadata\Waiter;
18
+
19
+ use Aws\Common\Waiter\AbstractResourceWaiter;
20
+ use Guzzle\Http\Exception\CurlException;
21
+
22
+ /**
23
+ * Waits until the instance metadata service is responding. Will send up to
24
+ * 4 requests with a 5 second delay between each try. Each try can last up to
25
+ * 11 seconds to complete if the service is not responding.
26
+ *
27
+ * @codeCoverageIgnore
28
+ */
29
+ class ServiceAvailable extends AbstractResourceWaiter
30
+ {
31
+ protected $interval = 5;
32
+ protected $maxAttempts = 4;
33
+
34
+ /**
35
+ * {@inheritdoc}
36
+ */
37
+ public function doWait()
38
+ {
39
+ $request = $this->client->get();
40
+ try {
41
+ $request->getCurlOptions()->set(CURLOPT_CONNECTTIMEOUT, 10)
42
+ ->set(CURLOPT_TIMEOUT, 10);
43
+ $request->send();
44
+
45
+ return true;
46
+ } catch (CurlException $e) {
47
+ return false;
48
+ }
49
+ }
50
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Iterator/AwsResourceIterator.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Iterator;
18
+
19
+ use Aws\Common\Enum\UaString as Ua;
20
+ use Aws\Common\Exception\RuntimeException;
21
+ Use Guzzle\Service\Resource\Model;
22
+ use Guzzle\Service\Resource\ResourceIterator;
23
+
24
+ /**
25
+ * Iterate over a client command
26
+ */
27
+ class AwsResourceIterator extends ResourceIterator
28
+ {
29
+ /**
30
+ * @var Model Result of a command
31
+ */
32
+ protected $lastResult = null;
33
+
34
+ /**
35
+ * Provides access to the most recent result obtained by the iterator. This makes it easier to extract any
36
+ * additional information from the result which you do not have access to from the values emitted by the iterator
37
+ *
38
+ * @return Model|null
39
+ */
40
+ public function getLastResult()
41
+ {
42
+ return $this->lastResult;
43
+ }
44
+
45
+ /**
46
+ * {@inheritdoc}
47
+ * This AWS specific version of the resource iterator provides a default implementation of the typical AWS iterator
48
+ * process. It relies on configuration and extension to implement the operation-specific logic of handling results
49
+ * and nextTokens. This method will loop until resources are acquired or there are no more iterations available.
50
+ */
51
+ protected function sendRequest()
52
+ {
53
+ do {
54
+ // Prepare the request including setting the next token
55
+ $this->prepareRequest();
56
+ if ($this->nextToken) {
57
+ $this->applyNextToken();
58
+ }
59
+
60
+ // Execute the request and handle the results
61
+ $this->command->add(Ua::OPTION, Ua::ITERATOR);
62
+ $this->lastResult = $this->command->getResult();
63
+ $resources = $this->handleResults($this->lastResult);
64
+ $this->determineNextToken($this->lastResult);
65
+
66
+ // If no resources collected, prepare to reiterate before yielding
67
+ if ($reiterate = empty($resources) && $this->nextToken) {
68
+ $this->command = clone $this->originalCommand;
69
+ }
70
+ } while ($reiterate);
71
+
72
+ return $resources;
73
+ }
74
+
75
+ protected function prepareRequest()
76
+ {
77
+ // Get the limit parameter key to set
78
+ $limitKey = $this->get('limit_key');
79
+ if ($limitKey && ($limit = $this->command->get($limitKey))) {
80
+ $pageSize = $this->calculatePageSize();
81
+
82
+ // If the limit of the command is different than the pageSize of the iterator, use the smaller value
83
+ if ($limit && $pageSize) {
84
+ $realLimit = min($limit, $pageSize);
85
+ $this->command->set($limitKey, $realLimit);
86
+ }
87
+ }
88
+ }
89
+
90
+ protected function handleResults(Model $result)
91
+ {
92
+ $results = array();
93
+
94
+ // Get the result key that contains the results
95
+ if ($resultKey = $this->get('result_key')) {
96
+ $results = $this->getValueFromResult($result, $resultKey) ?: array();
97
+ }
98
+
99
+ return $results;
100
+ }
101
+
102
+ protected function applyNextToken()
103
+ {
104
+ // Get the token parameter key to set
105
+ if ($tokenParam = $this->get('input_token')) {
106
+ // Set the next token. Works with multi-value tokens
107
+ if (is_array($tokenParam)) {
108
+ if (is_array($this->nextToken) && count($tokenParam) === count($this->nextToken)) {
109
+ foreach (array_combine($tokenParam, $this->nextToken) as $param => $token) {
110
+ $this->command->set($param, $token);
111
+ }
112
+ } else {
113
+ throw new RuntimeException('The definition of the iterator\'s token parameter and the actual token '
114
+ . 'value are not compatible.');
115
+ }
116
+ } else {
117
+ $this->command->set($tokenParam, $this->nextToken);
118
+ }
119
+ }
120
+ }
121
+
122
+ protected function determineNextToken(Model $result)
123
+ {
124
+ $this->nextToken = null;
125
+
126
+ // If the value of "more_results" is true or there is no "more_results" to check, then try to get the next token
127
+ $moreKey = $this->get('more_results');
128
+ if ($moreKey === null || $this->getValueFromResult($result, $moreKey)) {
129
+ // Get the token key to check
130
+ if ($tokenKey = $this->get('output_token')) {
131
+ // Get the next token's value. Works with multi-value tokens
132
+ if (is_array($tokenKey)) {
133
+ $this->nextToken = array();
134
+ foreach ($tokenKey as $key) {
135
+ $this->nextToken[] = $this->getValueFromResult($result, $key);
136
+ }
137
+ } else {
138
+ $this->nextToken = $this->getValueFromResult($result, $tokenKey);
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Extracts the value from the result using Collection::getPath. Also adds some additional logic for keys that need
146
+ * to access n-1 indexes (e.g., ImportExport, Kinesis). The n-1 logic only works for the known cases. We will switch
147
+ * to a jmespath implementation in the future to cover all cases
148
+ *
149
+ * @param Model $result
150
+ * @param string $key
151
+ *
152
+ * @return mixed|null
153
+ */
154
+ protected function getValueFromResult(Model $result, $key)
155
+ {
156
+ // Special handling for keys that need to access n-1 indexes
157
+ if (strpos($key, '#') !== false) {
158
+ $keyParts = explode('#', $key, 2);
159
+ $items = $result->getPath(trim($keyParts[0], '/'));
160
+ if ($items && is_array($items)) {
161
+ $index = count($items) - 1;
162
+ $key = strtr($key, array('#' => $index));
163
+ }
164
+ }
165
+
166
+ // Get the value
167
+ return $result->getPath($key);
168
+ }
169
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Iterator/AwsResourceIteratorFactory.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Aws\Common\Iterator;
4
+
5
+ use Aws\Common\Exception\InvalidArgumentException;
6
+ use Guzzle\Common\Collection;
7
+ use Guzzle\Service\Command\CommandInterface;
8
+ use Guzzle\Service\Resource\ResourceIteratorFactoryInterface;
9
+
10
+ /**
11
+ * Resource iterator factory used to instantiate the default AWS resource iterator with the correct configuration or
12
+ * use a concrete iterator class if one exists
13
+ */
14
+ class AwsResourceIteratorFactory implements ResourceIteratorFactoryInterface
15
+ {
16
+ /**
17
+ * @var array Default configuration values for iterators
18
+ */
19
+ protected static $defaultIteratorConfig = array(
20
+ 'input_token' => null,
21
+ 'output_token' => null,
22
+ 'limit_key' => null,
23
+ 'result_key' => null,
24
+ 'more_results' => null,
25
+ );
26
+
27
+ /**
28
+ * @var array Legacy configuration options mapped to their new names
29
+ */
30
+ private static $legacyConfigOptions = array(
31
+ 'token_param' => 'input_token',
32
+ 'token_key' => 'output_token',
33
+ 'limit_param' => 'limit_key',
34
+ 'more_key' => 'more_results',
35
+ );
36
+
37
+ /**
38
+ * @var array Iterator configuration for each iterable operation
39
+ */
40
+ protected $config;
41
+
42
+ /**
43
+ * @var ResourceIteratorFactoryInterface Another factory that will be used first to instantiate the iterator
44
+ */
45
+ protected $primaryIteratorFactory;
46
+
47
+ /**
48
+ * @param array $config An array of configuration values for the factory
49
+ * @param ResourceIteratorFactoryInterface $primaryIteratorFactory Another factory to use for chain of command
50
+ */
51
+ public function __construct(array $config, ResourceIteratorFactoryInterface $primaryIteratorFactory = null)
52
+ {
53
+ $this->primaryIteratorFactory = $primaryIteratorFactory;
54
+ $this->config = array();
55
+ foreach ($config as $name => $operation) {
56
+ $this->config[$name] = $operation + self::$defaultIteratorConfig;
57
+ }
58
+ }
59
+
60
+ public function build(CommandInterface $command, array $options = array())
61
+ {
62
+ // Get the configuration data for the command
63
+ $commandName = $command->getName();
64
+ $commandSupported = isset($this->config[$commandName]);
65
+ $options = $this->translateLegacyConfigOptions($options);
66
+ $options += $commandSupported ? $this->config[$commandName] : array();
67
+
68
+ // Instantiate the iterator using the primary factory (if one was provided)
69
+ if ($this->primaryIteratorFactory && $this->primaryIteratorFactory->canBuild($command)) {
70
+ $iterator = $this->primaryIteratorFactory->build($command, $options);
71
+ } elseif (!$commandSupported) {
72
+ throw new InvalidArgumentException("Iterator was not found for {$commandName}.");
73
+ } else {
74
+ // Instantiate a generic AWS resource iterator
75
+ $iterator = new AwsResourceIterator($command, $options);
76
+ }
77
+
78
+ return $iterator;
79
+ }
80
+
81
+ public function canBuild(CommandInterface $command)
82
+ {
83
+ if ($this->primaryIteratorFactory) {
84
+ return $this->primaryIteratorFactory->canBuild($command);
85
+ } else {
86
+ return isset($this->config[$command->getName()]);
87
+ }
88
+ }
89
+
90
+ /**
91
+ * @param array $config The config for a single operation
92
+ *
93
+ * @return array The modified config with legacy options translated
94
+ */
95
+ private function translateLegacyConfigOptions($config)
96
+ {
97
+ foreach (self::$legacyConfigOptions as $legacyOption => $newOption) {
98
+ if (isset($config[$legacyOption])) {
99
+ $config[$newOption] = $config[$legacyOption];
100
+ unset($config[$legacyOption]);
101
+ }
102
+ }
103
+
104
+ return $config;
105
+ }
106
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractTransfer.php ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+ use Aws\Common\Exception\MultipartUploadException;
21
+ use Aws\Common\Exception\RuntimeException;
22
+ use Guzzle\Common\AbstractHasDispatcher;
23
+ use Guzzle\Http\EntityBody;
24
+ use Guzzle\Http\EntityBodyInterface;
25
+ use Guzzle\Service\Command\OperationCommand;
26
+ use Guzzle\Service\Resource\Model;
27
+
28
+ /**
29
+ * Abstract class for transfer commonalities
30
+ */
31
+ abstract class AbstractTransfer extends AbstractHasDispatcher implements TransferInterface
32
+ {
33
+ const BEFORE_UPLOAD = 'multipart_upload.before_upload';
34
+ const AFTER_UPLOAD = 'multipart_upload.after_upload';
35
+ const BEFORE_PART_UPLOAD = 'multipart_upload.before_part_upload';
36
+ const AFTER_PART_UPLOAD = 'multipart_upload.after_part_upload';
37
+ const AFTER_ABORT = 'multipart_upload.after_abort';
38
+ const AFTER_COMPLETE = 'multipart_upload.after_complete';
39
+
40
+ /**
41
+ * @var AwsClientInterface Client used for the transfers
42
+ */
43
+ protected $client;
44
+
45
+ /**
46
+ * @var TransferStateInterface State of the transfer
47
+ */
48
+ protected $state;
49
+
50
+ /**
51
+ * @var EntityBody Data source of the transfer
52
+ */
53
+ protected $source;
54
+
55
+ /**
56
+ * @var array Associative array of options
57
+ */
58
+ protected $options;
59
+
60
+ /**
61
+ * @var int Size of each part to upload
62
+ */
63
+ protected $partSize;
64
+
65
+ /**
66
+ * @var bool Whether or not the transfer has been stopped
67
+ */
68
+ protected $stopped = false;
69
+
70
+ /**
71
+ * Construct a new transfer object
72
+ *
73
+ * @param AwsClientInterface $client Client used for the transfers
74
+ * @param TransferStateInterface $state State used to track transfer
75
+ * @param EntityBody $source Data source of the transfer
76
+ * @param array $options Array of options to apply
77
+ */
78
+ public function __construct(
79
+ AwsClientInterface $client,
80
+ TransferStateInterface $state,
81
+ EntityBody $source,
82
+ array $options = array()
83
+ ) {
84
+ $this->client = $client;
85
+ $this->state = $state;
86
+ $this->source = $source;
87
+ $this->options = $options;
88
+
89
+ $this->init();
90
+
91
+ $this->partSize = $this->calculatePartSize();
92
+ }
93
+
94
+ public function __invoke()
95
+ {
96
+ return $this->upload();
97
+ }
98
+
99
+ /**
100
+ * {@inheritdoc}
101
+ */
102
+ public static function getAllEvents()
103
+ {
104
+ return array(
105
+ self::BEFORE_PART_UPLOAD,
106
+ self::AFTER_UPLOAD,
107
+ self::BEFORE_PART_UPLOAD,
108
+ self::AFTER_PART_UPLOAD,
109
+ self::AFTER_ABORT,
110
+ self::AFTER_COMPLETE
111
+ );
112
+ }
113
+
114
+ /**
115
+ * {@inheritdoc}
116
+ */
117
+ public function abort()
118
+ {
119
+ $command = $this->getAbortCommand();
120
+ $result = $command->getResult();
121
+
122
+ $this->state->setAborted(true);
123
+ $this->stop();
124
+ $this->dispatch(self::AFTER_ABORT, $this->getEventData($command));
125
+
126
+ return $result;
127
+ }
128
+
129
+ /**
130
+ * {@inheritdoc}
131
+ */
132
+ public function stop()
133
+ {
134
+ $this->stopped = true;
135
+
136
+ return $this->state;
137
+ }
138
+
139
+ /**
140
+ * {@inheritdoc}
141
+ */
142
+ public function getState()
143
+ {
144
+ return $this->state;
145
+ }
146
+
147
+ /**
148
+ * Get the array of options associated with the transfer
149
+ *
150
+ * @return array
151
+ */
152
+ public function getOptions()
153
+ {
154
+ return $this->options;
155
+ }
156
+
157
+ /**
158
+ * Set an option on the transfer
159
+ *
160
+ * @param string $option Name of the option
161
+ * @param mixed $value Value to set
162
+ *
163
+ * @return self
164
+ */
165
+ public function setOption($option, $value)
166
+ {
167
+ $this->options[$option] = $value;
168
+
169
+ return $this;
170
+ }
171
+
172
+ /**
173
+ * Get the source body of the upload
174
+ *
175
+ * @return EntityBodyInterface
176
+ */
177
+ public function getSource()
178
+ {
179
+ return $this->source;
180
+ }
181
+
182
+ /**
183
+ * {@inheritdoc}
184
+ * @throws MultipartUploadException when an error is encountered. Use getLastException() to get more information.
185
+ * @throws RuntimeException when attempting to upload an aborted transfer
186
+ */
187
+ public function upload()
188
+ {
189
+ if ($this->state->isAborted()) {
190
+ throw new RuntimeException('The transfer has been aborted and cannot be uploaded');
191
+ }
192
+
193
+ $this->stopped = false;
194
+ $eventData = $this->getEventData();
195
+ $this->dispatch(self::BEFORE_UPLOAD, $eventData);
196
+
197
+ try {
198
+ $this->transfer();
199
+ $this->dispatch(self::AFTER_UPLOAD, $eventData);
200
+
201
+ if ($this->stopped) {
202
+ return null;
203
+ } else {
204
+ $result = $this->complete();
205
+ $this->dispatch(self::AFTER_COMPLETE, $eventData);
206
+ }
207
+ } catch (\Exception $e) {
208
+ throw new MultipartUploadException($this->state, $e);
209
+ }
210
+
211
+ return $result;
212
+ }
213
+
214
+ /**
215
+ * Get an array used for event notifications
216
+ *
217
+ * @param OperationCommand $command Command to include in event data
218
+ *
219
+ * @return array
220
+ */
221
+ protected function getEventData(OperationCommand $command = null)
222
+ {
223
+ $data = array(
224
+ 'transfer' => $this,
225
+ 'source' => $this->source,
226
+ 'options' => $this->options,
227
+ 'client' => $this->client,
228
+ 'part_size' => $this->partSize,
229
+ 'state' => $this->state
230
+ );
231
+
232
+ if ($command) {
233
+ $data['command'] = $command;
234
+ }
235
+
236
+ return $data;
237
+ }
238
+
239
+ /**
240
+ * Hook to initialize the transfer
241
+ */
242
+ protected function init() {}
243
+
244
+ /**
245
+ * Determine the upload part size based on the size of the source data and
246
+ * taking into account the acceptable minimum and maximum part sizes.
247
+ *
248
+ * @return int The part size
249
+ */
250
+ abstract protected function calculatePartSize();
251
+
252
+ /**
253
+ * Complete the multipart upload
254
+ *
255
+ * @return Model Returns the result of the complete multipart upload command
256
+ */
257
+ abstract protected function complete();
258
+
259
+ /**
260
+ * Hook to implement in subclasses to perform the actual transfer
261
+ */
262
+ abstract protected function transfer();
263
+
264
+ /**
265
+ * Fetches the abort command fom the concrete implementation
266
+ *
267
+ * @return OperationCommand
268
+ */
269
+ abstract protected function getAbortCommand();
270
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractTransferState.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+
21
+ /**
22
+ * State of a multipart upload
23
+ */
24
+ abstract class AbstractTransferState implements TransferStateInterface
25
+ {
26
+ /**
27
+ * @var UploadIdInterface Object holding params used to identity the upload part
28
+ */
29
+ protected $uploadId;
30
+
31
+ /**
32
+ * @var array Array of parts where the part number is the index
33
+ */
34
+ protected $parts = array();
35
+
36
+ /**
37
+ * @var bool Whether or not the transfer was aborted
38
+ */
39
+ protected $aborted = false;
40
+
41
+ /**
42
+ * Construct a new transfer state object
43
+ *
44
+ * @param UploadIdInterface $uploadId Upload identifier object
45
+ */
46
+ public function __construct(UploadIdInterface $uploadId)
47
+ {
48
+ $this->uploadId = $uploadId;
49
+ }
50
+
51
+ /**
52
+ * {@inheritdoc}
53
+ */
54
+ public function getUploadId()
55
+ {
56
+ return $this->uploadId;
57
+ }
58
+
59
+ /**
60
+ * Get a data value from the transfer state's uploadId
61
+ *
62
+ * @param string $key Key to retrieve (e.g. Bucket, Key, UploadId, etc)
63
+ *
64
+ * @return string|null
65
+ */
66
+ public function getFromId($key)
67
+ {
68
+ $params = $this->uploadId->toParams();
69
+
70
+ return isset($params[$key]) ? $params[$key] : null;
71
+ }
72
+
73
+ /**
74
+ * {@inheritdoc}
75
+ */
76
+ public function getPart($partNumber)
77
+ {
78
+ return isset($this->parts[$partNumber]) ? $this->parts[$partNumber] : null;
79
+ }
80
+
81
+ /**
82
+ * {@inheritdoc}
83
+ */
84
+ public function addPart(UploadPartInterface $part)
85
+ {
86
+ $partNumber = $part->getPartNumber();
87
+ $this->parts[$partNumber] = $part;
88
+
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * {@inheritdoc}
94
+ */
95
+ public function hasPart($partNumber)
96
+ {
97
+ return isset($this->parts[$partNumber]);
98
+ }
99
+
100
+ /**
101
+ * {@inheritdoc}
102
+ */
103
+ public function getPartNumbers()
104
+ {
105
+ return array_keys($this->parts);
106
+ }
107
+
108
+ /**
109
+ * {@inheritdoc}
110
+ */
111
+ public function setAborted($aborted)
112
+ {
113
+ $this->aborted = (bool) $aborted;
114
+
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * {@inheritdoc}
120
+ */
121
+ public function isAborted()
122
+ {
123
+ return $this->aborted;
124
+ }
125
+
126
+ /**
127
+ * {@inheritdoc}
128
+ */
129
+ public function count()
130
+ {
131
+ return count($this->parts);
132
+ }
133
+
134
+ /**
135
+ * {@inheritdoc}
136
+ */
137
+ public function getIterator()
138
+ {
139
+ return new \ArrayIterator($this->parts);
140
+ }
141
+
142
+ /**
143
+ * {@inheritdoc}
144
+ */
145
+ public function serialize()
146
+ {
147
+ return serialize(get_object_vars($this));
148
+ }
149
+
150
+ /**
151
+ * {@inheritdoc}
152
+ */
153
+ public function unserialize($serialized)
154
+ {
155
+ $data = unserialize($serialized);
156
+ foreach (get_object_vars($this) as $property => $oldValue) {
157
+ if (array_key_exists($property, $data)) {
158
+ $this->{$property} = $data[$property];
159
+ } else {
160
+ throw new RuntimeException("The {$property} property could be restored during unserialization.");
161
+ }
162
+ }
163
+ }
164
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractUploadBuilder.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+ use Aws\Common\Exception\InvalidArgumentException;
21
+ use Guzzle\Http\EntityBody;
22
+
23
+ /**
24
+ * Easily create a multipart uploader used to quickly and reliably upload a
25
+ * large file or data stream to Amazon S3 using multipart uploads
26
+ */
27
+ abstract class AbstractUploadBuilder
28
+ {
29
+ /**
30
+ * @var AwsClientInterface Client used to transfer requests
31
+ */
32
+ protected $client;
33
+
34
+ /**
35
+ * @var TransferStateInterface State of the transfer
36
+ */
37
+ protected $state;
38
+
39
+ /**
40
+ * @var EntityBody Source of the data
41
+ */
42
+ protected $source;
43
+
44
+ /**
45
+ * @var array Array of headers to set on the object
46
+ */
47
+ protected $headers = array();
48
+
49
+ /**
50
+ * Return a new instance of the UploadBuilder
51
+ *
52
+ * @return static
53
+ */
54
+ public static function newInstance()
55
+ {
56
+ return new static;
57
+ }
58
+
59
+ /**
60
+ * Set the client used to connect to the AWS service
61
+ *
62
+ * @param AwsClientInterface $client Client to use
63
+ *
64
+ * @return $this
65
+ */
66
+ public function setClient(AwsClientInterface $client)
67
+ {
68
+ $this->client = $client;
69
+
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Set the state of the upload. This is useful for resuming from a previously started multipart upload.
75
+ * You must use a local file stream as the data source if you wish to resume from a previous upload.
76
+ *
77
+ * @param TransferStateInterface|string $state Pass a TransferStateInterface object or the ID of the initiated
78
+ * multipart upload. When an ID is passed, the builder will create a
79
+ * state object using the data from a ListParts API response.
80
+ *
81
+ * @return $this
82
+ */
83
+ public function resumeFrom($state)
84
+ {
85
+ $this->state = $state;
86
+
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Set the data source of the transfer
92
+ *
93
+ * @param resource|string|EntityBody $source Source of the transfer. Pass a string to transfer from a file on disk.
94
+ * You can also stream from a resource returned from fopen or a Guzzle
95
+ * {@see EntityBody} object.
96
+ *
97
+ * @return $this
98
+ * @throws InvalidArgumentException when the source cannot be found or opened
99
+ */
100
+ public function setSource($source)
101
+ {
102
+ // Use the contents of a file as the data source
103
+ if (is_string($source)) {
104
+ if (!file_exists($source)) {
105
+ throw new InvalidArgumentException("File does not exist: {$source}");
106
+ }
107
+ // Clear the cache so that we send accurate file sizes
108
+ clearstatcache(true, $source);
109
+ $source = fopen($source, 'r');
110
+ }
111
+
112
+ $this->source = EntityBody::factory($source);
113
+
114
+ if ($this->source->isSeekable() && $this->source->getSize() == 0) {
115
+ throw new InvalidArgumentException('Empty body provided to upload builder');
116
+ }
117
+
118
+ return $this;
119
+ }
120
+
121
+ /**
122
+ * Specify the headers to set on the upload
123
+ *
124
+ * @param array $headers Headers to add to the uploaded object
125
+ *
126
+ * @return $this
127
+ */
128
+ public function setHeaders(array $headers)
129
+ {
130
+ $this->headers = $headers;
131
+
132
+ return $this;
133
+ }
134
+
135
+ /**
136
+ * Build the appropriate uploader based on the builder options
137
+ *
138
+ * @return TransferInterface
139
+ */
140
+ abstract public function build();
141
+
142
+ /**
143
+ * Initiate the multipart upload
144
+ *
145
+ * @return TransferStateInterface
146
+ */
147
+ abstract protected function initiateMultipartUpload();
148
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractUploadId.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+
21
+ /**
22
+ * An object that encapsulates the data identifying an upload
23
+ */
24
+ abstract class AbstractUploadId implements UploadIdInterface
25
+ {
26
+ /**
27
+ * @var array Expected values (with defaults)
28
+ */
29
+ protected static $expectedValues = array();
30
+
31
+ /**
32
+ * @var array Params representing the identifying information
33
+ */
34
+ protected $data = array();
35
+
36
+ /**
37
+ * {@inheritdoc}
38
+ */
39
+ public static function fromParams($data)
40
+ {
41
+ $uploadId = new static();
42
+ $uploadId->loadData($data);
43
+
44
+ return $uploadId;
45
+ }
46
+
47
+ /**
48
+ * {@inheritdoc}
49
+ */
50
+ public function toParams()
51
+ {
52
+ return $this->data;
53
+ }
54
+
55
+ /**
56
+ * {@inheritdoc}
57
+ */
58
+ public function serialize()
59
+ {
60
+ return serialize($this->data);
61
+ }
62
+
63
+ /**
64
+ * {@inheritdoc}
65
+ */
66
+ public function unserialize($serialized)
67
+ {
68
+ $this->loadData(unserialize($serialized));
69
+ }
70
+
71
+ /**
72
+ * Loads an array of data into the UploadId by extracting only the needed keys
73
+ *
74
+ * @param array $data Data to load
75
+ *
76
+ * @throws InvalidArgumentException if a required key is missing
77
+ */
78
+ protected function loadData($data)
79
+ {
80
+ $data = array_replace(static::$expectedValues, array_intersect_key($data, static::$expectedValues));
81
+ foreach ($data as $key => $value) {
82
+ if (isset($data[$key])) {
83
+ $this->data[$key] = $data[$key];
84
+ } else {
85
+ throw new InvalidArgumentException("A required key [$key] was missing from the UploadId.");
86
+ }
87
+ }
88
+ }
89
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/AbstractUploadPart.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+
21
+ /**
22
+ * An object that encapsulates the data for an upload part
23
+ */
24
+ abstract class AbstractUploadPart implements UploadPartInterface
25
+ {
26
+ /**
27
+ * @var array A map of external array keys to internal property names
28
+ */
29
+ protected static $keyMap = array();
30
+
31
+ /**
32
+ * @var int The number of the upload part representing its order in the overall upload
33
+ */
34
+ protected $partNumber;
35
+
36
+ /**
37
+ * {@inheritdoc}
38
+ */
39
+ public static function fromArray($data)
40
+ {
41
+ $part = new static();
42
+ $part->loadData($data);
43
+
44
+ return $part;
45
+ }
46
+
47
+ /**
48
+ * {@inheritdoc}
49
+ */
50
+ public function getPartNumber()
51
+ {
52
+ return $this->partNumber;
53
+ }
54
+
55
+ /**
56
+ * {@inheritdoc}
57
+ */
58
+ public function toArray()
59
+ {
60
+ $array = array();
61
+ foreach (static::$keyMap as $key => $property) {
62
+ $array[$key] = $this->{$property};
63
+ }
64
+
65
+ return $array;
66
+ }
67
+
68
+ /**
69
+ * {@inheritdoc}
70
+ */
71
+ public function serialize()
72
+ {
73
+ return serialize($this->toArray());
74
+ }
75
+
76
+ /**
77
+ * {@inheritdoc}
78
+ */
79
+ public function unserialize($serialized)
80
+ {
81
+ $this->loadData(unserialize($serialized));
82
+ }
83
+
84
+ /**
85
+ * Loads an array of data into the upload part by extracting only the needed keys
86
+ *
87
+ * @param array|\Traversable $data Data to load into the upload part value object
88
+ *
89
+ * @throws InvalidArgumentException if a required key is missing
90
+ */
91
+ protected function loadData($data)
92
+ {
93
+ foreach (static::$keyMap as $key => $property) {
94
+ if (isset($data[$key])) {
95
+ $this->{$property} = $data[$key];
96
+ } else {
97
+ throw new InvalidArgumentException("A required key [$key] was missing from the upload part.");
98
+ }
99
+ }
100
+ }
101
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/TransferInterface.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ use Guzzle\Common\HasDispatcherInterface;
20
+ use Guzzle\Service\Resource\Model;
21
+
22
+ /**
23
+ * Interface for transferring the contents of a data source to an AWS service via a multipart upload interface
24
+ */
25
+ interface TransferInterface extends HasDispatcherInterface
26
+ {
27
+ /**
28
+ * Upload the source to using a multipart upload
29
+ *
30
+ * @return Model|null Result of the complete multipart upload command or null if uploading was stopped
31
+ */
32
+ public function upload();
33
+
34
+ /**
35
+ * Abort the upload
36
+ *
37
+ * @return Model Returns the result of the abort multipart upload command
38
+ */
39
+ public function abort();
40
+
41
+ /**
42
+ * Get the current state of the upload
43
+ *
44
+ * @return TransferStateInterface
45
+ */
46
+ public function getState();
47
+
48
+ /**
49
+ * Stop the transfer and retrieve the current state.
50
+ *
51
+ * This allows you to stop and later resume a long running transfer if needed.
52
+ *
53
+ * @return TransferStateInterface
54
+ */
55
+ public function stop();
56
+
57
+ /**
58
+ * Set an option on the transfer object
59
+ *
60
+ * @param string $option Option to set
61
+ * @param mixed $value The value to set
62
+ *
63
+ * @return self
64
+ */
65
+ public function setOption($option, $value);
66
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/TransferStateInterface.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+
21
+ /**
22
+ * State of a multipart upload
23
+ */
24
+ interface TransferStateInterface extends \Countable, \IteratorAggregate, \Serializable
25
+ {
26
+ /**
27
+ * Create the transfer state from the results of list parts request
28
+ *
29
+ * @param AwsClientInterface $client Client used to send the request
30
+ * @param UploadIdInterface $uploadId Params needed to identify the upload and form the request
31
+ *
32
+ * @return self
33
+ */
34
+ public static function fromUploadId(AwsClientInterface $client, UploadIdInterface $uploadId);
35
+
36
+ /**
37
+ * Get the params used to identify an upload part
38
+ *
39
+ * @return UploadIdInterface
40
+ */
41
+ public function getUploadId();
42
+
43
+ /**
44
+ * Get the part information of a specific part
45
+ *
46
+ * @param int $partNumber Part to retrieve
47
+ *
48
+ * @return UploadPartInterface
49
+ */
50
+ public function getPart($partNumber);
51
+
52
+ /**
53
+ * Add a part to the transfer state
54
+ *
55
+ * @param UploadPartInterface $part The part to add
56
+ *
57
+ * @return self
58
+ */
59
+ public function addPart(UploadPartInterface $part);
60
+
61
+ /**
62
+ * Check if a specific part has been uploaded
63
+ *
64
+ * @param int $partNumber Part to check
65
+ *
66
+ * @return bool
67
+ */
68
+ public function hasPart($partNumber);
69
+
70
+ /**
71
+ * Get a list of all of the uploaded part numbers
72
+ *
73
+ * @return array
74
+ */
75
+ public function getPartNumbers();
76
+
77
+ /**
78
+ * Set whether or not the transfer has been aborted
79
+ *
80
+ * @param bool $aborted Set to true to mark the transfer as aborted
81
+ *
82
+ * @return self
83
+ */
84
+ public function setAborted($aborted);
85
+
86
+ /**
87
+ * Check if the transfer has been marked as aborted
88
+ *
89
+ * @return bool
90
+ */
91
+ public function isAborted();
92
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/UploadIdInterface.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ /**
20
+ * An object that encapsulates the data identifying an upload
21
+ */
22
+ interface UploadIdInterface extends \Serializable
23
+ {
24
+ /**
25
+ * Create an UploadId from an array
26
+ *
27
+ * @param array $data Data representing the upload identification
28
+ *
29
+ * @return self
30
+ */
31
+ public static function fromParams($data);
32
+
33
+ /**
34
+ * Returns the array form of the upload identification for use as command params
35
+ *
36
+ * @return array
37
+ */
38
+ public function toParams();
39
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Model/MultipartUpload/UploadPartInterface.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Model\MultipartUpload;
18
+
19
+ /**
20
+ * An object that encapsulates the data for an upload part
21
+ */
22
+ interface UploadPartInterface extends \Serializable
23
+ {
24
+ /**
25
+ * Create an upload part from an array
26
+ *
27
+ * @param array|\Traversable $data Data representing the upload part
28
+ *
29
+ * @return self
30
+ */
31
+ public static function fromArray($data);
32
+
33
+ /**
34
+ * Returns the part number of the upload part which is used as an identifier
35
+ *
36
+ * @return int
37
+ */
38
+ public function getPartNumber();
39
+
40
+ /**
41
+ * Returns the array form of the upload part
42
+ *
43
+ * @return array
44
+ */
45
+ public function toArray();
46
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Resources/aws-config.php ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ return array(
18
+ 'class' => 'Aws\Common\Aws',
19
+ 'services' => array(
20
+
21
+ 'default_settings' => array(
22
+ 'params' => array()
23
+ ),
24
+
25
+ 'autoscaling' => array(
26
+ 'alias' => 'AutoScaling',
27
+ 'extends' => 'default_settings',
28
+ 'class' => 'Aws\AutoScaling\AutoScalingClient'
29
+ ),
30
+
31
+ 'cloudformation' => array(
32
+ 'alias' => 'CloudFormation',
33
+ 'extends' => 'default_settings',
34
+ 'class' => 'Aws\CloudFormation\CloudFormationClient'
35
+ ),
36
+
37
+ 'cloudfront' => array(
38
+ 'alias' => 'CloudFront',
39
+ 'extends' => 'default_settings',
40
+ 'class' => 'Aws\CloudFront\CloudFrontClient'
41
+ ),
42
+
43
+ 'cloudfront_20120505' => array(
44
+ 'extends' => 'cloudfront',
45
+ 'params' => array(
46
+ 'version' => '2012-05-05'
47
+ )
48
+ ),
49
+
50
+ 'cloudhsm' => array(
51
+ 'alias' => 'CloudHsm',
52
+ 'extends' => 'default_settings',
53
+ 'class' => 'Aws\CloudHsm\CloudHsmClient'
54
+ ),
55
+
56
+ 'cloudsearch' => array(
57
+ 'alias' => 'CloudSearch',
58
+ 'extends' => 'default_settings',
59
+ 'class' => 'Aws\CloudSearch\CloudSearchClient'
60
+ ),
61
+
62
+ 'cloudsearch_20110201' => array(
63
+ 'extends' => 'cloudsearch',
64
+ 'params' => array(
65
+ 'version' => '2011-02-01'
66
+ )
67
+ ),
68
+
69
+ 'cloudsearchdomain' => array(
70
+ 'alias' => 'CloudSearchDomain',
71
+ 'extends' => 'default_settings',
72
+ 'class' => 'Aws\CloudSearchDomain\CloudSearchDomainClient'
73
+ ),
74
+
75
+ 'cloudtrail' => array(
76
+ 'alias' => 'CloudTrail',
77
+ 'extends' => 'default_settings',
78
+ 'class' => 'Aws\CloudTrail\CloudTrailClient'
79
+ ),
80
+
81
+ 'cloudwatch' => array(
82
+ 'alias' => 'CloudWatch',
83
+ 'extends' => 'default_settings',
84
+ 'class' => 'Aws\CloudWatch\CloudWatchClient'
85
+ ),
86
+
87
+ 'cloudwatchlogs' => array(
88
+ 'alias' => 'CloudWatchLogs',
89
+ 'extends' => 'default_settings',
90
+ 'class' => 'Aws\CloudWatchLogs\CloudWatchLogsClient'
91
+ ),
92
+
93
+ 'cognito-identity' => array(
94
+ 'alias' => 'CognitoIdentity',
95
+ 'extends' => 'default_settings',
96
+ 'class' => 'Aws\CognitoIdentity\CognitoIdentityClient'
97
+ ),
98
+
99
+ 'cognitoidentity' => array('extends' => 'cognito-identity'),
100
+
101
+ 'cognito-sync' => array(
102
+ 'alias' => 'CognitoSync',
103
+ 'extends' => 'default_settings',
104
+ 'class' => 'Aws\CognitoSync\CognitoSyncClient'
105
+ ),
106
+
107
+ 'cognitosync' => array('extends' => 'cognito-sync'),
108
+
109
+ 'codedeploy' => array(
110
+ 'alias' => 'CodeDeploy',
111
+ 'extends' => 'default_settings',
112
+ 'class' => 'Aws\CodeDeploy\CodeDeployClient'
113
+ ),
114
+
115
+ 'config' => array(
116
+ 'alias' => 'ConfigService',
117
+ 'extends' => 'default_settings',
118
+ 'class' => 'Aws\ConfigService\ConfigServiceClient'
119
+ ),
120
+
121
+ 'datapipeline' => array(
122
+ 'alias' => 'DataPipeline',
123
+ 'extends' => 'default_settings',
124
+ 'class' => 'Aws\DataPipeline\DataPipelineClient'
125
+ ),
126
+
127
+ 'directconnect' => array(
128
+ 'alias' => 'DirectConnect',
129
+ 'extends' => 'default_settings',
130
+ 'class' => 'Aws\DirectConnect\DirectConnectClient'
131
+ ),
132
+
133
+ 'dynamodb' => array(
134
+ 'alias' => 'DynamoDb',
135
+ 'extends' => 'default_settings',
136
+ 'class' => 'Aws\DynamoDb\DynamoDbClient'
137
+ ),
138
+
139
+ 'dynamodb_20111205' => array(
140
+ 'extends' => 'dynamodb',
141
+ 'params' => array(
142
+ 'version' => '2011-12-05'
143
+ )
144
+ ),
145
+
146
+ 'ec2' => array(
147
+ 'alias' => 'Ec2',
148
+ 'extends' => 'default_settings',
149
+ 'class' => 'Aws\Ec2\Ec2Client'
150
+ ),
151
+
152
+ 'ecs' => array(
153
+ 'alias' => 'Ecs',
154
+ 'extends' => 'default_settings',
155
+ 'class' => 'Aws\Ecs\EcsClient'
156
+ ),
157
+
158
+ 'elasticache' => array(
159
+ 'alias' => 'ElastiCache',
160
+ 'extends' => 'default_settings',
161
+ 'class' => 'Aws\ElastiCache\ElastiCacheClient'
162
+ ),
163
+
164
+ 'elasticbeanstalk' => array(
165
+ 'alias' => 'ElasticBeanstalk',
166
+ 'extends' => 'default_settings',
167
+ 'class' => 'Aws\ElasticBeanstalk\ElasticBeanstalkClient'
168
+ ),
169
+
170
+ 'elasticloadbalancing' => array(
171
+ 'alias' => 'ElasticLoadBalancing',
172
+ 'extends' => 'default_settings',
173
+ 'class' => 'Aws\ElasticLoadBalancing\ElasticLoadBalancingClient'
174
+ ),
175
+
176
+ 'elastictranscoder' => array(
177
+ 'alias' => 'ElasticTranscoder',
178
+ 'extends' => 'default_settings',
179
+ 'class' => 'Aws\ElasticTranscoder\ElasticTranscoderClient'
180
+ ),
181
+
182
+ 'emr' => array(
183
+ 'alias' => 'Emr',
184
+ 'extends' => 'default_settings',
185
+ 'class' => 'Aws\Emr\EmrClient'
186
+ ),
187
+
188
+ 'glacier' => array(
189
+ 'alias' => 'Glacier',
190
+ 'extends' => 'default_settings',
191
+ 'class' => 'Aws\Glacier\GlacierClient'
192
+ ),
193
+
194
+ 'kinesis' => array(
195
+ 'alias' => 'Kinesis',
196
+ 'extends' => 'default_settings',
197
+ 'class' => 'Aws\Kinesis\KinesisClient'
198
+ ),
199
+
200
+ 'kms' => array(
201
+ 'alias' => 'Kms',
202
+ 'extends' => 'default_settings',
203
+ 'class' => 'Aws\Kms\KmsClient'
204
+ ),
205
+
206
+ 'lambda' => array(
207
+ 'alias' => 'Lambda',
208
+ 'extends' => 'default_settings',
209
+ 'class' => 'Aws\Lambda\LambdaClient'
210
+ ),
211
+
212
+ 'iam' => array(
213
+ 'alias' => 'Iam',
214
+ 'extends' => 'default_settings',
215
+ 'class' => 'Aws\Iam\IamClient'
216
+ ),
217
+
218
+ 'importexport' => array(
219
+ 'alias' => 'ImportExport',
220
+ 'extends' => 'default_settings',
221
+ 'class' => 'Aws\ImportExport\ImportExportClient'
222
+ ),
223
+
224
+ 'opsworks' => array(
225
+ 'alias' => 'OpsWorks',
226
+ 'extends' => 'default_settings',
227
+ 'class' => 'Aws\OpsWorks\OpsWorksClient'
228
+ ),
229
+
230
+ 'rds' => array(
231
+ 'alias' => 'Rds',
232
+ 'extends' => 'default_settings',
233
+ 'class' => 'Aws\Rds\RdsClient'
234
+ ),
235
+
236
+ 'redshift' => array(
237
+ 'alias' => 'Redshift',
238
+ 'extends' => 'default_settings',
239
+ 'class' => 'Aws\Redshift\RedshiftClient'
240
+ ),
241
+
242
+ 'route53' => array(
243
+ 'alias' => 'Route53',
244
+ 'extends' => 'default_settings',
245
+ 'class' => 'Aws\Route53\Route53Client'
246
+ ),
247
+
248
+ 'route53domains' => array(
249
+ 'alias' => 'Route53Domains',
250
+ 'extends' => 'default_settings',
251
+ 'class' => 'Aws\Route53Domains\Route53DomainsClient'
252
+ ),
253
+
254
+ 's3' => array(
255
+ 'alias' => 'S3',
256
+ 'extends' => 'default_settings',
257
+ 'class' => 'Aws\S3\S3Client'
258
+ ),
259
+
260
+ 'sdb' => array(
261
+ 'alias' => 'SimpleDb',
262
+ 'extends' => 'default_settings',
263
+ 'class' => 'Aws\SimpleDb\SimpleDbClient'
264
+ ),
265
+
266
+ 'ses' => array(
267
+ 'alias' => 'Ses',
268
+ 'extends' => 'default_settings',
269
+ 'class' => 'Aws\Ses\SesClient'
270
+ ),
271
+
272
+ 'sns' => array(
273
+ 'alias' => 'Sns',
274
+ 'extends' => 'default_settings',
275
+ 'class' => 'Aws\Sns\SnsClient'
276
+ ),
277
+
278
+ 'sqs' => array(
279
+ 'alias' => 'Sqs',
280
+ 'extends' => 'default_settings',
281
+ 'class' => 'Aws\Sqs\SqsClient'
282
+ ),
283
+
284
+ 'ssm' => array(
285
+ 'alias' => 'Ssm',
286
+ 'extends' => 'default_settings',
287
+ 'class' => 'Aws\Ssm\SsmClient'
288
+ ),
289
+
290
+ 'storagegateway' => array(
291
+ 'alias' => 'StorageGateway',
292
+ 'extends' => 'default_settings',
293
+ 'class' => 'Aws\StorageGateway\StorageGatewayClient'
294
+ ),
295
+
296
+ 'sts' => array(
297
+ 'alias' => 'Sts',
298
+ 'extends' => 'default_settings',
299
+ 'class' => 'Aws\Sts\StsClient'
300
+ ),
301
+
302
+ 'support' => array(
303
+ 'alias' => 'Support',
304
+ 'extends' => 'default_settings',
305
+ 'class' => 'Aws\Support\SupportClient'
306
+ ),
307
+
308
+ 'swf' => array(
309
+ 'alias' => 'Swf',
310
+ 'extends' => 'default_settings',
311
+ 'class' => 'Aws\Swf\SwfClient'
312
+ ),
313
+ )
314
+ );
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Resources/public-endpoints.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ return array(
3
+ 'version' => 2,
4
+ 'endpoints' => array(
5
+ '*/*' => array(
6
+ 'endpoint' => '{service}.{region}.amazonaws.com'
7
+ ),
8
+ 'cn-north-1/*' => array(
9
+ 'endpoint' => '{service}.{region}.amazonaws.com.cn',
10
+ 'signatureVersion' => 'v4'
11
+ ),
12
+ 'us-gov-west-1/iam' => array(
13
+ 'endpoint' => 'iam.us-gov.amazonaws.com'
14
+ ),
15
+ 'us-gov-west-1/sts' => array(
16
+ 'endpoint' => 'sts.us-gov-west-1.amazonaws.com'
17
+ ),
18
+ 'us-gov-west-1/s3' => array(
19
+ 'endpoint' => 's3-{region}.amazonaws.com'
20
+ ),
21
+ '*/cloudfront' => array(
22
+ 'endpoint' => 'cloudfront.amazonaws.com',
23
+ 'credentialScope' => array(
24
+ 'region' => 'us-east-1'
25
+ )
26
+ ),
27
+ '*/iam' => array(
28
+ 'endpoint' => 'iam.amazonaws.com',
29
+ 'credentialScope' => array(
30
+ 'region' => 'us-east-1'
31
+ )
32
+ ),
33
+ '*/importexport' => array(
34
+ 'endpoint' => 'importexport.amazonaws.com',
35
+ 'credentialScope' => array(
36
+ 'region' => 'us-east-1'
37
+ )
38
+ ),
39
+ '*/route53' => array(
40
+ 'endpoint' => 'route53.amazonaws.com',
41
+ 'credentialScope' => array(
42
+ 'region' => 'us-east-1'
43
+ )
44
+ ),
45
+ '*/sts' => array(
46
+ 'endpoint' => 'sts.amazonaws.com',
47
+ 'credentialScope' => array(
48
+ 'region' => 'us-east-1'
49
+ )
50
+ ),
51
+ 'us-east-1/sdb' => array(
52
+ 'endpoint' => 'sdb.amazonaws.com'
53
+ ),
54
+ 'us-east-1/s3' => array(
55
+ 'endpoint' => 's3.amazonaws.com'
56
+ ),
57
+ 'us-west-1/s3' => array(
58
+ 'endpoint' => 's3-{region}.amazonaws.com'
59
+ ),
60
+ 'us-west-2/s3' => array(
61
+ 'endpoint' => 's3-{region}.amazonaws.com'
62
+ ),
63
+ 'eu-west-1/s3' => array(
64
+ 'endpoint' => 's3-{region}.amazonaws.com'
65
+ ),
66
+ 'ap-southeast-1/s3' => array(
67
+ 'endpoint' => 's3-{region}.amazonaws.com'
68
+ ),
69
+ 'ap-southeast-2/s3' => array(
70
+ 'endpoint' => 's3-{region}.amazonaws.com'
71
+ ),
72
+ 'ap-northeast-1/s3' => array(
73
+ 'endpoint' => 's3-{region}.amazonaws.com'
74
+ ),
75
+ 'sa-east-1/s3' => array(
76
+ 'endpoint' => 's3-{region}.amazonaws.com'
77
+ )
78
+ )
79
+ );
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Resources/sdk1-config.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ return array(
18
+ 'includes' => array('_aws'),
19
+ 'services' => array(
20
+
21
+ 'sdk1_settings' => array(
22
+ 'extends' => 'default_settings',
23
+ 'params' => array(
24
+ 'certificate_authority' => false
25
+ )
26
+ ),
27
+
28
+ 'v1.autoscaling' => array(
29
+ 'extends' => 'sdk1_settings',
30
+ 'class' => 'AmazonAS'
31
+ ),
32
+
33
+ 'v1.cloudformation' => array(
34
+ 'extends' => 'sdk1_settings',
35
+ 'class' => 'AmazonCloudFormation'
36
+ ),
37
+
38
+ 'v1.cloudfront' => array(
39
+ 'extends' => 'sdk1_settings',
40
+ 'class' => 'AmazonCloudFront'
41
+ ),
42
+
43
+ 'v1.cloudsearch' => array(
44
+ 'extends' => 'sdk1_settings',
45
+ 'class' => 'AmazonCloudSearch'
46
+ ),
47
+
48
+ 'v1.cloudwatch' => array(
49
+ 'extends' => 'sdk1_settings',
50
+ 'class' => 'AmazonCloudWatch'
51
+ ),
52
+
53
+ 'v1.dynamodb' => array(
54
+ 'extends' => 'sdk1_settings',
55
+ 'class' => 'AmazonDynamoDB'
56
+ ),
57
+
58
+ 'v1.ec2' => array(
59
+ 'extends' => 'sdk1_settings',
60
+ 'class' => 'AmazonEC2'
61
+ ),
62
+
63
+ 'v1.elasticache' => array(
64
+ 'extends' => 'sdk1_settings',
65
+ 'class' => 'AmazonElastiCache'
66
+ ),
67
+
68
+ 'v1.elasticbeanstalk' => array(
69
+ 'extends' => 'sdk1_settings',
70
+ 'class' => 'AmazonElasticBeanstalk'
71
+ ),
72
+
73
+ 'v1.elb' => array(
74
+ 'extends' => 'sdk1_settings',
75
+ 'class' => 'AmazonELB'
76
+ ),
77
+
78
+ 'v1.emr' => array(
79
+ 'extends' => 'sdk1_settings',
80
+ 'class' => 'AmazonEMR'
81
+ ),
82
+
83
+ 'v1.iam' => array(
84
+ 'extends' => 'sdk1_settings',
85
+ 'class' => 'AmazonIAM'
86
+ ),
87
+
88
+ 'v1.importexport' => array(
89
+ 'extends' => 'sdk1_settings',
90
+ 'class' => 'AmazonImportExport'
91
+ ),
92
+
93
+ 'v1.rds' => array(
94
+ 'extends' => 'sdk1_settings',
95
+ 'class' => 'AmazonRDS'
96
+ ),
97
+
98
+ 'v1.s3' => array(
99
+ 'extends' => 'sdk1_settings',
100
+ 'class' => 'AmazonS3'
101
+ ),
102
+
103
+ 'v1.sdb' => array(
104
+ 'extends' => 'sdk1_settings',
105
+ 'class' => 'AmazonSDB'
106
+ ),
107
+
108
+ 'v1.ses' => array(
109
+ 'extends' => 'sdk1_settings',
110
+ 'class' => 'AmazonSES'
111
+ ),
112
+
113
+ 'v1.sns' => array(
114
+ 'extends' => 'sdk1_settings',
115
+ 'class' => 'AmazonSNS'
116
+ ),
117
+
118
+ 'v1.sqs' => array(
119
+ 'extends' => 'sdk1_settings',
120
+ 'class' => 'AmazonSQS'
121
+ ),
122
+
123
+ 'v1.storagegateway' => array(
124
+ 'extends' => 'sdk1_settings',
125
+ 'class' => 'AmazonStorageGateway'
126
+ ),
127
+
128
+ 'v1.sts' => array(
129
+ 'extends' => 'sdk1_settings',
130
+ 'class' => 'AmazonSTS'
131
+ ),
132
+
133
+ 'v1.swf' => array(
134
+ 'extends' => 'sdk1_settings',
135
+ 'class' => 'AmazonSWF'
136
+ )
137
+ )
138
+ );
lib/amazon/aws/aws-sdk-php/src/Aws/Common/RulesEndpointProvider.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Aws\Common;
3
+
4
+ /**
5
+ * Provides endpoints based on a rules configuration file.
6
+ */
7
+ class RulesEndpointProvider
8
+ {
9
+ /** @var array */
10
+ private $patterns;
11
+
12
+ /**
13
+ * @param array $patterns Hash of endpoint patterns mapping to endpoint
14
+ * configurations.
15
+ */
16
+ public function __construct(array $patterns)
17
+ {
18
+ $this->patterns = $patterns;
19
+ }
20
+
21
+ /**
22
+ * Creates and returns the default RulesEndpointProvider based on the
23
+ * public rule sets.
24
+ *
25
+ * @return self
26
+ */
27
+ public static function fromDefaults()
28
+ {
29
+ return new self(require __DIR__ . '/Resources/public-endpoints.php');
30
+ }
31
+
32
+ public function __invoke(array $args = array())
33
+ {
34
+ if (!isset($args['service'])) {
35
+ throw new \InvalidArgumentException('Requires a "service" value');
36
+ }
37
+
38
+ if (!isset($args['region'])) {
39
+ throw new \InvalidArgumentException('Requires a "region" value');
40
+ }
41
+
42
+ foreach ($this->getKeys($args['region'], $args['service']) as $key) {
43
+ if (isset($this->patterns['endpoints'][$key])) {
44
+ return $this->expand($this->patterns['endpoints'][$key], $args);
45
+ }
46
+ }
47
+
48
+ throw new \RuntimeException('Could not resolve endpoint');
49
+ }
50
+
51
+ private function expand(array $config, array $args)
52
+ {
53
+ $scheme = isset($args['scheme']) ? $args['scheme'] : 'https';
54
+ $config['endpoint'] = $scheme . '://' . str_replace(
55
+ array('{service}', '{region}'),
56
+ array($args['service'], $args['region']),
57
+ $config['endpoint']
58
+ );
59
+
60
+ return $config;
61
+ }
62
+
63
+ private function getKeys($region, $service)
64
+ {
65
+ return array("$region/$service", "$region/*", "*/$service", "*/*");
66
+ }
67
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/AbstractSignature.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Signature;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Guzzle\Http\Message\RequestInterface;
21
+
22
+ abstract class AbstractSignature implements SignatureInterface
23
+ {
24
+ /**
25
+ * Provides the timestamp used for the class (used for mocking PHP's time() function)
26
+ *
27
+ * @return int
28
+ */
29
+ protected function getTimestamp()
30
+ {
31
+ return time();
32
+ }
33
+
34
+ /**
35
+ * @codeCoverageIgnore
36
+ */
37
+ public function createPresignedUrl(
38
+ RequestInterface $request,
39
+ CredentialsInterface $credentials,
40
+ $expires
41
+ ) {
42
+ throw new \BadMethodCallException(__METHOD__ . ' not implemented');
43
+ }
44
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/EndpointSignatureInterface.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Signature;
18
+
19
+ /**
20
+ * Interface for signatures that use specific region and service names when
21
+ * signing requests.
22
+ */
23
+ interface EndpointSignatureInterface extends SignatureInterface
24
+ {
25
+ /**
26
+ * Set the service name instead of inferring it from a request URL
27
+ *
28
+ * @param string $service Name of the service used when signing
29
+ *
30
+ * @return self
31
+ */
32
+ public function setServiceName($service);
33
+
34
+ /**
35
+ * Set the region name instead of inferring it from a request URL
36
+ *
37
+ * @param string $region Name of the region used when signing
38
+ *
39
+ * @return self
40
+ */
41
+ public function setRegionName($region);
42
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureInterface.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Signature;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Guzzle\Http\Message\RequestInterface;
21
+
22
+ /**
23
+ * Interface used to provide interchangeable strategies for signing requests
24
+ * using the various AWS signature protocols.
25
+ */
26
+ interface SignatureInterface
27
+ {
28
+ /**
29
+ * Signs the specified request with an AWS signing protocol by using the
30
+ * provided AWS account credentials and adding the required headers to the
31
+ * request.
32
+ *
33
+ * @param RequestInterface $request Request to add a signature to
34
+ * @param CredentialsInterface $credentials Signing credentials
35
+ */
36
+ public function signRequest(RequestInterface $request, CredentialsInterface $credentials);
37
+
38
+ /**
39
+ * Create a pre-signed URL
40
+ *
41
+ * @param RequestInterface $request Request to sign
42
+ * @param CredentialsInterface $credentials Credentials used to sign
43
+ * @param int|string|\DateTime $expires The time at which the URL should expire. This can be a Unix timestamp, a
44
+ * PHP DateTime object, or a string that can be evaluated by strtotime
45
+ * @return string
46
+ */
47
+ public function createPresignedUrl(
48
+ RequestInterface $request,
49
+ CredentialsInterface $credentials,
50
+ $expires
51
+ );
52
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureListener.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Signature;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Aws\Common\Credentials\NullCredentials;
21
+ use Guzzle\Common\Event;
22
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
23
+
24
+ /**
25
+ * Listener used to sign requests before they are sent over the wire
26
+ */
27
+ class SignatureListener implements EventSubscriberInterface
28
+ {
29
+ /**
30
+ * @var CredentialsInterface
31
+ */
32
+ protected $credentials;
33
+
34
+ /**
35
+ * @var SignatureInterface
36
+ */
37
+ protected $signature;
38
+
39
+ /**
40
+ * Construct a new request signing plugin
41
+ *
42
+ * @param CredentialsInterface $credentials Credentials used to sign requests
43
+ * @param SignatureInterface $signature Signature implementation
44
+ */
45
+ public function __construct(CredentialsInterface $credentials, SignatureInterface $signature)
46
+ {
47
+ $this->credentials = $credentials;
48
+ $this->signature = $signature;
49
+ }
50
+
51
+ /**
52
+ * {@inheritdoc}
53
+ */
54
+ public static function getSubscribedEvents()
55
+ {
56
+ return array(
57
+ 'request.before_send' => array('onRequestBeforeSend', -255),
58
+ 'client.credentials_changed' => array('onCredentialsChanged')
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Updates the listener with new credentials if the client is updated
64
+ *
65
+ * @param Event $event Event emitted
66
+ */
67
+ public function onCredentialsChanged(Event $event)
68
+ {
69
+ $this->credentials = $event['credentials'];
70
+ }
71
+
72
+ /**
73
+ * Signs requests before they are sent
74
+ *
75
+ * @param Event $event Event emitted
76
+ */
77
+ public function onRequestBeforeSend(Event $event)
78
+ {
79
+ if(!$this->credentials instanceof NullCredentials) {
80
+ $this->signature->signRequest($event['request'], $this->credentials);
81
+ }
82
+ }
83
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureV2.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Signature;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Guzzle\Http\Message\RequestInterface;
21
+
22
+ /**
23
+ * Implementation of Signature Version 2
24
+ * @link http://aws.amazon.com/articles/1928
25
+ */
26
+ class SignatureV2 extends AbstractSignature
27
+ {
28
+ public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
29
+ {
30
+ // refresh the cached timestamp
31
+ $timestamp = $this->getTimestamp(true);
32
+
33
+ // set values we need in CanonicalizedParameterString
34
+ $this->addParameter($request, 'Timestamp', gmdate('c', $timestamp));
35
+ $this->addParameter($request, 'SignatureVersion', '2');
36
+ $this->addParameter($request, 'SignatureMethod', 'HmacSHA256');
37
+ $this->addParameter($request, 'AWSAccessKeyId', $credentials->getAccessKeyId());
38
+
39
+ if ($token = $credentials->getSecurityToken()) {
40
+ $this->addParameter($request, 'SecurityToken', $token);
41
+ }
42
+
43
+ // Get the path and ensure it's absolute
44
+ $path = '/' . ltrim($request->getUrl(true)->normalizePath()->getPath(), '/');
45
+
46
+ // build string to sign
47
+ $sign = $request->getMethod() . "\n"
48
+ . $request->getHost() . "\n"
49
+ . $path . "\n"
50
+ . $this->getCanonicalizedParameterString($request);
51
+
52
+ // Add the string to sign to the request for debugging purposes
53
+ $request->getParams()->set('aws.string_to_sign', $sign);
54
+
55
+ $signature = base64_encode(
56
+ hash_hmac(
57
+ 'sha256',
58
+ $sign,
59
+ $credentials->getSecretKey(),
60
+ true
61
+ )
62
+ );
63
+
64
+ $this->addParameter($request, 'Signature', $signature);
65
+ }
66
+
67
+ /**
68
+ * Add a parameter key and value to the request according to type
69
+ *
70
+ * @param RequestInterface $request The request
71
+ * @param string $key The name of the parameter
72
+ * @param string $value The value of the parameter
73
+ */
74
+ public function addParameter(RequestInterface $request, $key, $value)
75
+ {
76
+ if ($request->getMethod() == 'POST') {
77
+ $request->setPostField($key, $value);
78
+ } else {
79
+ $request->getQuery()->set($key, $value);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Get the canonicalized query/parameter string for a request
85
+ *
86
+ * @param RequestInterface $request Request used to build canonicalized string
87
+ *
88
+ * @return string
89
+ */
90
+ private function getCanonicalizedParameterString(RequestInterface $request)
91
+ {
92
+ if ($request->getMethod() == 'POST') {
93
+ $params = $request->getPostFields()->toArray();
94
+ } else {
95
+ $params = $request->getQuery()->toArray();
96
+ }
97
+
98
+ // Don't resign a previous signature value
99
+ unset($params['Signature']);
100
+ uksort($params, 'strcmp');
101
+
102
+ $str = '';
103
+ foreach ($params as $key => $val) {
104
+ $str .= rawurlencode($key) . '=' . rawurlencode($val) . '&';
105
+ }
106
+
107
+ return substr($str, 0, -1);
108
+ }
109
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureV3Https.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Signature;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Aws\Common\Enum\DateFormat;
21
+ use Guzzle\Http\Message\RequestInterface;
22
+
23
+ /**
24
+ * Implementation of Signature Version 3 HTTPS
25
+ * @link http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/RESTAuthentication.html
26
+ */
27
+ class SignatureV3Https extends AbstractSignature
28
+ {
29
+ public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
30
+ {
31
+ // Add a date header if one is not set
32
+ if (!$request->hasHeader('date') && !$request->hasHeader('x-amz-date')) {
33
+ $request->setHeader('Date', gmdate(DateFormat::RFC1123, $this->getTimestamp()));
34
+ }
35
+
36
+ // Add the security token if one is present
37
+ if ($credentials->getSecurityToken()) {
38
+ $request->setHeader('x-amz-security-token', $credentials->getSecurityToken());
39
+ }
40
+
41
+ // Determine the string to sign
42
+ $stringToSign = (string) ($request->getHeader('Date') ?: $request->getHeader('x-amz-date'));
43
+ $request->getParams()->set('aws.string_to_sign', $stringToSign);
44
+
45
+ // Calculate the signature
46
+ $signature = base64_encode(hash_hmac('sha256', $stringToSign, $credentials->getSecretKey(), true));
47
+
48
+ // Add the authorization header to the request
49
+ $headerFormat = 'AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HmacSHA256,Signature=%s';
50
+ $request->setHeader('X-Amzn-Authorization', sprintf($headerFormat, $credentials->getAccessKeyId(), $signature));
51
+ }
52
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Signature/SignatureV4.php ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Signature;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Aws\Common\Enum\DateFormat;
21
+ use Aws\Common\HostNameUtils;
22
+ use Guzzle\Http\Message\EntityEnclosingRequestInterface;
23
+ use Guzzle\Http\Message\RequestFactory;
24
+ use Guzzle\Http\Message\RequestInterface;
25
+ use Guzzle\Http\QueryString;
26
+ use Guzzle\Http\Url;
27
+ use Guzzle\Stream\Stream;
28
+
29
+ /**
30
+ * Signature Version 4
31
+ * @link http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
32
+ */
33
+ class SignatureV4 extends AbstractSignature implements EndpointSignatureInterface
34
+ {
35
+ /** @var string Cache of the default empty entity-body payload */
36
+ const DEFAULT_PAYLOAD = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
37
+
38
+ /** @var string Explicitly set service name */
39
+ protected $serviceName;
40
+
41
+ /** @var string Explicitly set region name */
42
+ protected $regionName;
43
+
44
+ /** @var int Maximum number of hashes to cache */
45
+ protected $maxCacheSize = 50;
46
+
47
+ /** @var array Cache of previously signed values */
48
+ protected $hashCache = array();
49
+
50
+ /** @var int Size of the hash cache */
51
+ protected $cacheSize = 0;
52
+
53
+ /**
54
+ * @param string $serviceName Bind the signing to a particular service name
55
+ * @param string $regionName Bind the signing to a particular region name
56
+ */
57
+ public function __construct($serviceName = null, $regionName = null)
58
+ {
59
+ $this->serviceName = $serviceName;
60
+ $this->regionName = $regionName;
61
+ }
62
+
63
+ /**
64
+ * Set the service name instead of inferring it from a request URL
65
+ *
66
+ * @param string $service Name of the service used when signing
67
+ *
68
+ * @return self
69
+ */
70
+ public function setServiceName($service)
71
+ {
72
+ $this->serviceName = $service;
73
+
74
+ return $this;
75
+ }
76
+
77
+ /**
78
+ * Set the region name instead of inferring it from a request URL
79
+ *
80
+ * @param string $region Name of the region used when signing
81
+ *
82
+ * @return self
83
+ */
84
+ public function setRegionName($region)
85
+ {
86
+ $this->regionName = $region;
87
+
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Set the maximum number of computed hashes to cache
93
+ *
94
+ * @param int $maxCacheSize Maximum number of hashes to cache
95
+ *
96
+ * @return self
97
+ */
98
+ public function setMaxCacheSize($maxCacheSize)
99
+ {
100
+ $this->maxCacheSize = $maxCacheSize;
101
+
102
+ return $this;
103
+ }
104
+
105
+ public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
106
+ {
107
+ $timestamp = $this->getTimestamp();
108
+ $longDate = gmdate(DateFormat::ISO8601, $timestamp);
109
+ $shortDate = substr($longDate, 0, 8);
110
+
111
+ // Remove any previously set Authorization headers so that retries work
112
+ $request->removeHeader('Authorization');
113
+
114
+ // Requires a x-amz-date header or Date
115
+ if ($request->hasHeader('x-amz-date') || !$request->hasHeader('Date')) {
116
+ $request->setHeader('x-amz-date', $longDate);
117
+ } else {
118
+ $request->setHeader('Date', gmdate(DateFormat::RFC1123, $timestamp));
119
+ }
120
+
121
+ // Add the security token if one is present
122
+ if ($credentials->getSecurityToken()) {
123
+ $request->setHeader('x-amz-security-token', $credentials->getSecurityToken());
124
+ }
125
+
126
+ // Parse the service and region or use one that is explicitly set
127
+ $region = $this->regionName;
128
+ $service = $this->serviceName;
129
+ if (!$region || !$service) {
130
+ $url = Url::factory($request->getUrl());
131
+ $region = $region ?: HostNameUtils::parseRegionName($url);
132
+ $service = $service ?: HostNameUtils::parseServiceName($url);
133
+ }
134
+
135
+ $credentialScope = $this->createScope($shortDate, $region, $service);
136
+ $payload = $this->getPayload($request);
137
+ $signingContext = $this->createSigningContext($request, $payload);
138
+ $signingContext['string_to_sign'] = $this->createStringToSign(
139
+ $longDate,
140
+ $credentialScope,
141
+ $signingContext['canonical_request']
142
+ );
143
+
144
+ // Calculate the signing key using a series of derived keys
145
+ $signingKey = $this->getSigningKey($shortDate, $region, $service, $credentials->getSecretKey());
146
+ $signature = hash_hmac('sha256', $signingContext['string_to_sign'], $signingKey);
147
+
148
+ $request->setHeader('Authorization', "AWS4-HMAC-SHA256 "
149
+ . "Credential={$credentials->getAccessKeyId()}/{$credentialScope}, "
150
+ . "SignedHeaders={$signingContext['signed_headers']}, Signature={$signature}");
151
+
152
+ // Add debug information to the request
153
+ $request->getParams()->set('aws.signature', $signingContext);
154
+ }
155
+
156
+ public function createPresignedUrl(
157
+ RequestInterface $request,
158
+ CredentialsInterface $credentials,
159
+ $expires
160
+ ) {
161
+ $request = $this->createPresignedRequest($request, $credentials);
162
+ $query = $request->getQuery();
163
+ $httpDate = gmdate(DateFormat::ISO8601, $this->getTimestamp());
164
+ $shortDate = substr($httpDate, 0, 8);
165
+ $scope = $this->createScope(
166
+ $shortDate,
167
+ $this->regionName,
168
+ $this->serviceName
169
+ );
170
+ $this->addQueryValues($scope, $request, $credentials, $expires);
171
+ $payload = $this->getPresignedPayload($request);
172
+ $context = $this->createSigningContext($request, $payload);
173
+ $stringToSign = $this->createStringToSign(
174
+ $httpDate,
175
+ $scope,
176
+ $context['canonical_request']
177
+ );
178
+ $key = $this->getSigningKey(
179
+ $shortDate,
180
+ $this->regionName,
181
+ $this->serviceName,
182
+ $credentials->getSecretKey()
183
+ );
184
+ $query['X-Amz-Signature'] = hash_hmac('sha256', $stringToSign, $key);
185
+
186
+ return $request->getUrl();
187
+ }
188
+
189
+ /**
190
+ * Converts a POST request to a GET request by moving POST fields into the
191
+ * query string.
192
+ *
193
+ * Useful for pre-signing query protocol requests.
194
+ *
195
+ * @param EntityEnclosingRequestInterface $request Request to clone
196
+ *
197
+ * @return RequestInterface
198
+ * @throws \InvalidArgumentException if the method is not POST
199
+ */
200
+ public static function convertPostToGet(EntityEnclosingRequestInterface $request)
201
+ {
202
+ if ($request->getMethod() !== 'POST') {
203
+ throw new \InvalidArgumentException('Expected a POST request but '
204
+ . 'received a ' . $request->getMethod() . ' request.');
205
+ }
206
+
207
+ $cloned = RequestFactory::getInstance()
208
+ ->cloneRequestWithMethod($request, 'GET');
209
+
210
+ // Move POST fields to the query if they are present
211
+ foreach ($request->getPostFields() as $name => $value) {
212
+ $cloned->getQuery()->set($name, $value);
213
+ }
214
+
215
+ return $cloned;
216
+ }
217
+
218
+ /**
219
+ * Get the payload part of a signature from a request.
220
+ *
221
+ * @param RequestInterface $request
222
+ *
223
+ * @return string
224
+ */
225
+ protected function getPayload(RequestInterface $request)
226
+ {
227
+ // Calculate the request signature payload
228
+ if ($request->hasHeader('x-amz-content-sha256')) {
229
+ // Handle streaming operations (e.g. Glacier.UploadArchive)
230
+ return (string) $request->getHeader('x-amz-content-sha256');
231
+ }
232
+
233
+ if ($request instanceof EntityEnclosingRequestInterface) {
234
+ if ($request->getMethod() == 'POST' && count($request->getPostFields())) {
235
+ return hash('sha256', (string) $request->getPostFields());
236
+ } elseif ($body = $request->getBody()) {
237
+ return Stream::getHash($request->getBody(), 'sha256');
238
+ }
239
+ }
240
+
241
+ return self::DEFAULT_PAYLOAD;
242
+ }
243
+
244
+ /**
245
+ * Get the payload of a request for use with pre-signed URLs.
246
+ *
247
+ * @param RequestInterface $request
248
+ *
249
+ * @return string
250
+ */
251
+ protected function getPresignedPayload(RequestInterface $request)
252
+ {
253
+ return $this->getPayload($request);
254
+ }
255
+
256
+ protected function createCanonicalizedPath(RequestInterface $request)
257
+ {
258
+ $doubleEncoded = rawurlencode(ltrim($request->getPath(), '/'));
259
+
260
+ return '/' . str_replace('%2F', '/', $doubleEncoded);
261
+ }
262
+
263
+ private function createStringToSign($longDate, $credentialScope, $creq)
264
+ {
265
+ return "AWS4-HMAC-SHA256\n{$longDate}\n{$credentialScope}\n"
266
+ . hash('sha256', $creq);
267
+ }
268
+
269
+ private function createPresignedRequest(
270
+ RequestInterface $request,
271
+ CredentialsInterface $credentials
272
+ ) {
273
+ $sr = RequestFactory::getInstance()->cloneRequestWithMethod($request, 'GET');
274
+
275
+ // Move POST fields to the query if they are present
276
+ if ($request instanceof EntityEnclosingRequestInterface) {
277
+ foreach ($request->getPostFields() as $name => $value) {
278
+ $sr->getQuery()->set($name, $value);
279
+ }
280
+ }
281
+
282
+ // Make sure to handle temporary credentials
283
+ if ($token = $credentials->getSecurityToken()) {
284
+ $sr->setHeader('X-Amz-Security-Token', $token);
285
+ $sr->getQuery()->set('X-Amz-Security-Token', $token);
286
+ }
287
+
288
+ $this->moveHeadersToQuery($sr);
289
+
290
+ return $sr;
291
+ }
292
+
293
+ /**
294
+ * Create the canonical representation of a request
295
+ *
296
+ * @param RequestInterface $request Request to canonicalize
297
+ * @param string $payload Request payload (typically the value
298
+ * of the x-amz-content-sha256 header.
299
+ *
300
+ * @return array Returns an array of context information including:
301
+ * - canonical_request
302
+ * - signed_headers
303
+ */
304
+ private function createSigningContext(RequestInterface $request, $payload)
305
+ {
306
+ $signable = array(
307
+ 'host' => true,
308
+ 'date' => true,
309
+ 'content-md5' => true
310
+ );
311
+
312
+ // Normalize the path as required by SigV4 and ensure it's absolute
313
+ $canon = $request->getMethod() . "\n"
314
+ . $this->createCanonicalizedPath($request) . "\n"
315
+ . $this->getCanonicalizedQueryString($request) . "\n";
316
+
317
+ $canonHeaders = array();
318
+
319
+ foreach ($request->getHeaders()->getAll() as $key => $values) {
320
+ $key = strtolower($key);
321
+ if (isset($signable[$key]) || substr($key, 0, 6) === 'x-amz-') {
322
+ $values = $values->toArray();
323
+ if (count($values) == 1) {
324
+ $values = $values[0];
325
+ } else {
326
+ sort($values);
327
+ $values = implode(',', $values);
328
+ }
329
+ $canonHeaders[$key] = $key . ':' . preg_replace('/\s+/', ' ', $values);
330
+ }
331
+ }
332
+
333
+ ksort($canonHeaders);
334
+ $signedHeadersString = implode(';', array_keys($canonHeaders));
335
+ $canon .= implode("\n", $canonHeaders) . "\n\n"
336
+ . $signedHeadersString . "\n"
337
+ . $payload;
338
+
339
+ return array(
340
+ 'canonical_request' => $canon,
341
+ 'signed_headers' => $signedHeadersString
342
+ );
343
+ }
344
+
345
+ /**
346
+ * Get a hash for a specific key and value. If the hash was previously
347
+ * cached, return it
348
+ *
349
+ * @param string $shortDate Short date
350
+ * @param string $region Region name
351
+ * @param string $service Service name
352
+ * @param string $secretKey Secret Access Key
353
+ *
354
+ * @return string
355
+ */
356
+ private function getSigningKey($shortDate, $region, $service, $secretKey)
357
+ {
358
+ $cacheKey = $shortDate . '_' . $region . '_' . $service . '_' . $secretKey;
359
+
360
+ // Retrieve the hash form the cache or create it and add it to the cache
361
+ if (!isset($this->hashCache[$cacheKey])) {
362
+ // When the cache size reaches the max, then just clear the cache
363
+ if (++$this->cacheSize > $this->maxCacheSize) {
364
+ $this->hashCache = array();
365
+ $this->cacheSize = 0;
366
+ }
367
+ $dateKey = hash_hmac('sha256', $shortDate, 'AWS4' . $secretKey, true);
368
+ $regionKey = hash_hmac('sha256', $region, $dateKey, true);
369
+ $serviceKey = hash_hmac('sha256', $service, $regionKey, true);
370
+ $this->hashCache[$cacheKey] = hash_hmac('sha256', 'aws4_request', $serviceKey, true);
371
+ }
372
+
373
+ return $this->hashCache[$cacheKey];
374
+ }
375
+
376
+ /**
377
+ * Get the canonicalized query string for a request
378
+ *
379
+ * @param RequestInterface $request
380
+ * @return string
381
+ */
382
+ private function getCanonicalizedQueryString(RequestInterface $request)
383
+ {
384
+ $queryParams = $request->getQuery()->getAll();
385
+ unset($queryParams['X-Amz-Signature']);
386
+ if (empty($queryParams)) {
387
+ return '';
388
+ }
389
+
390
+ $qs = '';
391
+ ksort($queryParams);
392
+ foreach ($queryParams as $key => $values) {
393
+ if (is_array($values)) {
394
+ sort($values);
395
+ } elseif ($values === 0) {
396
+ $values = array('0');
397
+ } elseif (!$values) {
398
+ $values = array('');
399
+ }
400
+
401
+ foreach ((array) $values as $value) {
402
+ if ($value === QueryString::BLANK) {
403
+ $value = '';
404
+ }
405
+ $qs .= rawurlencode($key) . '=' . rawurlencode($value) . '&';
406
+ }
407
+ }
408
+
409
+ return substr($qs, 0, -1);
410
+ }
411
+
412
+ private function convertExpires($expires)
413
+ {
414
+ if ($expires instanceof \DateTime) {
415
+ $expires = $expires->getTimestamp();
416
+ } elseif (!is_numeric($expires)) {
417
+ $expires = strtotime($expires);
418
+ }
419
+
420
+ $duration = $expires - time();
421
+
422
+ // Ensure that the duration of the signature is not longer than a week
423
+ if ($duration > 604800) {
424
+ throw new \InvalidArgumentException('The expiration date of a '
425
+ . 'signature version 4 presigned URL must be less than one '
426
+ . 'week');
427
+ }
428
+
429
+ return $duration;
430
+ }
431
+
432
+ private function createScope($shortDate, $region, $service)
433
+ {
434
+ return $shortDate
435
+ . '/' . $region
436
+ . '/' . $service
437
+ . '/aws4_request';
438
+ }
439
+
440
+ private function addQueryValues(
441
+ $scope,
442
+ RequestInterface $request,
443
+ CredentialsInterface $credentials,
444
+ $expires
445
+ ) {
446
+ $credential = $credentials->getAccessKeyId() . '/' . $scope;
447
+
448
+ // Set query params required for pre-signed URLs
449
+ $request->getQuery()
450
+ ->set('X-Amz-Algorithm', 'AWS4-HMAC-SHA256')
451
+ ->set('X-Amz-Credential', $credential)
452
+ ->set('X-Amz-Date', gmdate('Ymd\THis\Z', $this->getTimestamp()))
453
+ ->set('X-Amz-SignedHeaders', 'Host')
454
+ ->set('X-Amz-Expires', $this->convertExpires($expires));
455
+ }
456
+
457
+ private function moveHeadersToQuery(RequestInterface $request)
458
+ {
459
+ $query = $request->getQuery();
460
+
461
+ foreach ($request->getHeaders() as $name => $header) {
462
+ if (substr($name, 0, 5) == 'x-amz') {
463
+ $query[$header->getName()] = (string) $header;
464
+ }
465
+ if ($name !== 'host') {
466
+ $request->removeHeader($name);
467
+ }
468
+ }
469
+ }
470
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/AbstractResourceWaiter.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+ use Aws\Common\Exception\RuntimeException;
21
+
22
+ /**
23
+ * Abstract waiter implementation used to wait on resources
24
+ */
25
+ abstract class AbstractResourceWaiter extends AbstractWaiter implements ResourceWaiterInterface
26
+ {
27
+ /**
28
+ * @var AwsClientInterface
29
+ */
30
+ protected $client;
31
+
32
+ /**
33
+ * {@inheritdoc}
34
+ */
35
+ public function setClient(AwsClientInterface $client)
36
+ {
37
+ $this->client = $client;
38
+
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * {@inheritdoc}
44
+ */
45
+ public function wait()
46
+ {
47
+ if (!$this->client) {
48
+ throw new RuntimeException('No client has been specified on the waiter');
49
+ }
50
+
51
+ parent::wait();
52
+ }
53
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/AbstractWaiter.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Guzzle\Common\AbstractHasDispatcher;
21
+
22
+ /**
23
+ * Abstract wait implementation
24
+ */
25
+ abstract class AbstractWaiter extends AbstractHasDispatcher implements WaiterInterface
26
+ {
27
+ protected $attempts = 0;
28
+ protected $config = array();
29
+
30
+ /**
31
+ * {@inheritdoc}
32
+ */
33
+ public static function getAllEvents()
34
+ {
35
+ return array(
36
+ // About to check if the waiter needs to wait
37
+ 'waiter.before_attempt',
38
+ // About to sleep
39
+ 'waiter.before_wait',
40
+ );
41
+ }
42
+
43
+ /**
44
+ * The max attempts allowed by the waiter
45
+ *
46
+ * @return int
47
+ */
48
+ public function getMaxAttempts()
49
+ {
50
+ return isset($this->config[self::MAX_ATTEMPTS]) ? $this->config[self::MAX_ATTEMPTS] : 10;
51
+ }
52
+
53
+ /**
54
+ * Get the amount of time in seconds to delay between attempts
55
+ *
56
+ * @return int
57
+ */
58
+ public function getInterval()
59
+ {
60
+ return isset($this->config[self::INTERVAL]) ? $this->config[self::INTERVAL] : 0;
61
+ }
62
+
63
+ /**
64
+ * {@inheritdoc}
65
+ */
66
+ public function setMaxAttempts($maxAttempts)
67
+ {
68
+ $this->config[self::MAX_ATTEMPTS] = $maxAttempts;
69
+
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * {@inheritdoc}
75
+ */
76
+ public function setInterval($interval)
77
+ {
78
+ $this->config[self::INTERVAL] = $interval;
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Set config options associated with the waiter
85
+ *
86
+ * @param array $config Options to set
87
+ *
88
+ * @return self
89
+ */
90
+ public function setConfig(array $config)
91
+ {
92
+ if (isset($config['waiter.before_attempt'])) {
93
+ $this->getEventDispatcher()->addListener('waiter.before_attempt', $config['waiter.before_attempt']);
94
+ unset($config['waiter.before_attempt']);
95
+ }
96
+
97
+ if (isset($config['waiter.before_wait'])) {
98
+ $this->getEventDispatcher()->addListener('waiter.before_wait', $config['waiter.before_wait']);
99
+ unset($config['waiter.before_wait']);
100
+ }
101
+
102
+ $this->config = $config;
103
+
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * {@inheritdoc}
109
+ */
110
+ public function wait()
111
+ {
112
+ $this->attempts = 0;
113
+
114
+ do {
115
+ $this->dispatch('waiter.before_attempt', array(
116
+ 'waiter' => $this,
117
+ 'config' => $this->config,
118
+ ));
119
+
120
+ if ($this->doWait()) {
121
+ break;
122
+ }
123
+
124
+ if (++$this->attempts >= $this->getMaxAttempts()) {
125
+ throw new RuntimeException('Wait method never resolved to true after ' . $this->attempts . ' attempts');
126
+ }
127
+
128
+ $this->dispatch('waiter.before_wait', array(
129
+ 'waiter' => $this,
130
+ 'config' => $this->config,
131
+ ));
132
+
133
+ if ($this->getInterval()) {
134
+ usleep($this->getInterval() * 1000000);
135
+ }
136
+
137
+ } while (1);
138
+ }
139
+
140
+ /**
141
+ * Method to implement in subclasses
142
+ *
143
+ * @return bool Return true when successful, false on failure
144
+ */
145
+ abstract protected function doWait();
146
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/CallableWaiter.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+ use Aws\Common\Exception\RuntimeException;
21
+
22
+ /**
23
+ * Callable wait implementation
24
+ */
25
+ class CallableWaiter extends AbstractWaiter
26
+ {
27
+ /**
28
+ * @var callable Callable function
29
+ */
30
+ protected $callable;
31
+
32
+ /**
33
+ * @var array Additional context for the callable function
34
+ */
35
+ protected $context = array();
36
+
37
+ /**
38
+ * Set the callable function to call in each wait attempt
39
+ *
40
+ * @param callable $callable Callable function
41
+ *
42
+ * @return self
43
+ * @throws InvalidArgumentException when the method is not callable
44
+ */
45
+ public function setCallable($callable)
46
+ {
47
+ if (!is_callable($callable)) {
48
+ throw new InvalidArgumentException('Value is not callable');
49
+ }
50
+
51
+ $this->callable = $callable;
52
+
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Set additional context for the callable function. This data will be passed into the callable function as the
58
+ * second argument
59
+ *
60
+ * @param array $context Additional context
61
+ *
62
+ * @return self
63
+ */
64
+ public function setContext(array $context)
65
+ {
66
+ $this->context = $context;
67
+
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * {@inheritdoc}
73
+ */
74
+ public function doWait()
75
+ {
76
+ if (!$this->callable) {
77
+ throw new RuntimeException('No callable was specified for the wait method');
78
+ }
79
+
80
+ return call_user_func($this->callable, $this->attempts, $this->context);
81
+ }
82
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/CompositeWaiterFactory.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+
21
+ /**
22
+ * Factory that utilizes multiple factories for creating waiters
23
+ */
24
+ class CompositeWaiterFactory implements WaiterFactoryInterface
25
+ {
26
+ /**
27
+ * @var array Array of factories
28
+ */
29
+ protected $factories;
30
+
31
+ /**
32
+ * @param array $factories Array of factories used to instantiate waiters
33
+ */
34
+ public function __construct(array $factories)
35
+ {
36
+ $this->factories = $factories;
37
+ }
38
+
39
+ /**
40
+ * {@inheritdoc}
41
+ */
42
+ public function build($waiter)
43
+ {
44
+ if (!($factory = $this->getFactory($waiter))) {
45
+ throw new InvalidArgumentException("Waiter was not found matching {$waiter}.");
46
+ }
47
+
48
+ return $factory->build($waiter);
49
+ }
50
+
51
+ /**
52
+ * {@inheritdoc}
53
+ */
54
+ public function canBuild($waiter)
55
+ {
56
+ return (bool) $this->getFactory($waiter);
57
+ }
58
+
59
+ /**
60
+ * Add a factory to the composite factory
61
+ *
62
+ * @param WaiterFactoryInterface $factory Factory to add
63
+ *
64
+ * @return self
65
+ */
66
+ public function addFactory(WaiterFactoryInterface $factory)
67
+ {
68
+ $this->factories[] = $factory;
69
+
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Get the factory that matches the waiter name
75
+ *
76
+ * @param string $waiter Name of the waiter
77
+ *
78
+ * @return WaiterFactoryInterface|bool
79
+ */
80
+ protected function getFactory($waiter)
81
+ {
82
+ foreach ($this->factories as $factory) {
83
+ if ($factory->canBuild($waiter)) {
84
+ return $factory;
85
+ }
86
+ }
87
+
88
+ return false;
89
+ }
90
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/ConfigResourceWaiter.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+ use Aws\Common\Exception\RuntimeException;
21
+ use Aws\Common\Exception\ServiceResponseException;
22
+ use Guzzle\Service\Resource\Model;
23
+ use Guzzle\Service\Exception\ValidationException;
24
+
25
+ /**
26
+ * Resource waiter driven by configuration options
27
+ */
28
+ class ConfigResourceWaiter extends AbstractResourceWaiter
29
+ {
30
+ /**
31
+ * @var WaiterConfig Waiter configuration
32
+ */
33
+ protected $waiterConfig;
34
+
35
+ /**
36
+ * @param WaiterConfig $waiterConfig Waiter configuration
37
+ */
38
+ public function __construct(WaiterConfig $waiterConfig)
39
+ {
40
+ $this->waiterConfig = $waiterConfig;
41
+ $this->setInterval($waiterConfig->get(WaiterConfig::INTERVAL));
42
+ $this->setMaxAttempts($waiterConfig->get(WaiterConfig::MAX_ATTEMPTS));
43
+ }
44
+
45
+ /**
46
+ * {@inheritdoc}
47
+ */
48
+ public function setConfig(array $config)
49
+ {
50
+ foreach ($config as $key => $value) {
51
+ if (substr($key, 0, 7) == 'waiter.') {
52
+ $this->waiterConfig->set(substr($key, 7), $value);
53
+ }
54
+ }
55
+
56
+ if (!isset($config[self::INTERVAL])) {
57
+ $config[self::INTERVAL] = $this->waiterConfig->get(WaiterConfig::INTERVAL);
58
+ }
59
+
60
+ if (!isset($config[self::MAX_ATTEMPTS])) {
61
+ $config[self::MAX_ATTEMPTS] = $this->waiterConfig->get(WaiterConfig::MAX_ATTEMPTS);
62
+ }
63
+
64
+ return parent::setConfig($config);
65
+ }
66
+
67
+ /**
68
+ * Get the waiter's configuration data
69
+ *
70
+ * @return WaiterConfig
71
+ */
72
+ public function getWaiterConfig()
73
+ {
74
+ return $this->waiterConfig;
75
+ }
76
+
77
+ /**
78
+ * {@inheritdoc}
79
+ */
80
+ protected function doWait()
81
+ {
82
+ $params = $this->config;
83
+ // remove waiter settings from the operation's input
84
+ foreach (array_keys($params) as $key) {
85
+ if (substr($key, 0, 7) == 'waiter.') {
86
+ unset($params[$key]);
87
+ }
88
+ }
89
+
90
+ $operation = $this->client->getCommand($this->waiterConfig->get(WaiterConfig::OPERATION), $params);
91
+
92
+ try {
93
+ return $this->checkResult($this->client->execute($operation));
94
+ } catch (ValidationException $e) {
95
+ throw new InvalidArgumentException(
96
+ $this->waiterConfig->get(WaiterConfig::WAITER_NAME) . ' waiter validation failed: ' . $e->getMessage(),
97
+ $e->getCode(),
98
+ $e
99
+ );
100
+ } catch (ServiceResponseException $e) {
101
+
102
+ // Check if this exception satisfies a success or failure acceptor
103
+ $transition = $this->checkErrorAcceptor($e);
104
+ if (null !== $transition) {
105
+ return $transition;
106
+ }
107
+
108
+ // Check if this exception should be ignored
109
+ foreach ((array) $this->waiterConfig->get(WaiterConfig::IGNORE_ERRORS) as $ignore) {
110
+ if ($e->getExceptionCode() == $ignore) {
111
+ // This exception is ignored, so it counts as a failed attempt rather than a fast-fail
112
+ return false;
113
+ }
114
+ }
115
+
116
+ // Allow non-ignore exceptions to bubble through
117
+ throw $e;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Check if an exception satisfies a success or failure acceptor
123
+ *
124
+ * @param ServiceResponseException $e
125
+ *
126
+ * @return bool|null Returns true for success, false for failure, and null for no transition
127
+ */
128
+ protected function checkErrorAcceptor(ServiceResponseException $e)
129
+ {
130
+ if ($this->waiterConfig->get(WaiterConfig::SUCCESS_TYPE) == 'error') {
131
+ if ($e->getExceptionCode() == $this->waiterConfig->get(WaiterConfig::SUCCESS_VALUE)) {
132
+ // Mark as a success
133
+ return true;
134
+ }
135
+ }
136
+
137
+ // Mark as an attempt
138
+ return null;
139
+ }
140
+
141
+ /**
142
+ * Check to see if the response model satisfies a success or failure state
143
+ *
144
+ * @param Model $result Result model
145
+ *
146
+ * @return bool
147
+ * @throws RuntimeException
148
+ */
149
+ protected function checkResult(Model $result)
150
+ {
151
+ // Check if the result evaluates to true based on the path and output model
152
+ if ($this->waiterConfig->get(WaiterConfig::SUCCESS_TYPE) == 'output' &&
153
+ $this->checkPath(
154
+ $result,
155
+ $this->waiterConfig->get(WaiterConfig::SUCCESS_PATH),
156
+ $this->waiterConfig->get(WaiterConfig::SUCCESS_VALUE)
157
+ )
158
+ ) {
159
+ return true;
160
+ }
161
+
162
+ // It did not finish waiting yet. Determine if we need to fail-fast based on the failure acceptor.
163
+ if ($this->waiterConfig->get(WaiterConfig::FAILURE_TYPE) == 'output') {
164
+ $failureValue = $this->waiterConfig->get(WaiterConfig::FAILURE_VALUE);
165
+ if ($failureValue) {
166
+ $key = $this->waiterConfig->get(WaiterConfig::FAILURE_PATH);
167
+ if ($this->checkPath($result, $key, $failureValue, false)) {
168
+ // Determine which of the results triggered the failure
169
+ $triggered = array_intersect(
170
+ (array) $this->waiterConfig->get(WaiterConfig::FAILURE_VALUE),
171
+ array_unique((array) $result->getPath($key))
172
+ );
173
+ // fast fail because the failure case was satisfied
174
+ throw new RuntimeException(
175
+ 'A resource entered into an invalid state of "'
176
+ . implode(', ', $triggered) . '" while waiting with the "'
177
+ . $this->waiterConfig->get(WaiterConfig::WAITER_NAME) . '" waiter.'
178
+ );
179
+ }
180
+ }
181
+ }
182
+
183
+ return false;
184
+ }
185
+
186
+ /**
187
+ * Check to see if the path of the output key is satisfied by the value
188
+ *
189
+ * @param Model $model Result model
190
+ * @param string $key Key to check
191
+ * @param string $checkValue Compare the key to the value
192
+ * @param bool $all Set to true to ensure all value match or false to only match one
193
+ *
194
+ * @return bool
195
+ */
196
+ protected function checkPath(Model $model, $key = null, $checkValue = array(), $all = true)
197
+ {
198
+ // If no key is set, then just assume true because the request succeeded
199
+ if (!$key) {
200
+ return true;
201
+ }
202
+
203
+ if (!($result = $model->getPath($key))) {
204
+ return false;
205
+ }
206
+
207
+ $total = $matches = 0;
208
+ foreach ((array) $result as $value) {
209
+ $total++;
210
+ foreach ((array) $checkValue as $check) {
211
+ if ($value == $check) {
212
+ $matches++;
213
+ break;
214
+ }
215
+ }
216
+ }
217
+
218
+ // When matching all values, ensure that the match count matches the total count
219
+ if ($all && $total != $matches) {
220
+ return false;
221
+ }
222
+
223
+ return $matches > 0;
224
+ }
225
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/ResourceWaiterInterface.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+
21
+ /**
22
+ * Interface used in conjunction with clients to wait on a resource
23
+ */
24
+ interface ResourceWaiterInterface extends WaiterInterface
25
+ {
26
+ /**
27
+ * Set the client associated with the waiter
28
+ *
29
+ * @param AwsClientInterface $client Client to use with the waiter
30
+ *
31
+ * @return self
32
+ */
33
+ public function setClient(AwsClientInterface $client);
34
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterClassFactory.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+ use Guzzle\Inflection\Inflector;
21
+ use Guzzle\Inflection\InflectorInterface;
22
+
23
+ /**
24
+ * Factory for creating {@see WaiterInterface} objects using a convention of
25
+ * storing waiter classes in the Waiter folder of a client class namespace using
26
+ * a snake_case to CamelCase conversion (e.g. camel_case => CamelCase).
27
+ */
28
+ class WaiterClassFactory implements WaiterFactoryInterface
29
+ {
30
+ /**
31
+ * @var array List of namespaces used to look for classes
32
+ */
33
+ protected $namespaces;
34
+
35
+ /**
36
+ * @var InflectorInterface Inflector used to inflect class names
37
+ */
38
+ protected $inflector;
39
+
40
+ /**
41
+ * @param array|string $namespaces Namespaces of waiter objects
42
+ * @param InflectorInterface $inflector Inflector used to resolve class names
43
+ */
44
+ public function __construct($namespaces = array(), InflectorInterface $inflector = null)
45
+ {
46
+ $this->namespaces = (array) $namespaces;
47
+ $this->inflector = $inflector ?: Inflector::getDefault();
48
+ }
49
+
50
+ /**
51
+ * Registers a namespace to check for Waiters
52
+ *
53
+ * @param string $namespace Namespace which contains Waiter classes
54
+ *
55
+ * @return self
56
+ */
57
+ public function registerNamespace($namespace)
58
+ {
59
+ array_unshift($this->namespaces, $namespace);
60
+
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * {@inheritdoc}
66
+ */
67
+ public function build($waiter)
68
+ {
69
+ if (!($className = $this->getClassName($waiter))) {
70
+ throw new InvalidArgumentException("Waiter was not found matching {$waiter}.");
71
+ }
72
+
73
+ return new $className();
74
+ }
75
+
76
+ /**
77
+ * {@inheritdoc}
78
+ */
79
+ public function canBuild($waiter)
80
+ {
81
+ return $this->getClassName($waiter) !== null;
82
+ }
83
+
84
+ /**
85
+ * Get the name of a waiter class
86
+ *
87
+ * @param string $waiter Waiter name
88
+ *
89
+ * @return string|null
90
+ */
91
+ protected function getClassName($waiter)
92
+ {
93
+ $waiterName = $this->inflector->camel($waiter);
94
+
95
+ // Determine the name of the class to load
96
+ $className = null;
97
+ foreach ($this->namespaces as $namespace) {
98
+ $potentialClassName = $namespace . '\\' . $waiterName;
99
+ if (class_exists($potentialClassName)) {
100
+ return $potentialClassName;
101
+ }
102
+ }
103
+
104
+ return null;
105
+ }
106
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterConfig.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Guzzle\Common\Collection;
20
+
21
+ /**
22
+ * Configuration info of a waiter object
23
+ */
24
+ class WaiterConfig extends Collection
25
+ {
26
+ const WAITER_NAME = 'name';
27
+ const MAX_ATTEMPTS = 'max_attempts';
28
+ const INTERVAL = 'interval';
29
+ const OPERATION = 'operation';
30
+ const IGNORE_ERRORS = 'ignore_errors';
31
+ const DESCRIPTION = 'description';
32
+ const SUCCESS_TYPE = 'success.type';
33
+ const SUCCESS_PATH = 'success.path';
34
+ const SUCCESS_VALUE = 'success.value';
35
+ const FAILURE_TYPE = 'failure.type';
36
+ const FAILURE_PATH = 'failure.path';
37
+ const FAILURE_VALUE = 'failure.value';
38
+
39
+ /**
40
+ * @param array $data Array of configuration directives
41
+ */
42
+ public function __construct(array $data = array())
43
+ {
44
+ $this->data = $data;
45
+ $this->extractConfig();
46
+ }
47
+
48
+ /**
49
+ * Create the command configuration variables
50
+ */
51
+ protected function extractConfig()
52
+ {
53
+ // Populate success.* and failure.* if specified in acceptor.*
54
+ foreach ($this->data as $key => $value) {
55
+ if (substr($key, 0, 9) == 'acceptor.') {
56
+ $name = substr($key, 9);
57
+ if (!isset($this->data["success.{$name}"])) {
58
+ $this->data["success.{$name}"] = $value;
59
+ }
60
+ if (!isset($this->data["failure.{$name}"])) {
61
+ $this->data["failure.{$name}"] = $value;
62
+ }
63
+ unset($this->data[$key]);
64
+ }
65
+ }
66
+ }
67
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterConfigFactory.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+ use Guzzle\Inflection\Inflector;
21
+ use Guzzle\Inflection\InflectorInterface;
22
+
23
+ /**
24
+ * Factory for creating {@see WaiterInterface} objects using a configuration DSL.
25
+ */
26
+ class WaiterConfigFactory implements WaiterFactoryInterface
27
+ {
28
+ /**
29
+ * @var array Configuration directives
30
+ */
31
+ protected $config;
32
+
33
+ /**
34
+ * @var InflectorInterface Inflector used to inflect class names
35
+ */
36
+ protected $inflector;
37
+
38
+ /**
39
+ * @param array $config Array of configuration directives
40
+ * @param InflectorInterface $inflector Inflector used to resolve class names
41
+ */
42
+ public function __construct(
43
+ array $config,
44
+ InflectorInterface $inflector = null
45
+ ) {
46
+ $this->config = $config;
47
+ $this->inflector = $inflector ?: Inflector::getDefault();
48
+ }
49
+
50
+ /**
51
+ * {@inheritdoc}
52
+ */
53
+ public function build($waiter)
54
+ {
55
+ return new ConfigResourceWaiter($this->getWaiterConfig($waiter));
56
+ }
57
+
58
+ /**
59
+ * {@inheritdoc}
60
+ */
61
+ public function canBuild($waiter)
62
+ {
63
+ return isset($this->config[$waiter]) || isset($this->config[$this->inflector->camel($waiter)]);
64
+ }
65
+
66
+ /**
67
+ * Get waiter configuration data, taking __default__ and extensions into account
68
+ *
69
+ * @param string $name Waiter name
70
+ *
71
+ * @return WaiterConfig
72
+ * @throws InvalidArgumentException
73
+ */
74
+ protected function getWaiterConfig($name)
75
+ {
76
+ if (!$this->canBuild($name)) {
77
+ throw new InvalidArgumentException('No waiter found matching "' . $name . '"');
78
+ }
79
+
80
+ // inflect the name if needed
81
+ $name = isset($this->config[$name]) ? $name : $this->inflector->camel($name);
82
+ $waiter = new WaiterConfig($this->config[$name]);
83
+ $waiter['name'] = $name;
84
+
85
+ // Always use __default__ as the basis if it's set
86
+ if (isset($this->config['__default__'])) {
87
+ $parentWaiter = new WaiterConfig($this->config['__default__']);
88
+ $waiter = $parentWaiter->overwriteWith($waiter);
89
+ }
90
+
91
+ // Allow for configuration extensions
92
+ if (isset($this->config[$name]['extends'])) {
93
+ $waiter = $this->getWaiterConfig($this->config[$name]['extends'])->overwriteWith($waiter);
94
+ }
95
+
96
+ return $waiter;
97
+ }
98
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterFactoryInterface.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ /**
20
+ * Waiter factory used to create waiter objects by short names
21
+ */
22
+ interface WaiterFactoryInterface
23
+ {
24
+ /**
25
+ * Create a waiter by name
26
+ *
27
+ * @param string $waiter Name of the waiter to create
28
+ *
29
+ * @return WaiterInterface
30
+ */
31
+ public function build($waiter);
32
+
33
+ /**
34
+ * Check if the factory can create a waiter by a specific name
35
+ *
36
+ * @param string $waiter Name of the waiter to check
37
+ *
38
+ * @return bool
39
+ */
40
+ public function canBuild($waiter);
41
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/Common/Waiter/WaiterInterface.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\Common\Waiter;
18
+
19
+ /**
20
+ * WaiterInterface used to wait on something to be in a particular state
21
+ */
22
+ interface WaiterInterface
23
+ {
24
+ const INTERVAL = 'waiter.interval';
25
+ const MAX_ATTEMPTS = 'waiter.max_attempts';
26
+
27
+ /**
28
+ * Set the maximum number of attempts to make when waiting
29
+ *
30
+ * @param int $maxAttempts Max number of attempts
31
+ *
32
+ * @return self
33
+ */
34
+ public function setMaxAttempts($maxAttempts);
35
+
36
+ /**
37
+ * Set the amount of time to interval between attempts
38
+ *
39
+ * @param int $interval Interval in seconds
40
+ *
41
+ * @return self
42
+ */
43
+ public function setInterval($interval);
44
+
45
+ /**
46
+ * Set configuration options associated with the waiter
47
+ *
48
+ * @param array $config Configuration options to set
49
+ *
50
+ * @return self
51
+ */
52
+ public function setConfig(array $config);
53
+
54
+ /**
55
+ * Begin the waiting loop
56
+ *
57
+ * @throw RuntimeException if the method never resolves to true
58
+ */
59
+ public function wait();
60
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/AcpListener.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+ use Aws\S3\Model\Acp;
21
+ use Guzzle\Common\Event;
22
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
23
+
24
+ /**
25
+ * Listener used to add an Access Control Policy to a request
26
+ */
27
+ class AcpListener implements EventSubscriberInterface
28
+ {
29
+ /**
30
+ * {@inheritdoc}
31
+ */
32
+ public static function getSubscribedEvents()
33
+ {
34
+ return array('command.before_prepare' => array('onCommandBeforePrepare', -255));
35
+ }
36
+
37
+ /**
38
+ * An event handler for constructing ACP definitions.
39
+ *
40
+ * @param Event $event The event to respond to.
41
+ *
42
+ * @throws InvalidArgumentException
43
+ */
44
+ public function onCommandBeforePrepare(Event $event)
45
+ {
46
+ /** @var $command \Guzzle\Service\Command\AbstractCommand */
47
+ $command = $event['command'];
48
+ $operation = $command->getOperation();
49
+ if ($operation->hasParam('ACP') && $command->hasKey('ACP')) {
50
+ if ($acp = $command->get('ACP')) {
51
+ // Ensure that the correct object was passed
52
+ if (!($acp instanceof Acp)) {
53
+ throw new InvalidArgumentException('ACP must be an instance of Aws\S3\Model\Acp');
54
+ }
55
+
56
+ // Check if the user specified both an ACP and Grants
57
+ if ($command->hasKey('Grants')) {
58
+ throw new InvalidArgumentException(
59
+ 'Use either the ACP parameter or the Grants parameter. Do not use both.'
60
+ );
61
+ }
62
+
63
+ // Add the correct headers/body based parameters to the command
64
+ if ($operation->hasParam('Grants')) {
65
+ $command->overwriteWith($acp->toArray());
66
+ } else {
67
+ $acp->updateCommand($command);
68
+ }
69
+ }
70
+
71
+ // Remove the ACP parameter
72
+ $command->remove('ACP');
73
+ }
74
+ }
75
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/BucketStyleListener.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Guzzle\Common\Event;
20
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
21
+
22
+ /**
23
+ * Listener used to change the way in which buckets are referenced (path/virtual style) based on context
24
+ */
25
+ class BucketStyleListener implements EventSubscriberInterface
26
+ {
27
+ private static $exclusions = array('GetBucketLocation' => true);
28
+
29
+ public static function getSubscribedEvents()
30
+ {
31
+ return array('command.after_prepare' => array('onCommandAfterPrepare', -255));
32
+ }
33
+
34
+ /**
35
+ * Changes how buckets are referenced in the HTTP request
36
+ *
37
+ * @param Event $event Event emitted
38
+ */
39
+ public function onCommandAfterPrepare(Event $event)
40
+ {
41
+ $command = $event['command'];
42
+ $bucket = $command['Bucket'];
43
+ $request = $command->getRequest();
44
+ $pathStyle = false;
45
+
46
+ // Skip operations that do not need the bucket moved to the host.
47
+ if (isset(self::$exclusions[$command->getName()])) {
48
+ return;
49
+ }
50
+
51
+ if ($key = $command['Key']) {
52
+ // Modify the command Key to account for the {/Key*} explosion into an array
53
+ if (is_array($key)) {
54
+ $command['Key'] = $key = implode('/', $key);
55
+ }
56
+ }
57
+
58
+ // Set the key and bucket on the request
59
+ $request->getParams()->set('bucket', $bucket)->set('key', $key);
60
+
61
+ // Switch to virtual if PathStyle is disabled, or not a DNS compatible bucket name, or the scheme is
62
+ // http, or the scheme is https and there are no dots in the host header (avoids SSL issues)
63
+ if (!$command['PathStyle'] && $command->getClient()->isValidBucketName($bucket)
64
+ && !($command->getRequest()->getScheme() == 'https' && strpos($bucket, '.'))
65
+ ) {
66
+ // Switch to virtual hosted bucket
67
+ $request->setHost($bucket . '.' . $request->getHost());
68
+ $request->setPath(preg_replace("#^/{$bucket}#", '', $request->getPath()));
69
+ } else {
70
+ $pathStyle = true;
71
+ }
72
+
73
+ if (!$bucket) {
74
+ $request->getParams()->set('s3.resource', '/');
75
+ } elseif ($pathStyle) {
76
+ // Path style does not need a trailing slash
77
+ $request->getParams()->set(
78
+ 's3.resource',
79
+ '/' . rawurlencode($bucket) . ($key ? ('/' . S3Client::encodeKey($key)) : '')
80
+ );
81
+ } else {
82
+ // Bucket style needs a trailing slash
83
+ $request->getParams()->set(
84
+ 's3.resource',
85
+ '/' . rawurlencode($bucket) . ($key ? ('/' . S3Client::encodeKey($key)) : '/')
86
+ );
87
+ }
88
+ }
89
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Command/S3Command.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Command;
18
+
19
+ use Guzzle\Service\Command\OperationCommand;
20
+ use Guzzle\Service\Resource\Model;
21
+ use Guzzle\Common\Event;
22
+
23
+ /**
24
+ * Adds functionality to Amazon S3 commands:
25
+ * - Adds the PutObject URL to a response
26
+ * - Allows creating a Pre-signed URL from any command
27
+ */
28
+ class S3Command extends OperationCommand
29
+ {
30
+ /**
31
+ * Create a pre-signed URL for the operation
32
+ *
33
+ * @param int|string $expires The Unix timestamp to expire at or a string that can be evaluated by strtotime
34
+ *
35
+ * @return string
36
+ */
37
+ public function createPresignedUrl($expires)
38
+ {
39
+ return $this->client->createPresignedUrl($this->prepare(), $expires);
40
+ }
41
+
42
+ /**
43
+ * {@inheritdoc}
44
+ */
45
+ protected function process()
46
+ {
47
+ $request = $this->getRequest();
48
+ $response = $this->getResponse();
49
+
50
+ // Dispatch an error if a 301 redirect occurred
51
+ if ($response->getStatusCode() == 301) {
52
+ $this->getClient()->getEventDispatcher()->dispatch('request.error', new Event(array(
53
+ 'request' => $this->getRequest(),
54
+ 'response' => $response
55
+ )));
56
+ }
57
+
58
+ parent::process();
59
+
60
+ // Set the GetObject URL if using the PutObject operation
61
+ if ($this->result instanceof Model && $this->getName() == 'PutObject') {
62
+ $this->result->set('ObjectURL', $request->getUrl());
63
+ }
64
+ }
65
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/CannedAcl.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable CannedAcl values
23
+ */
24
+ class CannedAcl extends Enum
25
+ {
26
+ const PRIVATE_ACCESS = 'private';
27
+ const PUBLIC_READ = 'public-read';
28
+ const PUBLIC_READ_WRITE = 'public-read-write';
29
+ const AUTHENTICATED_READ = 'authenticated-read';
30
+ const BUCKET_OWNER_READ = 'bucket-owner-read';
31
+ const BUCKET_OWNER_FULL_CONTROL = 'bucket-owner-full-control';
32
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/EncodingType.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable EncodingType values
23
+ */
24
+ class EncodingType extends Enum
25
+ {
26
+ const URL = 'url';
27
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Event.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable Event values
23
+ */
24
+ class Event extends Enum
25
+ {
26
+ const REDUCED_REDUNDANCY_LOST_OBJECT = 's3:ReducedRedundancyLostObject';
27
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/GranteeType.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable GranteeType values
23
+ */
24
+ class GranteeType extends Enum
25
+ {
26
+ const USER = 'CanonicalUser';
27
+ const EMAIL = 'AmazonCustomerByEmail';
28
+ const GROUP = 'Group';
29
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Group.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable Amazon S3 group options for ACL grantees
23
+ */
24
+ class Group extends Enum
25
+ {
26
+ const AUTHENTICATED_USERS = 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers';
27
+ const ALL_USERS = 'http://acs.amazonaws.com/groups/global/AllUsers';
28
+ const LOG_DELIVERY = 'http://acs.amazonaws.com/groups/s3/LogDelivery';
29
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/MFADelete.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable MFADelete values
23
+ */
24
+ class MFADelete extends Enum
25
+ {
26
+ const ENABLED = 'Enabled';
27
+ const DISABLED = 'Disabled';
28
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/MetadataDirective.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable MetadataDirective values
23
+ */
24
+ class MetadataDirective extends Enum
25
+ {
26
+ const COPY = 'COPY';
27
+ const REPLACE = 'REPLACE';
28
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Payer.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable Payer values
23
+ */
24
+ class Payer extends Enum
25
+ {
26
+ const REQUESTER = 'Requester';
27
+ const BUCKET_OWNER = 'BucketOwner';
28
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Permission.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable Permission values
23
+ */
24
+ class Permission extends Enum
25
+ {
26
+ const FULL_CONTROL = 'FULL_CONTROL';
27
+ const WRITE = 'WRITE';
28
+ const WRITE_ACP = 'WRITE_ACP';
29
+ const READ = 'READ';
30
+ const READ_ACP = 'READ_ACP';
31
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Protocol.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable Protocol values
23
+ */
24
+ class Protocol extends Enum
25
+ {
26
+ const HTTP = 'http';
27
+ const HTTPS = 'https';
28
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/ServerSideEncryption.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable ServerSideEncryption values
23
+ */
24
+ class ServerSideEncryption extends Enum
25
+ {
26
+ const AES256 = 'AES256';
27
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Status.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable Status values
23
+ */
24
+ class Status extends Enum
25
+ {
26
+ const ENABLED = 'Enabled';
27
+ const SUSPENDED = 'Suspended';
28
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/Storage.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable Amazon S3 storage options
23
+ */
24
+ class Storage extends Enum
25
+ {
26
+ const STANDARD = 'STANDARD';
27
+ const REDUCED = 'REDUCED_REDUNDANCY';
28
+ const GLACIER = 'GLACIER';
29
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Enum/StorageClass.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Enum;
18
+
19
+ use Aws\Common\Enum;
20
+
21
+ /**
22
+ * Contains enumerable StorageClass values
23
+ */
24
+ class StorageClass extends Enum
25
+ {
26
+ const STANDARD = 'STANDARD';
27
+ const REDUCED_REDUNDANCY = 'REDUCED_REDUNDANCY';
28
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/AccessDeniedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Access Denied
21
+ */
22
+ class AccessDeniedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/AccountProblemException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * There is a problem with your AWS account that prevents the operation from completing successfully. Please use Contact Us.
21
+ */
22
+ class AccountProblemException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/AmbiguousGrantByEmailAddressException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The e-mail address you provided is associated with more than one account.
21
+ */
22
+ class AmbiguousGrantByEmailAddressException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BadDigestException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The Content-MD5 you specified did not match what we received.
21
+ */
22
+ class BadDigestException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BucketAlreadyExistsException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
21
+ */
22
+ class BucketAlreadyExistsException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BucketAlreadyOwnedByYouException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your previous request to create the named bucket succeeded and you already own it.
21
+ */
22
+ class BucketAlreadyOwnedByYouException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/BucketNotEmptyException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The bucket you tried to delete is not empty.
21
+ */
22
+ class BucketNotEmptyException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/CredentialsNotSupportedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * This request does not support credentials.
21
+ */
22
+ class CredentialsNotSupportedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/CrossLocationLoggingProhibitedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Cross location logging not allowed. Buckets in one geographic location cannot log information to a bucket in another location.
21
+ */
22
+ class CrossLocationLoggingProhibitedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/DeleteMultipleObjectsException.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Exception thrown when errors occur in a DeleteMultipleObjects request
21
+ */
22
+ class DeleteMultipleObjectsException extends S3Exception
23
+ {
24
+ /**
25
+ * @var array Array of errors
26
+ */
27
+ protected $errors = array();
28
+
29
+ /**
30
+ * @param array $errors Array of errors
31
+ */
32
+ public function __construct(array $errors = array())
33
+ {
34
+ parent::__construct('Unable to delete certain keys when executing a DeleteMultipleObjects request');
35
+ $this->errors = $errors;
36
+ }
37
+
38
+ /**
39
+ * Get the errored objects
40
+ *
41
+ * @return array Returns an array of associative arrays, each containing
42
+ * a 'Code', 'Message', and 'Key' key.
43
+ */
44
+ public function getErrors()
45
+ {
46
+ return $this->errors;
47
+ }
48
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/EntityTooLargeException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your proposed upload exceeds the maximum allowed object size.
21
+ */
22
+ class EntityTooLargeException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/EntityTooSmallException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your proposed upload is smaller than the minimum allowed object size.
21
+ */
22
+ class EntityTooSmallException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ExpiredTokenException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The provided token has expired.
21
+ */
22
+ class ExpiredTokenException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/IllegalVersioningConfigurationException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Indicates that the Versioning configuration specified in the request is invalid.
21
+ */
22
+ class IllegalVersioningConfigurationException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/IncompleteBodyException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * You did not provide the number of bytes specified by the Content-Length HTTP header
21
+ */
22
+ class IncompleteBodyException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/IncorrectNumberOfFilesInPostRequestException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * POST requires exactly one file upload per request.
21
+ */
22
+ class IncorrectNumberOfFilesInPostRequestException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InlineDataTooLargeException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Inline data exceeds the maximum allowed size.
21
+ */
22
+ class InlineDataTooLargeException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InternalErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * We encountered an internal error. Please try again.
21
+ */
22
+ class InternalErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidAccessKeyIdException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The AWS Access Key Id you provided does not exist in our records.
21
+ */
22
+ class InvalidAccessKeyIdException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidAddressingHeaderException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * You must specify the Anonymous role.
21
+ */
22
+ class InvalidAddressingHeaderException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidArgumentException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Invalid Argument
21
+ */
22
+ class InvalidArgumentException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidBucketNameException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified bucket is not valid.
21
+ */
22
+ class InvalidBucketNameException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidBucketStateException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The request is not valid with the current state of the bucket.
21
+ */
22
+ class InvalidBucketStateException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidDigestException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The Content-MD5 you specified was an invalid.
21
+ */
22
+ class InvalidDigestException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidLocationConstraintException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified location constraint is not valid. For more information about Regions, see How to Select a Region for Your Buckets.
21
+ */
22
+ class InvalidLocationConstraintException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPartException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * One or more of the specified parts could not be found. The part might not have been uploaded, or the specified entity tag might not have matched the part's entity tag.
21
+ */
22
+ class InvalidPartException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPartOrderException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The list of parts was not in ascending order.Parts list must specified in order by part number.
21
+ */
22
+ class InvalidPartOrderException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPayerException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * All access to this object has been disabled.
21
+ */
22
+ class InvalidPayerException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidPolicyDocumentException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The content of the form does not meet the conditions specified in the policy document.
21
+ */
22
+ class InvalidPolicyDocumentException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidRangeException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The requested range cannot be satisfied.
21
+ */
22
+ class InvalidRangeException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidRequestException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * SOAP requests must be made over an HTTPS connection.
21
+ */
22
+ class InvalidRequestException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidSOAPRequestException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The SOAP request body is invalid.
21
+ */
22
+ class InvalidSOAPRequestException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidSecurityException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The provided security credentials are not valid.
21
+ */
22
+ class InvalidSecurityException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidStorageClassException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The storage class you specified is not valid.
21
+ */
22
+ class InvalidStorageClassException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidTagErrorException.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The Tag provided was not a valid tag. This can occur if the Tag did not pass input validation. See the
21
+ * CostAllocation docs for a description of valid tags.
22
+ */
23
+ class InvalidTagErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidTargetBucketForLoggingException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The target bucket for logging does not exist, is not owned by you, or does not have the appropriate grants for the log-delivery group.
21
+ */
22
+ class InvalidTargetBucketForLoggingException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidTokenException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The provided token is malformed or otherwise invalid.
21
+ */
22
+ class InvalidTokenException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/InvalidURIException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Couldn't parse the specified URI.
21
+ */
22
+ class InvalidURIException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/KeyTooLongException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your key is too long.
21
+ */
22
+ class KeyTooLongException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MalformedACLErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The XML you provided was not well-formed or did not validate against our published schema.
21
+ */
22
+ class MalformedACLErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MalformedPOSTRequestException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The body of your POST request is not well-formed multipart/form-data.
21
+ */
22
+ class MalformedPOSTRequestException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MalformedXMLException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * This happens when the user sends a malformed xml (xml that doesn't conform to the published xsd) for the configuration. The error message is, "The XML you provided was not well-formed or did not validate against our published schema."
21
+ */
22
+ class MalformedXMLException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MaxMessageLengthExceededException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your request was too big.
21
+ */
22
+ class MaxMessageLengthExceededException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MaxPostPreDataLengthExceededErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your POST request fields preceding the upload file were too large.
21
+ */
22
+ class MaxPostPreDataLengthExceededErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MetadataTooLargeException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your metadata headers exceed the maximum allowed metadata size.
21
+ */
22
+ class MetadataTooLargeException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MethodNotAllowedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified method is not allowed against this resource.
21
+ */
22
+ class MethodNotAllowedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingAttachmentException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * A SOAP attachment was expected, but none were found.
21
+ */
22
+ class MissingAttachmentException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingContentLengthException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * You must provide the Content-Length HTTP header.
21
+ */
22
+ class MissingContentLengthException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingRequestBodyErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * This happens when the user sends an empty xml document as a request. The error message is, "Request body is empty."
21
+ */
22
+ class MissingRequestBodyErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingSecurityElementException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The SOAP 1.1 request is missing a security element.
21
+ */
22
+ class MissingSecurityElementException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/MissingSecurityHeaderException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your request was missing a required header.
21
+ */
22
+ class MissingSecurityHeaderException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoLoggingStatusForKeyException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * There is no such thing as a logging status sub-resource for a key.
21
+ */
22
+ class NoLoggingStatusForKeyException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchBucketException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified bucket does not exist.
21
+ */
22
+ class NoSuchBucketException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchBucketPolicyException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified bucket policy does not exist.
21
+ */
22
+ class NoSuchBucketPolicyException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchCORSConfigurationException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified bucket does not have a CORs configuration.
21
+ */
22
+ class NoSuchCORSConfigurationException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchKeyException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified key does not exist.
21
+ */
22
+ class NoSuchKeyException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchLifecycleConfigurationException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The lifecycle configuration does not exist.
21
+ */
22
+ class NoSuchLifecycleConfigurationException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchTagSetErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * There is no TagSet associated with the bucket.
21
+ */
22
+ class NoSuchTagSetErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchUploadException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified multipart upload does not exist.
21
+ */
22
+ class NoSuchUploadException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchVersionException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Indicates that the version ID specified in the request does not match an existing version.
21
+ */
22
+ class NoSuchVersionException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NoSuchWebsiteConfigurationException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified bucket does not have a website configuration.
21
+ */
22
+ class NoSuchWebsiteConfigurationException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NotImplementedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * A header you provided implies functionality that is not implemented.
21
+ */
22
+ class NotImplementedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NotSignedUpException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your account is not signed up for the Amazon S3 service. You must sign up before you can use Amazon S3. You can sign up at the following URL: http://aws.amazon.com/s3
21
+ */
22
+ class NotSignedUpException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/NotSuchBucketPolicyException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The specified bucket does not have a bucket policy.
21
+ */
22
+ class NotSuchBucketPolicyException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ObjectAlreadyInActiveTierErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * This operation is not allowed against this storage tier
21
+ */
22
+ class ObjectAlreadyInActiveTierErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ObjectNotInActiveTierErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The source object of the COPY operation is not in the active tier and is only stored in Amazon Glacier.
21
+ */
22
+ class ObjectNotInActiveTierErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/OperationAbortedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * A conflicting conditional operation is currently in progress against this resource. Please try again.
21
+ */
22
+ class OperationAbortedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/Parser/S3ExceptionParser.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception\Parser;
18
+
19
+ use Aws\Common\Exception\Parser\DefaultXmlExceptionParser;
20
+ use Guzzle\Http\Message\RequestInterface;
21
+ use Guzzle\Http\Message\Response;
22
+
23
+ /**
24
+ * Parses S3 exception responses
25
+ */
26
+ class S3ExceptionParser extends DefaultXmlExceptionParser
27
+ {
28
+ /**
29
+ * {@inheritdoc}
30
+ */
31
+ public function parse(RequestInterface $request, Response $response)
32
+ {
33
+ $data = parent::parse($request, $response);
34
+
35
+ if ($response->getStatusCode() === 301) {
36
+ $data['type'] = 'client';
37
+ if (isset($data['message'], $data['parsed'])) {
38
+ $data['message'] = rtrim($data['message'], '.') . ': "' . $data['parsed']->Endpoint . '".';
39
+ }
40
+ }
41
+
42
+ return $data;
43
+ }
44
+
45
+ /**
46
+ * {@inheritdoc}
47
+ */
48
+ protected function parseHeaders(RequestInterface $request, Response $response, array &$data)
49
+ {
50
+ parent::parseHeaders($request, $response, $data);
51
+
52
+ // Get the request
53
+ $status = $response->getStatusCode();
54
+ $method = $request->getMethod();
55
+
56
+ // Attempt to determine code for 403s and 404s
57
+ if ($status === 403) {
58
+ $data['code'] = 'AccessDenied';
59
+ } elseif ($method === 'HEAD' && $status === 404) {
60
+ $path = explode('/', trim($request->getPath(), '/'));
61
+ $host = explode('.', $request->getHost());
62
+ $bucket = (count($host) === 4) ? $host[0] : array_shift($path);
63
+ $object = array_shift($path);
64
+
65
+ if ($bucket && $object) {
66
+ $data['code'] = 'NoSuchKey';
67
+ } elseif ($bucket) {
68
+ $data['code'] = 'NoSuchBucket';
69
+ }
70
+ }
71
+ }
72
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/PermanentRedirectException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
21
+ */
22
+ class PermanentRedirectException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/PreconditionFailedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * At least one of the preconditions you specified did not hold.
21
+ */
22
+ class PreconditionFailedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RedirectException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Temporary redirect.
21
+ */
22
+ class RedirectException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestIsNotMultiPartContentException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Bucket POST must be of the enclosure-type multipart/form-data.
21
+ */
22
+ class RequestIsNotMultiPartContentException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestTimeTooSkewedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The difference between the request time and the server's time is too large.
21
+ */
22
+ class RequestTimeTooSkewedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestTimeoutException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Your socket connection to the server was not read from or written to within the timeout period.
21
+ */
22
+ class RequestTimeoutException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/RequestTorrentOfBucketErrorException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Requesting the torrent file of a bucket is not permitted.
21
+ */
22
+ class RequestTorrentOfBucketErrorException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/S3Exception.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ use Aws\Common\Exception\ServiceResponseException;
20
+
21
+ /**
22
+ * Default service exception class
23
+ */
24
+ class S3Exception extends ServiceResponseException {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/ServiceUnavailableException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Please reduce your request rate.
21
+ */
22
+ class ServiceUnavailableException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/SignatureDoesNotMatchException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. For more information, see REST Authentication and SOAP Authentication for details.
21
+ */
22
+ class SignatureDoesNotMatchException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/SlowDownException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * Please reduce your request rate.
21
+ */
22
+ class SlowDownException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/TemporaryRedirectException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * You are being redirected to the bucket while DNS updates.
21
+ */
22
+ class TemporaryRedirectException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/TokenRefreshRequiredException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The provided token must be refreshed.
21
+ */
22
+ class TokenRefreshRequiredException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/TooManyBucketsException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * You have attempted to create more buckets than allowed.
21
+ */
22
+ class TooManyBucketsException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/UnexpectedContentException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * This request does not support content.
21
+ */
22
+ class UnexpectedContentException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/UnresolvableGrantByEmailAddressException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The e-mail address you provided does not match any account on record.
21
+ */
22
+ class UnresolvableGrantByEmailAddressException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Exception/UserKeyMustBeSpecifiedException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Exception;
18
+
19
+ /**
20
+ * The bucket POST must contain the specified field name. If it is specified, please check the order of the fields.
21
+ */
22
+ class UserKeyMustBeSpecifiedException extends S3Exception {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListBucketsIterator.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Iterator;
18
+
19
+ use Aws\Common\Iterator\AwsResourceIterator;
20
+ use Guzzle\Service\Resource\Model;
21
+
22
+ /**
23
+ * Iterator for the S3 ListBuckets command
24
+ *
25
+ * This iterator includes the following additional options:
26
+ *
27
+ * - names_only: Set to true to receive only the object/prefix names
28
+ */
29
+ class ListBucketsIterator extends AwsResourceIterator
30
+ {
31
+ /**
32
+ * {@inheritdoc}
33
+ */
34
+ protected function handleResults(Model $result)
35
+ {
36
+ // Get the results
37
+ $buckets = $result->get('Buckets') ?: array();
38
+
39
+ // If only the names_only set, change arrays to a string
40
+ if ($this->get('names_only')) {
41
+ foreach ($buckets as &$bucket) {
42
+ $bucket = $bucket['Name'];
43
+ }
44
+ }
45
+
46
+ return $buckets;
47
+ }
48
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListMultipartUploadsIterator.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Iterator;
18
+
19
+ use Guzzle\Service\Resource\Model;
20
+ use Aws\Common\Iterator\AwsResourceIterator;
21
+
22
+ /**
23
+ * Iterator for the S3 ListMultipartUploads command
24
+ *
25
+ * This iterator includes the following additional options:
26
+ *
27
+ * - return_prefixes: Set to true to return both prefixes and uploads
28
+ */
29
+ class ListMultipartUploadsIterator extends AwsResourceIterator
30
+ {
31
+ /**
32
+ * {@inheritdoc}
33
+ */
34
+ protected function handleResults(Model $result)
35
+ {
36
+ // Get the list of uploads
37
+ $uploads = $result->get('Uploads') ?: array();
38
+
39
+ // If there are prefixes and we want them, merge them in
40
+ if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
41
+ $uploads = array_merge($uploads, $result->get('CommonPrefixes'));
42
+ }
43
+
44
+ return $uploads;
45
+ }
46
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListObjectVersionsIterator.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Iterator;
18
+
19
+ use Aws\Common\Iterator\AwsResourceIterator;
20
+ use Guzzle\Service\Resource\Model;
21
+
22
+ /**
23
+ * Iterator for an S3 ListObjectVersions command
24
+ *
25
+ * This iterator includes the following additional options:
26
+ *
27
+ * - return_prefixes: Set to true to receive both prefixes and versions in results
28
+ */
29
+ class ListObjectVersionsIterator extends AwsResourceIterator
30
+ {
31
+ /**
32
+ * {@inheritdoc}
33
+ */
34
+ protected function handleResults(Model $result)
35
+ {
36
+ // Get the list of object versions
37
+ $versions = $result->get('Versions') ?: array();
38
+ $deleteMarkers = $result->get('DeleteMarkers') ?: array();
39
+ $versions = array_merge($versions, $deleteMarkers);
40
+
41
+ // If there are prefixes and we want them, merge them in
42
+ if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
43
+ $versions = array_merge($versions, $result->get('CommonPrefixes'));
44
+ }
45
+
46
+ return $versions;
47
+ }
48
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/ListObjectsIterator.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Iterator;
18
+
19
+ use Aws\Common\Iterator\AwsResourceIterator;
20
+ use Guzzle\Service\Resource\Model;
21
+
22
+ /**
23
+ * Iterator for an S3 ListObjects command
24
+ *
25
+ * This iterator includes the following additional options:
26
+ *
27
+ * - return_prefixes: Set to true to receive both prefixes and objects in results
28
+ * - sort_results: Set to true to sort mixed (object/prefix) results
29
+ * - names_only: Set to true to receive only the object/prefix names
30
+ */
31
+ class ListObjectsIterator extends AwsResourceIterator
32
+ {
33
+ protected function handleResults(Model $result)
34
+ {
35
+ // Get the list of objects and record the last key
36
+ $objects = $result->get('Contents') ?: array();
37
+ $numObjects = count($objects);
38
+ $lastKey = $numObjects ? $objects[$numObjects - 1]['Key'] : false;
39
+ if ($lastKey && !$result->hasKey($this->get('output_token'))) {
40
+ $result->set($this->get('output_token'), $lastKey);
41
+ }
42
+
43
+ // Closure for getting the name of an object or prefix
44
+ $getName = function ($object) {
45
+ return isset($object['Key']) ? $object['Key'] : $object['Prefix'];
46
+ };
47
+
48
+ // If common prefixes returned (i.e. a delimiter was set) and they need to be returned, there is more to do
49
+ if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
50
+ // Collect and format the prefixes to include with the objects
51
+ $objects = array_merge($objects, $result->get('CommonPrefixes'));
52
+
53
+ // Sort the objects and prefixes to maintain alphabetical order, but only if some of each were returned
54
+ if ($this->get('sort_results') && $lastKey && $objects) {
55
+ usort($objects, function ($object1, $object2) use ($getName) {
56
+ return strcmp($getName($object1), $getName($object2));
57
+ });
58
+ }
59
+ }
60
+
61
+ // If only the names are desired, iterate through the results and convert the arrays to the object/prefix names
62
+ if ($this->get('names_only')) {
63
+ $objects = array_map($getName, $objects);
64
+ }
65
+
66
+ return $objects;
67
+ }
68
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Iterator/OpendirIterator.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Iterator;
18
+
19
+ /**
20
+ * Provides an iterator around an opendir resource. This is useful when you need to provide context to an opendir so
21
+ * you can't use RecursiveDirectoryIterator
22
+ */
23
+ class OpendirIterator implements \Iterator
24
+ {
25
+ /** @var resource */
26
+ protected $dirHandle;
27
+
28
+ /** @var \SplFileInfo */
29
+ protected $currentFile;
30
+
31
+ /** @var int */
32
+ protected $key = -1;
33
+
34
+ /** @var string */
35
+ protected $filePrefix;
36
+
37
+ /**
38
+ * @param resource $dirHandle Opened directory handled returned from opendir
39
+ * @param string $filePrefix Prefix to add to each filename
40
+ */
41
+ public function __construct($dirHandle, $filePrefix = '')
42
+ {
43
+ $this->filePrefix = $filePrefix;
44
+ $this->dirHandle = $dirHandle;
45
+ $this->next();
46
+ }
47
+
48
+ public function __destruct()
49
+ {
50
+ if ($this->dirHandle) {
51
+ closedir($this->dirHandle);
52
+ }
53
+ }
54
+
55
+ public function rewind()
56
+ {
57
+ $this->key = 0;
58
+ rewinddir($this->dirHandle);
59
+ }
60
+
61
+ public function current()
62
+ {
63
+ return $this->currentFile;
64
+ }
65
+
66
+ public function next()
67
+ {
68
+ if ($file = readdir($this->dirHandle)) {
69
+ $this->currentFile = new \SplFileInfo($this->filePrefix . $file);
70
+ } else {
71
+ $this->currentFile = false;
72
+ }
73
+
74
+ $this->key++;
75
+ }
76
+
77
+ public function key()
78
+ {
79
+ return $this->key;
80
+ }
81
+
82
+ public function valid()
83
+ {
84
+ return $this->currentFile !== false;
85
+ }
86
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/Acp.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\Common\Exception\InvalidArgumentException;
20
+ use Aws\Common\Exception\OverflowException;
21
+ use Guzzle\Common\ToArrayInterface;
22
+ use Guzzle\Service\Command\AbstractCommand;
23
+
24
+ /**
25
+ * Amazon S3 Access Control Policy (ACP)
26
+ */
27
+ class Acp implements ToArrayInterface, \IteratorAggregate, \Countable
28
+ {
29
+ /**
30
+ * @var \SplObjectStorage List of grants on the ACP
31
+ */
32
+ protected $grants = array();
33
+
34
+ /**
35
+ * @var Grantee The owner of the ACP
36
+ */
37
+ protected $owner;
38
+
39
+ /**
40
+ * Constructs an ACP
41
+ *
42
+ * @param Grantee $owner ACP policy owner
43
+ * @param array|\Traversable $grants List of grants for the ACP
44
+ */
45
+ public function __construct(Grantee $owner, $grants = null)
46
+ {
47
+ $this->setOwner($owner);
48
+ $this->setGrants($grants);
49
+ }
50
+
51
+ /**
52
+ * Create an Acp object from an array. This can be used to create an ACP from a response to a GetObject/Bucket ACL
53
+ * operation.
54
+ *
55
+ * @param array $data Array of ACP data
56
+ *
57
+ * @return Acp
58
+ */
59
+ public static function fromArray(array $data)
60
+ {
61
+ $builder = new AcpBuilder();
62
+ $builder->setOwner((string) $data['Owner']['ID'], $data['Owner']['DisplayName']);
63
+
64
+ // Add each Grantee to the ACP
65
+ foreach ($data['Grants'] as $grant) {
66
+ $permission = $grant['Permission'];
67
+
68
+ // Determine the type for response bodies that are missing the Type parameter
69
+ if (!isset($grant['Grantee']['Type'])) {
70
+ if (isset($grant['Grantee']['ID'])) {
71
+ $grant['Grantee']['Type'] = 'CanonicalUser';
72
+ } elseif (isset($grant['Grantee']['URI'])) {
73
+ $grant['Grantee']['Type'] = 'Group';
74
+ } else {
75
+ $grant['Grantee']['Type'] = 'AmazonCustomerByEmail';
76
+ }
77
+ }
78
+
79
+ switch ($grant['Grantee']['Type']) {
80
+ case 'Group':
81
+ $builder->addGrantForGroup($permission, $grant['Grantee']['URI']);
82
+ break;
83
+ case 'AmazonCustomerByEmail':
84
+ $builder->addGrantForEmail($permission, $grant['Grantee']['EmailAddress']);
85
+ break;
86
+ case 'CanonicalUser':
87
+ $builder->addGrantForUser(
88
+ $permission,
89
+ $grant['Grantee']['ID'],
90
+ $grant['Grantee']['DisplayName']
91
+ );
92
+ }
93
+ }
94
+
95
+ return $builder->build();
96
+ }
97
+
98
+ /**
99
+ * Set the owner of the ACP policy
100
+ *
101
+ * @param Grantee $owner ACP policy owner
102
+ *
103
+ * @return $this
104
+ *
105
+ * @throws InvalidArgumentException if the grantee does not have an ID set
106
+ */
107
+ public function setOwner(Grantee $owner)
108
+ {
109
+ if (!$owner->isCanonicalUser()) {
110
+ throw new InvalidArgumentException('The owner must have an ID set.');
111
+ }
112
+
113
+ $this->owner = $owner;
114
+
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * Get the owner of the ACP policy
120
+ *
121
+ * @return Grantee
122
+ */
123
+ public function getOwner()
124
+ {
125
+ return $this->owner;
126
+ }
127
+
128
+ /**
129
+ * Set the grants for the ACP
130
+ *
131
+ * @param array|\Traversable $grants List of grants for the ACP
132
+ *
133
+ * @return $this
134
+ *
135
+ * @throws InvalidArgumentException
136
+ */
137
+ public function setGrants($grants = array())
138
+ {
139
+ $this->grants = new \SplObjectStorage();
140
+
141
+ if ($grants) {
142
+ if (is_array($grants) || $grants instanceof \Traversable) {
143
+ /** @var $grant Grant */
144
+ foreach ($grants as $grant) {
145
+ $this->addGrant($grant);
146
+ }
147
+ } else {
148
+ throw new InvalidArgumentException('Grants must be passed in as an array or Traversable object.');
149
+ }
150
+ }
151
+
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * Get all of the grants
157
+ *
158
+ * @return \SplObjectStorage
159
+ */
160
+ public function getGrants()
161
+ {
162
+ return $this->grants;
163
+ }
164
+
165
+ /**
166
+ * Add a Grant
167
+ *
168
+ * @param Grant $grant Grant to add
169
+ *
170
+ * @return $this
171
+ */
172
+ public function addGrant(Grant $grant)
173
+ {
174
+ if (count($this->grants) < 100) {
175
+ $this->grants->attach($grant);
176
+ } else {
177
+ throw new OverflowException('An ACP may contain up to 100 grants.');
178
+ }
179
+
180
+ return $this;
181
+ }
182
+
183
+ /**
184
+ * Get the total number of attributes
185
+ *
186
+ * @return int
187
+ */
188
+ public function count()
189
+ {
190
+ return count($this->grants);
191
+ }
192
+
193
+ /**
194
+ * Returns the grants for iteration
195
+ *
196
+ * @return \SplObjectStorage
197
+ */
198
+ public function getIterator()
199
+ {
200
+ return $this->grants;
201
+ }
202
+
203
+ /**
204
+ * Applies grant headers to a command's parameters
205
+ *
206
+ * @param AbstractCommand $command Command to be updated
207
+ *
208
+ * @return $this
209
+ */
210
+ public function updateCommand(AbstractCommand $command)
211
+ {
212
+ $parameters = array();
213
+ foreach ($this->grants as $grant) {
214
+ /** @var $grant Grant */
215
+ $parameters = array_merge_recursive($parameters, $grant->getParameterArray());
216
+ }
217
+
218
+ foreach ($parameters as $name => $values) {
219
+ $command->set($name, implode(', ', (array) $values));
220
+ }
221
+
222
+ return $this;
223
+ }
224
+
225
+ /**
226
+ * {@inheritdoc}
227
+ */
228
+ public function toArray()
229
+ {
230
+ $grants = array();
231
+ foreach ($this->grants as $grant) {
232
+ $grants[] = $grant->toArray();
233
+ }
234
+
235
+ return array(
236
+ 'Owner' => array(
237
+ 'ID' => $this->owner->getId(),
238
+ 'DisplayName' => $this->owner->getDisplayName()
239
+ ),
240
+ 'Grants' => $grants
241
+ );
242
+ }
243
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/AcpBuilder.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\S3\Enum\GranteeType;
20
+
21
+ /**
22
+ * Builder for creating Access Control Policies
23
+ */
24
+ class AcpBuilder
25
+ {
26
+ /**
27
+ * @var Grantee The owner for the ACL
28
+ */
29
+ protected $owner;
30
+
31
+ /**
32
+ * @var array An array of Grant objects for the ACL
33
+ */
34
+ protected $grants = array();
35
+
36
+ /**
37
+ * Static method for chainable instantiation
38
+ *
39
+ * @return static
40
+ */
41
+ public static function newInstance()
42
+ {
43
+ return new static;
44
+ }
45
+
46
+ /**
47
+ * Sets the owner to be set on the ACL
48
+ *
49
+ * @param string $id Owner identifier
50
+ * @param string $displayName Owner display name
51
+ *
52
+ * @return $this
53
+ */
54
+ public function setOwner($id, $displayName = null)
55
+ {
56
+ $this->owner = new Grantee($id, $displayName ?: $id, GranteeType::USER);
57
+
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Create and store a Grant with a CanonicalUser Grantee for the ACL
63
+ *
64
+ * @param string $permission Permission for the Grant
65
+ * @param string $id Grantee identifier
66
+ * @param string $displayName Grantee display name
67
+ *
68
+ * @return $this
69
+ */
70
+ public function addGrantForUser($permission, $id, $displayName = null)
71
+ {
72
+ $grantee = new Grantee($id, $displayName ?: $id, GranteeType::USER);
73
+ $this->addGrant($permission, $grantee);
74
+
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Create and store a Grant with a AmazonCustomerByEmail Grantee for the ACL
80
+ *
81
+ * @param string $permission Permission for the Grant
82
+ * @param string $email Grantee email address
83
+ *
84
+ * @return $this
85
+ */
86
+ public function addGrantForEmail($permission, $email)
87
+ {
88
+ $grantee = new Grantee($email, null, GranteeType::EMAIL);
89
+ $this->addGrant($permission, $grantee);
90
+
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * Create and store a Grant with a Group Grantee for the ACL
96
+ *
97
+ * @param string $permission Permission for the Grant
98
+ * @param string $group Grantee group
99
+ *
100
+ * @return $this
101
+ */
102
+ public function addGrantForGroup($permission, $group)
103
+ {
104
+ $grantee = new Grantee($group, null, GranteeType::GROUP);
105
+ $this->addGrant($permission, $grantee);
106
+
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Create and store a Grant for the ACL
112
+ *
113
+ * @param string $permission Permission for the Grant
114
+ * @param Grantee $grantee The Grantee for the Grant
115
+ *
116
+ * @return $this
117
+ */
118
+ public function addGrant($permission, Grantee $grantee)
119
+ {
120
+ $this->grants[] = new Grant($grantee, $permission);
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Builds the ACP and returns it
127
+ *
128
+ * @return Acp
129
+ */
130
+ public function build()
131
+ {
132
+ return new Acp($this->owner, $this->grants);
133
+ }
134
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/ClearBucket.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+ use Guzzle\Common\AbstractHasDispatcher;
21
+ use Guzzle\Batch\FlushingBatch;
22
+ use Guzzle\Batch\ExceptionBufferingBatch;
23
+ use Guzzle\Batch\NotifyingBatch;
24
+ use Guzzle\Common\Exception\ExceptionCollection;
25
+
26
+ /**
27
+ * Class used to clear the contents of a bucket or the results of an iterator
28
+ */
29
+ class ClearBucket extends AbstractHasDispatcher
30
+ {
31
+ /**
32
+ * @var string Event emitted when a batch request has completed
33
+ */
34
+ const AFTER_DELETE = 'clear_bucket.after_delete';
35
+
36
+ /**
37
+ * @var string Event emitted before the bucket is cleared
38
+ */
39
+ const BEFORE_CLEAR = 'clear_bucket.before_clear';
40
+
41
+ /**
42
+ * @var string Event emitted after the bucket is cleared
43
+ */
44
+ const AFTER_CLEAR = 'clear_bucket.after_clear';
45
+
46
+ /**
47
+ * @var AwsClientInterface Client used to execute the requests
48
+ */
49
+ protected $client;
50
+
51
+ /**
52
+ * @var AbstractS3ResourceIterator Iterator used to yield keys
53
+ */
54
+ protected $iterator;
55
+
56
+ /**
57
+ * @var string MFA used with each request
58
+ */
59
+ protected $mfa;
60
+
61
+ /**
62
+ * @param AwsClientInterface $client Client used to execute requests
63
+ * @param string $bucket Name of the bucket to clear
64
+ */
65
+ public function __construct(AwsClientInterface $client, $bucket)
66
+ {
67
+ $this->client = $client;
68
+ $this->bucket = $bucket;
69
+ }
70
+
71
+ /**
72
+ * {@inheritdoc}
73
+ */
74
+ public static function getAllEvents()
75
+ {
76
+ return array(self::AFTER_DELETE, self::BEFORE_CLEAR, self::AFTER_CLEAR);
77
+ }
78
+
79
+ /**
80
+ * Set the bucket that is to be cleared
81
+ *
82
+ * @param string $bucket Name of the bucket to clear
83
+ *
84
+ * @return $this
85
+ */
86
+ public function setBucket($bucket)
87
+ {
88
+ $this->bucket = $bucket;
89
+
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * Get the iterator used to yield the keys to be deleted. A default iterator
95
+ * will be created and returned if no iterator has been explicitly set.
96
+ *
97
+ * @return \Iterator
98
+ */
99
+ public function getIterator()
100
+ {
101
+ if (!$this->iterator) {
102
+ $this->iterator = $this->client->getIterator('ListObjectVersions', array(
103
+ 'Bucket' => $this->bucket
104
+ ));
105
+ }
106
+
107
+ return $this->iterator;
108
+ }
109
+
110
+ /**
111
+ * Sets a different iterator to use than the default iterator. This can be helpful when you wish to delete
112
+ * only specific keys from a bucket (e.g. keys that match a certain prefix or delimiter, or perhaps keys that
113
+ * pass through a filtered, decorated iterator).
114
+ *
115
+ * @param \Iterator $iterator Iterator used to yield the keys to be deleted
116
+ *
117
+ * @return $this
118
+ */
119
+ public function setIterator(\Iterator $iterator)
120
+ {
121
+ $this->iterator = $iterator;
122
+
123
+ return $this;
124
+ }
125
+
126
+ /**
127
+ * Set the MFA token to send with each request
128
+ *
129
+ * @param string $mfa MFA token to send with each request. The value is the concatenation of the authentication
130
+ * device's serial number, a space, and the value displayed on your authentication device.
131
+ *
132
+ * @return $this
133
+ */
134
+ public function setMfa($mfa)
135
+ {
136
+ $this->mfa = $mfa;
137
+
138
+ return $this;
139
+ }
140
+
141
+ /**
142
+ * Clear the bucket
143
+ *
144
+ * @return int Returns the number of deleted keys
145
+ * @throws ExceptionCollection
146
+ */
147
+ public function clear()
148
+ {
149
+ $that = $this;
150
+ $batch = DeleteObjectsBatch::factory($this->client, $this->bucket, $this->mfa);
151
+ $batch = new NotifyingBatch($batch, function ($items) use ($that) {
152
+ $that->dispatch(ClearBucket::AFTER_DELETE, array('keys' => $items));
153
+ });
154
+ $batch = new FlushingBatch(new ExceptionBufferingBatch($batch), 1000);
155
+
156
+ // Let any listeners know that the bucket is about to be cleared
157
+ $this->dispatch(self::BEFORE_CLEAR, array(
158
+ 'iterator' => $this->getIterator(),
159
+ 'batch' => $batch,
160
+ 'mfa' => $this->mfa
161
+ ));
162
+
163
+ $deleted = 0;
164
+ foreach ($this->getIterator() as $object) {
165
+ if (isset($object['VersionId'])) {
166
+ $versionId = $object['VersionId'] == 'null' ? null : $object['VersionId'];
167
+ } else {
168
+ $versionId = null;
169
+ }
170
+ $batch->addKey($object['Key'], $versionId);
171
+ $deleted++;
172
+ }
173
+ $batch->flush();
174
+
175
+ // If any errors were encountered, then throw an ExceptionCollection
176
+ if (count($batch->getExceptions())) {
177
+ $e = new ExceptionCollection();
178
+ foreach ($batch->getExceptions() as $exception) {
179
+ $e->add($exception->getPrevious());
180
+ }
181
+ throw $e;
182
+ }
183
+
184
+ // Let any listeners know that the bucket was cleared
185
+ $this->dispatch(self::AFTER_CLEAR, array('deleted' => $deleted));
186
+
187
+ return $deleted;
188
+ }
189
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/DeleteObjectsBatch.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+ use Aws\Common\Exception\InvalidArgumentException;
21
+ use Guzzle\Service\Command\AbstractCommand;
22
+ use Guzzle\Batch\BatchBuilder;
23
+ use Guzzle\Batch\BatchSizeDivisor;
24
+ use Guzzle\Batch\AbstractBatchDecorator;
25
+
26
+ /**
27
+ * The DeleteObjectsBatch is a BatchDecorator for Guzzle that implements a
28
+ * queue for deleting keys from an Amazon S3 bucket. You can add DeleteObject
29
+ * or an array of [Key => %s, VersionId => %s] and call flush when the objects
30
+ * should be deleted.
31
+ */
32
+ class DeleteObjectsBatch extends AbstractBatchDecorator
33
+ {
34
+ /**
35
+ * Factory for creating a DeleteObjectsBatch
36
+ *
37
+ * @param AwsClientInterface $client Client used to transfer requests
38
+ * @param string $bucket Bucket that contains the objects to delete
39
+ * @param string $mfa MFA token to use with the request
40
+ *
41
+ * @return static
42
+ */
43
+ public static function factory(AwsClientInterface $client, $bucket, $mfa = null)
44
+ {
45
+ $batch = BatchBuilder::factory()
46
+ ->createBatchesWith(new BatchSizeDivisor(1000))
47
+ ->transferWith(new DeleteObjectsTransfer($client, $bucket, $mfa))
48
+ ->build();
49
+
50
+ return new static($batch);
51
+ }
52
+
53
+ /**
54
+ * Add an object to be deleted
55
+ *
56
+ * @param string $key Key of the object
57
+ * @param string $versionId VersionID of the object
58
+ *
59
+ * @return $this
60
+ */
61
+ public function addKey($key, $versionId = null)
62
+ {
63
+ return $this->add(array(
64
+ 'Key' => $key,
65
+ 'VersionId' => $versionId
66
+ ));
67
+ }
68
+
69
+ /**
70
+ * {@inheritdoc}
71
+ */
72
+ public function add($item)
73
+ {
74
+ if ($item instanceof AbstractCommand && $item->getName() == 'DeleteObject') {
75
+ $item = array(
76
+ 'Key' => $item['Key'],
77
+ 'VersionId' => $item['VersionId']
78
+ );
79
+ }
80
+
81
+ if (!is_array($item) || (!isset($item['Key']))) {
82
+ throw new InvalidArgumentException('Item must be a DeleteObject command or array containing a Key and VersionId key.');
83
+ }
84
+
85
+ return parent::add($item);
86
+ }
87
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/DeleteObjectsTransfer.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+ use Aws\Common\Exception\OverflowException;
21
+ use Aws\Common\Enum\UaString as Ua;
22
+ use Aws\S3\Exception\InvalidArgumentException;
23
+ use Aws\S3\Exception\DeleteMultipleObjectsException;
24
+ use Guzzle\Batch\BatchTransferInterface;
25
+ use Guzzle\Service\Command\CommandInterface;
26
+
27
+ /**
28
+ * Transfer logic for deleting multiple objects from an Amazon S3 bucket in a
29
+ * single request
30
+ */
31
+ class DeleteObjectsTransfer implements BatchTransferInterface
32
+ {
33
+ /**
34
+ * @var AwsClientInterface The Amazon S3 client for doing transfers
35
+ */
36
+ protected $client;
37
+
38
+ /**
39
+ * @var string Bucket from which to delete the objects
40
+ */
41
+ protected $bucket;
42
+
43
+ /**
44
+ * @var string MFA token to apply to the request
45
+ */
46
+ protected $mfa;
47
+
48
+ /**
49
+ * Constructs a transfer using the injected client
50
+ *
51
+ * @param AwsClientInterface $client Client used to transfer the requests
52
+ * @param string $bucket Name of the bucket that stores the objects
53
+ * @param string $mfa MFA token used when contacting the Amazon S3 API
54
+ */
55
+ public function __construct(AwsClientInterface $client, $bucket, $mfa = null)
56
+ {
57
+ $this->client = $client;
58
+ $this->bucket = $bucket;
59
+ $this->mfa = $mfa;
60
+ }
61
+
62
+ /**
63
+ * Set a new MFA token value
64
+ *
65
+ * @param string $token MFA token
66
+ *
67
+ * @return $this
68
+ */
69
+ public function setMfa($token)
70
+ {
71
+ $this->mfa = $token;
72
+
73
+ return $this;
74
+ }
75
+
76
+ /**
77
+ * {@inheritdoc}
78
+ * @throws OverflowException if a batch has more than 1000 items
79
+ * @throws InvalidArgumentException when an invalid batch item is encountered
80
+ */
81
+ public function transfer(array $batch)
82
+ {
83
+ if (empty($batch)) {
84
+ return;
85
+ }
86
+
87
+ if (count($batch) > 1000) {
88
+ throw new OverflowException('Batches should be divided into chunks of no larger than 1000 keys');
89
+ }
90
+
91
+ $del = array();
92
+ $command = $this->client->getCommand('DeleteObjects', array(
93
+ 'Bucket' => $this->bucket,
94
+ Ua::OPTION => Ua::BATCH
95
+ ));
96
+
97
+ if ($this->mfa) {
98
+ $command->getRequestHeaders()->set('x-amz-mfa', $this->mfa);
99
+ }
100
+
101
+ foreach ($batch as $object) {
102
+ // Ensure that the batch item is valid
103
+ if (!is_array($object) || !isset($object['Key'])) {
104
+ throw new InvalidArgumentException('Invalid batch item encountered: ' . var_export($batch, true));
105
+ }
106
+ $del[] = array(
107
+ 'Key' => $object['Key'],
108
+ 'VersionId' => isset($object['VersionId']) ? $object['VersionId'] : null
109
+ );
110
+ }
111
+
112
+ $command['Objects'] = $del;
113
+
114
+ $command->execute();
115
+ $this->processResponse($command);
116
+ }
117
+
118
+ /**
119
+ * Process the response of the DeleteMultipleObjects request
120
+ *
121
+ * @paramCommandInterface $command Command executed
122
+ */
123
+ protected function processResponse(CommandInterface $command)
124
+ {
125
+ $result = $command->getResult();
126
+
127
+ // Ensure that the objects were deleted successfully
128
+ if (!empty($result['Errors'])) {
129
+ $errors = $result['Errors'];
130
+ throw new DeleteMultipleObjectsException($errors);
131
+ }
132
+ }
133
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/Grant.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\S3\Enum\Permission;
20
+ use Aws\Common\Exception\InvalidArgumentException;
21
+ use Guzzle\Common\ToArrayInterface;
22
+
23
+ /**
24
+ * Amazon S3 Grant model
25
+ */
26
+ class Grant implements ToArrayInterface
27
+ {
28
+ /**
29
+ * @var array A map of permissions to operation parameters
30
+ */
31
+ protected static $parameterMap = array(
32
+ Permission::READ => 'GrantRead',
33
+ Permission::WRITE => 'GrantWrite',
34
+ Permission::READ_ACP => 'GrantReadACP',
35
+ Permission::WRITE_ACP => 'GrantWriteACP',
36
+ Permission::FULL_CONTROL => 'GrantFullControl'
37
+ );
38
+
39
+ /**
40
+ * @var Grantee The grantee affected by the grant
41
+ */
42
+ protected $grantee;
43
+
44
+ /**
45
+ * @var string The permission set by the grant
46
+ */
47
+ protected $permission;
48
+
49
+ /**
50
+ * Constructs an ACL
51
+ *
52
+ * @param Grantee $grantee Affected grantee
53
+ * @param string $permission Permission applied
54
+ */
55
+ public function __construct(Grantee $grantee, $permission)
56
+ {
57
+ $this->setGrantee($grantee);
58
+ $this->setPermission($permission);
59
+ }
60
+
61
+ /**
62
+ * Set the grantee affected by the grant
63
+ *
64
+ * @param Grantee $grantee Affected grantee
65
+ *
66
+ * @return $this
67
+ */
68
+ public function setGrantee(Grantee $grantee)
69
+ {
70
+ $this->grantee = $grantee;
71
+
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * Get the grantee affected by the grant
77
+ *
78
+ * @return Grantee
79
+ */
80
+ public function getGrantee()
81
+ {
82
+ return $this->grantee;
83
+ }
84
+
85
+ /**
86
+ * Set the permission set by the grant
87
+ *
88
+ * @param string $permission Permission applied
89
+ *
90
+ * @return $this
91
+ *
92
+ * @throws InvalidArgumentException
93
+ */
94
+ public function setPermission($permission)
95
+ {
96
+ $valid = Permission::values();
97
+ if (!in_array($permission, $valid)) {
98
+ throw new InvalidArgumentException('The permission must be one of '
99
+ . 'the following: ' . implode(', ', $valid) . '.');
100
+ }
101
+
102
+ $this->permission = $permission;
103
+
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Get the permission set by the grant
109
+ *
110
+ * @return string
111
+ */
112
+ public function getPermission()
113
+ {
114
+ return $this->permission;
115
+ }
116
+
117
+ /**
118
+ * Returns an array of the operation parameter and value to set on the operation
119
+ *
120
+ * @return array
121
+ */
122
+ public function getParameterArray()
123
+ {
124
+ return array(
125
+ self::$parameterMap[$this->permission] => $this->grantee->getHeaderValue()
126
+ );
127
+ }
128
+
129
+ /**
130
+ * {@inheritdoc}
131
+ */
132
+ public function toArray()
133
+ {
134
+ return array(
135
+ 'Grantee' => $this->grantee->toArray(),
136
+ 'Permission' => $this->permission
137
+ );
138
+ }
139
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/Grantee.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\S3\Enum\Group;
20
+ use Aws\S3\Enum\GranteeType;
21
+ use Aws\Common\Exception\InvalidArgumentException;
22
+ use Aws\Common\Exception\UnexpectedValueException;
23
+ use Aws\Common\Exception\LogicException;
24
+ use Guzzle\Common\ToArrayInterface;
25
+
26
+ /**
27
+ * Amazon S3 Grantee model
28
+ */
29
+ class Grantee implements ToArrayInterface
30
+ {
31
+ /**
32
+ * @var array A map of grantee types to grant header value prefixes
33
+ */
34
+ protected static $headerMap = array(
35
+ GranteeType::USER => 'id',
36
+ GranteeType::EMAIL => 'emailAddress',
37
+ GranteeType::GROUP => 'uri'
38
+ );
39
+
40
+ /**
41
+ * @var string The account ID, email, or URL identifying the grantee
42
+ */
43
+ protected $id;
44
+
45
+ /**
46
+ * @var string The display name of the grantee
47
+ */
48
+ protected $displayName;
49
+
50
+ /**
51
+ * @var string The type of the grantee (CanonicalUser or Group)
52
+ */
53
+ protected $type;
54
+
55
+ /**
56
+ * Constructs a Grantee
57
+ *
58
+ * @param string $id Grantee identifier
59
+ * @param string $displayName Grantee display name
60
+ * @param string $expectedType The expected type of the grantee
61
+ */
62
+ public function __construct($id, $displayName = null, $expectedType = null)
63
+ {
64
+ $this->type = GranteeType::USER;
65
+ $this->setId($id, $expectedType);
66
+ $this->setDisplayName($displayName);
67
+ }
68
+
69
+ /**
70
+ * Sets the account ID, email, or URL identifying the grantee
71
+ *
72
+ * @param string $id Grantee identifier
73
+ * @param string $expectedType The expected type of the grantee
74
+ *
75
+ * @return Grantee
76
+ *
77
+ * @throws UnexpectedValueException if $expectedType is set and the grantee
78
+ * is not of that type after instantiation
79
+ * @throws InvalidArgumentException when the ID provided is not a string
80
+ */
81
+ public function setId($id, $expectedType = null)
82
+ {
83
+ if (in_array($id, Group::values())) {
84
+ $this->type = GranteeType::GROUP;
85
+ } elseif (!is_string($id)) {
86
+ throw new InvalidArgumentException('The grantee ID must be provided as a string value.');
87
+ }
88
+
89
+ if (strpos($id, '@') !== false) {
90
+ $this->type = GranteeType::EMAIL;
91
+ }
92
+
93
+ if ($expectedType && $expectedType !== $this->type) {
94
+ throw new UnexpectedValueException('The type of the grantee after '
95
+ . 'setting the ID did not match the specified, expected type "'
96
+ . $expectedType . '" but received "' . $this->type . '".');
97
+ }
98
+
99
+ $this->id = $id;
100
+
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Gets the grantee identifier
106
+ *
107
+ * @return string
108
+ */
109
+ public function getId()
110
+ {
111
+ return $this->id;
112
+ }
113
+
114
+ /**
115
+ * Gets the grantee email address (if it is set)
116
+ *
117
+ * @return null|string
118
+ */
119
+ public function getEmailAddress()
120
+ {
121
+ return $this->isAmazonCustomerByEmail() ? $this->id : null;
122
+ }
123
+
124
+ /**
125
+ * Gets the grantee URI (if it is set)
126
+ *
127
+ * @return null|string
128
+ */
129
+ public function getGroupUri()
130
+ {
131
+ return $this->isGroup() ? $this->id : null;
132
+ }
133
+
134
+ /**
135
+ * Sets the display name of the grantee
136
+ *
137
+ * @param string $displayName Grantee name
138
+ *
139
+ * @return Grantee
140
+ *
141
+ * @throws LogicException when the grantee type not CanonicalUser
142
+ */
143
+ public function setDisplayName($displayName)
144
+ {
145
+ if ($this->type === GranteeType::USER) {
146
+ if (empty($displayName) || !is_string($displayName)) {
147
+ $displayName = $this->id;
148
+ }
149
+ $this->displayName = $displayName;
150
+ } else {
151
+ if ($displayName) {
152
+ throw new LogicException('The display name can only be set '
153
+ . 'for grantees specified by ID.');
154
+ }
155
+ }
156
+
157
+ return $this;
158
+ }
159
+
160
+ /**
161
+ * Gets the grantee display name
162
+ *
163
+ * @return string
164
+ */
165
+ public function getDisplayName()
166
+ {
167
+ return $this->displayName;
168
+ }
169
+
170
+ /**
171
+ * Gets the grantee type (determined by ID)
172
+ *
173
+ * @return string
174
+ */
175
+ public function getType()
176
+ {
177
+ return $this->type;
178
+ }
179
+
180
+ /**
181
+ * Returns true if this grantee object represents a canonical user by ID
182
+ *
183
+ * @return bool
184
+ */
185
+ public function isCanonicalUser()
186
+ {
187
+ return ($this->type === GranteeType::USER);
188
+ }
189
+
190
+ /**
191
+ * Returns true if this grantee object represents a customer by email
192
+ *
193
+ * @return bool
194
+ */
195
+ public function isAmazonCustomerByEmail()
196
+ {
197
+ return ($this->type === GranteeType::EMAIL);
198
+ }
199
+
200
+ /**
201
+ * Returns true if this grantee object represents a group by URL
202
+ *
203
+ * @return bool
204
+ */
205
+ public function isGroup()
206
+ {
207
+ return ($this->type === GranteeType::GROUP);
208
+ }
209
+
210
+ /**
211
+ * Returns the value used in headers to specify this grantee
212
+ *
213
+ * @return string
214
+ */
215
+ public function getHeaderValue()
216
+ {
217
+ $key = static::$headerMap[$this->type];
218
+
219
+ return "{$key}=\"{$this->id}\"";
220
+ }
221
+
222
+ /**
223
+ * {@inheritdoc}
224
+ */
225
+ public function toArray()
226
+ {
227
+ $result = array(
228
+ 'Type' => $this->type
229
+ );
230
+
231
+ switch ($this->type) {
232
+ case GranteeType::USER:
233
+ $result['ID'] = $this->id;
234
+ $result['DisplayName'] = $this->displayName;
235
+ break;
236
+ case GranteeType::EMAIL:
237
+ $result['EmailAddress'] = $this->id;
238
+ break;
239
+ case GranteeType::GROUP:
240
+ $result['URI'] = $this->id;
241
+ }
242
+
243
+ return $result;
244
+ }
245
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/AbstractTransfer.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Enum\UaString as Ua;
20
+ use Aws\Common\Exception\RuntimeException;
21
+ use Aws\Common\Model\MultipartUpload\AbstractTransfer as CommonAbstractTransfer;
22
+ use Guzzle\Service\Command\OperationCommand;
23
+
24
+ /**
25
+ * Abstract class for transfer commonalities
26
+ */
27
+ abstract class AbstractTransfer extends CommonAbstractTransfer
28
+ {
29
+ // An S3 upload part can be anywhere from 5 MB to 5 GB, but you can only have 10000 parts per upload
30
+ const MIN_PART_SIZE = 5242880;
31
+ const MAX_PART_SIZE = 5368709120;
32
+ const MAX_PARTS = 10000;
33
+
34
+ /**
35
+ * {@inheritdoc}
36
+ * @throws RuntimeException if the part size can not be calculated from the provided data
37
+ */
38
+ protected function init()
39
+ {
40
+ // Merge provided options onto the default option values
41
+ $this->options = array_replace(array(
42
+ 'min_part_size' => self::MIN_PART_SIZE,
43
+ 'part_md5' => true
44
+ ), $this->options);
45
+
46
+ // Make sure the part size can be calculated somehow
47
+ if (!$this->options['min_part_size'] && !$this->source->getContentLength()) {
48
+ throw new RuntimeException('The ContentLength of the data source could not be determined, and no '
49
+ . 'min_part_size option was provided');
50
+ }
51
+ }
52
+
53
+ /**
54
+ * {@inheritdoc}
55
+ */
56
+ protected function calculatePartSize()
57
+ {
58
+ $partSize = $this->source->getContentLength()
59
+ ? (int) ceil(($this->source->getContentLength() / self::MAX_PARTS))
60
+ : self::MIN_PART_SIZE;
61
+ $partSize = max($this->options['min_part_size'], $partSize);
62
+ $partSize = min($partSize, self::MAX_PART_SIZE);
63
+ $partSize = max($partSize, self::MIN_PART_SIZE);
64
+
65
+ return $partSize;
66
+ }
67
+
68
+ /**
69
+ * {@inheritdoc}
70
+ */
71
+ protected function complete()
72
+ {
73
+ /** @var $part UploadPart */
74
+ $parts = array();
75
+ foreach ($this->state as $part) {
76
+ $parts[] = array(
77
+ 'PartNumber' => $part->getPartNumber(),
78
+ 'ETag' => $part->getETag(),
79
+ );
80
+ }
81
+
82
+ $params = $this->state->getUploadId()->toParams();
83
+ $params[Ua::OPTION] = Ua::MULTIPART_UPLOAD;
84
+ $params['Parts'] = $parts;
85
+ $command = $this->client->getCommand('CompleteMultipartUpload', $params);
86
+
87
+ return $command->getResult();
88
+ }
89
+
90
+ /**
91
+ * {@inheritdoc}
92
+ */
93
+ protected function getAbortCommand()
94
+ {
95
+ $params = $this->state->getUploadId()->toParams();
96
+ $params[Ua::OPTION] = Ua::MULTIPART_UPLOAD;
97
+
98
+ /** @var $command OperationCommand */
99
+ $command = $this->client->getCommand('AbortMultipartUpload', $params);
100
+
101
+ return $command;
102
+ }
103
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/ParallelTransfer.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Aws\Common\Enum\DateFormat;
21
+ use Aws\Common\Enum\UaString as Ua;
22
+ use Guzzle\Http\EntityBody;
23
+ use Guzzle\Http\ReadLimitEntityBody;
24
+
25
+ /**
26
+ * Transfers multipart upload parts in parallel
27
+ */
28
+ class ParallelTransfer extends AbstractTransfer
29
+ {
30
+ /**
31
+ * {@inheritdoc}
32
+ */
33
+ protected function init()
34
+ {
35
+ parent::init();
36
+
37
+ if (!$this->source->isLocal() || $this->source->getWrapper() != 'plainfile') {
38
+ throw new RuntimeException('The source data must be a local file stream when uploading in parallel.');
39
+ }
40
+
41
+ if (empty($this->options['concurrency'])) {
42
+ throw new RuntimeException('The `concurrency` option must be specified when instantiating.');
43
+ }
44
+ }
45
+
46
+ /**
47
+ * {@inheritdoc}
48
+ */
49
+ protected function transfer()
50
+ {
51
+ $totalParts = (int) ceil($this->source->getContentLength() / $this->partSize);
52
+ $concurrency = min($totalParts, $this->options['concurrency']);
53
+ $partsToSend = $this->prepareParts($concurrency);
54
+ $eventData = $this->getEventData();
55
+
56
+ while (!$this->stopped && count($this->state) < $totalParts) {
57
+
58
+ $currentTotal = count($this->state);
59
+ $commands = array();
60
+
61
+ for ($i = 0; $i < $concurrency && $i + $currentTotal < $totalParts; $i++) {
62
+
63
+ // Move the offset to the correct position
64
+ $partsToSend[$i]->setOffset(($currentTotal + $i) * $this->partSize);
65
+
66
+ // @codeCoverageIgnoreStart
67
+ if ($partsToSend[$i]->getContentLength() == 0) {
68
+ break;
69
+ }
70
+ // @codeCoverageIgnoreEnd
71
+
72
+ $params = $this->state->getUploadId()->toParams();
73
+ $eventData['command'] = $this->client->getCommand('UploadPart', array_replace($params, array(
74
+ 'PartNumber' => count($this->state) + 1 + $i,
75
+ 'Body' => $partsToSend[$i],
76
+ 'ContentMD5' => (bool) $this->options['part_md5'],
77
+ Ua::OPTION => Ua::MULTIPART_UPLOAD
78
+ )));
79
+ $commands[] = $eventData['command'];
80
+ // Notify any listeners of the part upload
81
+ $this->dispatch(self::BEFORE_PART_UPLOAD, $eventData);
82
+ }
83
+
84
+ // Allow listeners to stop the transfer if needed
85
+ if ($this->stopped) {
86
+ break;
87
+ }
88
+
89
+ // Execute each command, iterate over the results, and add to the transfer state
90
+ /** @var $command \Guzzle\Service\Command\OperationCommand */
91
+ foreach ($this->client->execute($commands) as $command) {
92
+ $this->state->addPart(UploadPart::fromArray(array(
93
+ 'PartNumber' => count($this->state) + 1,
94
+ 'ETag' => $command->getResponse()->getEtag(),
95
+ 'Size' => (int) $command->getResponse()->getContentLength(),
96
+ 'LastModified' => gmdate(DateFormat::RFC2822)
97
+ )));
98
+ $eventData['command'] = $command;
99
+ // Notify any listeners the the part was uploaded
100
+ $this->dispatch(self::AFTER_PART_UPLOAD, $eventData);
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Prepare the entity body handles to use while transferring
107
+ *
108
+ * @param int $concurrency Number of parts to prepare
109
+ *
110
+ * @return array Parts to send
111
+ */
112
+ protected function prepareParts($concurrency)
113
+ {
114
+ $url = $this->source->getUri();
115
+ // Use the source EntityBody as the first part
116
+ $parts = array(new ReadLimitEntityBody($this->source, $this->partSize));
117
+ // Open EntityBody handles for each part to upload in parallel
118
+ for ($i = 1; $i < $concurrency; $i++) {
119
+ $parts[] = new ReadLimitEntityBody(new EntityBody(fopen($url, 'r')), $this->partSize);
120
+ }
121
+
122
+ return $parts;
123
+ }
124
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/SerialTransfer.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Enum\DateFormat;
20
+ use Aws\Common\Enum\Size;
21
+ use Aws\Common\Enum\UaString as Ua;
22
+ use Guzzle\Http\EntityBody;
23
+ use Guzzle\Http\ReadLimitEntityBody;
24
+
25
+ /**
26
+ * Transfers multipart upload parts serially
27
+ */
28
+ class SerialTransfer extends AbstractTransfer
29
+ {
30
+ /**
31
+ * {@inheritdoc}
32
+ */
33
+ protected function transfer()
34
+ {
35
+ while (!$this->stopped && !$this->source->isConsumed()) {
36
+
37
+ if ($this->source->getContentLength() && $this->source->isSeekable()) {
38
+ // If the stream is seekable and the Content-Length known, then stream from the data source
39
+ $body = new ReadLimitEntityBody($this->source, $this->partSize, $this->source->ftell());
40
+ } else {
41
+ // We need to read the data source into a temporary buffer before streaming
42
+ $body = EntityBody::factory();
43
+ while ($body->getContentLength() < $this->partSize
44
+ && $body->write(
45
+ $this->source->read(max(1, min(10 * Size::KB, $this->partSize - $body->getContentLength())))
46
+ ));
47
+ }
48
+
49
+ // @codeCoverageIgnoreStart
50
+ if ($body->getContentLength() == 0) {
51
+ break;
52
+ }
53
+ // @codeCoverageIgnoreEnd
54
+
55
+ $params = $this->state->getUploadId()->toParams();
56
+ $command = $this->client->getCommand('UploadPart', array_replace($params, array(
57
+ 'PartNumber' => count($this->state) + 1,
58
+ 'Body' => $body,
59
+ 'ContentMD5' => (bool) $this->options['part_md5'],
60
+ Ua::OPTION => Ua::MULTIPART_UPLOAD
61
+ )));
62
+
63
+ // Notify observers that the part is about to be uploaded
64
+ $eventData = $this->getEventData();
65
+ $eventData['command'] = $command;
66
+ $this->dispatch(self::BEFORE_PART_UPLOAD, $eventData);
67
+
68
+ // Allow listeners to stop the transfer if needed
69
+ if ($this->stopped) {
70
+ break;
71
+ }
72
+
73
+ $response = $command->getResponse();
74
+
75
+ $this->state->addPart(UploadPart::fromArray(array(
76
+ 'PartNumber' => count($this->state) + 1,
77
+ 'ETag' => $response->getEtag(),
78
+ 'Size' => $body->getContentLength(),
79
+ 'LastModified' => gmdate(DateFormat::RFC2822)
80
+ )));
81
+
82
+ // Notify observers that the part was uploaded
83
+ $this->dispatch(self::AFTER_PART_UPLOAD, $eventData);
84
+ }
85
+ }
86
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/TransferState.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Client\AwsClientInterface;
20
+ use Aws\Common\Model\MultipartUpload\AbstractTransferState;
21
+ use Aws\Common\Model\MultipartUpload\UploadIdInterface;
22
+
23
+ /**
24
+ * State of a multipart upload
25
+ */
26
+ class TransferState extends AbstractTransferState
27
+ {
28
+ /**
29
+ * {@inheritdoc}
30
+ */
31
+ public static function fromUploadId(AwsClientInterface $client, UploadIdInterface $uploadId)
32
+ {
33
+ $transferState = new self($uploadId);
34
+
35
+ foreach ($client->getIterator('ListParts', $uploadId->toParams()) as $part) {
36
+ $transferState->addPart(UploadPart::fromArray($part));
37
+ }
38
+
39
+ return $transferState;
40
+ }
41
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/UploadBuilder.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Enum\UaString as Ua;
20
+ use Aws\Common\Exception\InvalidArgumentException;
21
+ use Aws\Common\Model\MultipartUpload\AbstractUploadBuilder;
22
+ use Aws\S3\Model\Acp;
23
+
24
+ /**
25
+ * Easily create a multipart uploader used to quickly and reliably upload a
26
+ * large file or data stream to Amazon S3 using multipart uploads
27
+ */
28
+ class UploadBuilder extends AbstractUploadBuilder
29
+ {
30
+ /**
31
+ * @var int Concurrency level to transfer the parts
32
+ */
33
+ protected $concurrency = 1;
34
+
35
+ /**
36
+ * @var int Minimum part size to upload
37
+ */
38
+ protected $minPartSize = AbstractTransfer::MIN_PART_SIZE;
39
+
40
+ /**
41
+ * @var string MD5 hash of the entire body to transfer
42
+ */
43
+ protected $md5;
44
+
45
+ /**
46
+ * @var bool Whether or not to calculate the entire MD5 hash of the object
47
+ */
48
+ protected $calculateEntireMd5 = false;
49
+
50
+ /**
51
+ * @var bool Whether or not to calculate MD5 hash of each part
52
+ */
53
+ protected $calculatePartMd5 = true;
54
+
55
+ /**
56
+ * @var array Array of initiate command options
57
+ */
58
+ protected $commandOptions = array();
59
+
60
+ /**
61
+ * @var array Array of transfer options
62
+ */
63
+ protected $transferOptions = array();
64
+
65
+ /**
66
+ * Set the bucket to upload the object to
67
+ *
68
+ * @param string $bucket Name of the bucket
69
+ *
70
+ * @return $this
71
+ */
72
+ public function setBucket($bucket)
73
+ {
74
+ return $this->setOption('Bucket', $bucket);
75
+ }
76
+
77
+ /**
78
+ * Set the key of the object
79
+ *
80
+ * @param string $key Key of the object to upload
81
+ *
82
+ * @return $this
83
+ */
84
+ public function setKey($key)
85
+ {
86
+ return $this->setOption('Key', $key);
87
+ }
88
+
89
+ /**
90
+ * Set the minimum acceptable part size
91
+ *
92
+ * @param int $minSize Minimum acceptable part size in bytes
93
+ *
94
+ * @return $this
95
+ */
96
+ public function setMinPartSize($minSize)
97
+ {
98
+ $this->minPartSize = (int) max((int) $minSize, AbstractTransfer::MIN_PART_SIZE);
99
+
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Set the concurrency level to use when uploading parts. This affects how
105
+ * many parts are uploaded in parallel. You must use a local file as your
106
+ * data source when using a concurrency greater than 1
107
+ *
108
+ * @param int $concurrency Concurrency level
109
+ *
110
+ * @return $this
111
+ */
112
+ public function setConcurrency($concurrency)
113
+ {
114
+ $this->concurrency = $concurrency;
115
+
116
+ return $this;
117
+ }
118
+
119
+ /**
120
+ * Explicitly set the MD5 hash of the entire body
121
+ *
122
+ * @param string $md5 MD5 hash of the entire body
123
+ *
124
+ * @return $this
125
+ */
126
+ public function setMd5($md5)
127
+ {
128
+ $this->md5 = $md5;
129
+
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Set to true to have the builder calculate the MD5 hash of the entire data
135
+ * source before initiating a multipart upload (this could be an expensive
136
+ * operation). This setting can ony be used with seekable data sources.
137
+ *
138
+ * @param bool $calculateMd5 Set to true to calculate the MD5 hash of the body
139
+ *
140
+ * @return $this
141
+ */
142
+ public function calculateMd5($calculateMd5)
143
+ {
144
+ $this->calculateEntireMd5 = (bool) $calculateMd5;
145
+
146
+ return $this;
147
+ }
148
+
149
+ /**
150
+ * Specify whether or not to calculate the MD5 hash of each uploaded part.
151
+ * This setting defaults to true.
152
+ *
153
+ * @param bool $usePartMd5 Set to true to calculate the MD5 has of each part
154
+ *
155
+ * @return $this
156
+ */
157
+ public function calculatePartMd5($usePartMd5)
158
+ {
159
+ $this->calculatePartMd5 = (bool) $usePartMd5;
160
+
161
+ return $this;
162
+ }
163
+
164
+ /**
165
+ * Set the ACP to use on the object
166
+ *
167
+ * @param Acp $acp ACP to set on the object
168
+ *
169
+ * @return $this
170
+ */
171
+ public function setAcp(Acp $acp)
172
+ {
173
+ return $this->setOption('ACP', $acp);
174
+ }
175
+
176
+ /**
177
+ * Set an option to pass to the initial CreateMultipartUpload operation
178
+ *
179
+ * @param string $name Option name
180
+ * @param string $value Option value
181
+ *
182
+ * @return $this
183
+ */
184
+ public function setOption($name, $value)
185
+ {
186
+ $this->commandOptions[$name] = $value;
187
+
188
+ return $this;
189
+ }
190
+
191
+ /**
192
+ * Add an array of options to pass to the initial CreateMultipartUpload operation
193
+ *
194
+ * @param array $options Array of CreateMultipartUpload operation parameters
195
+ *
196
+ * @return $this
197
+ */
198
+ public function addOptions(array $options)
199
+ {
200
+ $this->commandOptions = array_replace($this->commandOptions, $options);
201
+
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Set an array of transfer options to apply to the upload transfer object
207
+ *
208
+ * @param array $options Transfer options
209
+ *
210
+ * @return $this
211
+ */
212
+ public function setTransferOptions(array $options)
213
+ {
214
+ $this->transferOptions = $options;
215
+
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * {@inheritdoc}
221
+ * @throws InvalidArgumentException when attempting to resume a transfer using a non-seekable stream
222
+ * @throws InvalidArgumentException when missing required properties (bucket, key, client, source)
223
+ */
224
+ public function build()
225
+ {
226
+ if ($this->state instanceof TransferState) {
227
+ $this->commandOptions = array_replace($this->commandOptions, $this->state->getUploadId()->toParams());
228
+ }
229
+
230
+ if (!isset($this->commandOptions['Bucket']) || !isset($this->commandOptions['Key'])
231
+ || !$this->client || !$this->source
232
+ ) {
233
+ throw new InvalidArgumentException('You must specify a Bucket, Key, client, and source.');
234
+ }
235
+
236
+ if ($this->state && !$this->source->isSeekable()) {
237
+ throw new InvalidArgumentException('You cannot resume a transfer using a non-seekable source.');
238
+ }
239
+
240
+ // If no state was set, then create one by initiating or loading a multipart upload
241
+ if (is_string($this->state)) {
242
+ $this->state = TransferState::fromUploadId($this->client, UploadId::fromParams(array(
243
+ 'Bucket' => $this->commandOptions['Bucket'],
244
+ 'Key' => $this->commandOptions['Key'],
245
+ 'UploadId' => $this->state
246
+ )));
247
+ } elseif (!$this->state) {
248
+ $this->state = $this->initiateMultipartUpload();
249
+ }
250
+
251
+ $options = array_replace(array(
252
+ 'min_part_size' => $this->minPartSize,
253
+ 'part_md5' => (bool) $this->calculatePartMd5,
254
+ 'concurrency' => $this->concurrency
255
+ ), $this->transferOptions);
256
+
257
+ return $this->concurrency > 1
258
+ ? new ParallelTransfer($this->client, $this->state, $this->source, $options)
259
+ : new SerialTransfer($this->client, $this->state, $this->source, $options);
260
+ }
261
+
262
+ /**
263
+ * {@inheritdoc}
264
+ */
265
+ protected function initiateMultipartUpload()
266
+ {
267
+ // Determine Content-Type
268
+ if (!isset($this->commandOptions['ContentType'])) {
269
+ if ($mimeType = $this->source->getContentType()) {
270
+ $this->commandOptions['ContentType'] = $mimeType;
271
+ }
272
+ }
273
+
274
+ $params = array_replace(array(
275
+ Ua::OPTION => Ua::MULTIPART_UPLOAD,
276
+ 'command.headers' => $this->headers,
277
+ 'Metadata' => array()
278
+ ), $this->commandOptions);
279
+
280
+ // Calculate the MD5 hash if none was set and it is asked of the builder
281
+ if ($this->calculateEntireMd5) {
282
+ $this->md5 = $this->source->getContentMd5();
283
+ }
284
+
285
+ // If an MD5 is specified, then add it to the custom headers of the request
286
+ // so that it will be returned when downloading the object from Amazon S3
287
+ if ($this->md5) {
288
+ $params['Metadata']['x-amz-Content-MD5'] = $this->md5;
289
+ }
290
+
291
+ $result = $this->client->getCommand('CreateMultipartUpload', $params)->execute();
292
+ // Create a new state based on the initiated upload
293
+ $params['UploadId'] = $result['UploadId'];
294
+
295
+ return new TransferState(UploadId::fromParams($params));
296
+ }
297
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/UploadId.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Model\MultipartUpload\AbstractUploadId;
20
+
21
+ /**
22
+ * An object that encapsulates the identification for a Glacier upload part
23
+ * @codeCoverageIgnore
24
+ */
25
+ class UploadId extends AbstractUploadId
26
+ {
27
+ /**
28
+ * {@inheritdoc}
29
+ */
30
+ protected static $expectedValues = array(
31
+ 'Bucket' => false,
32
+ 'Key' => false,
33
+ 'UploadId' => false
34
+ );
35
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/MultipartUpload/UploadPart.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model\MultipartUpload;
18
+
19
+ use Aws\Common\Model\MultipartUpload\AbstractUploadPart;
20
+
21
+ /**
22
+ * An object that encapsulates the data for a Glacier upload operation
23
+ */
24
+ class UploadPart extends AbstractUploadPart
25
+ {
26
+ /**
27
+ * {@inheritdoc}
28
+ */
29
+ protected static $keyMap = array(
30
+ 'PartNumber' => 'partNumber',
31
+ 'ETag' => 'eTag',
32
+ 'LastModified' => 'lastModified',
33
+ 'Size' => 'size'
34
+ );
35
+
36
+ /**
37
+ * @var string The ETag for this part
38
+ */
39
+ protected $eTag;
40
+
41
+ /**
42
+ * @var string The last modified date
43
+ */
44
+ protected $lastModified;
45
+
46
+ /**
47
+ * @var int The size (or content-length) in bytes of the upload body
48
+ */
49
+ protected $size;
50
+
51
+ /**
52
+ * @return string
53
+ */
54
+ public function getETag()
55
+ {
56
+ return $this->eTag;
57
+ }
58
+
59
+ /**
60
+ * @return string
61
+ */
62
+ public function getLastModified()
63
+ {
64
+ return $this->lastModified;
65
+ }
66
+
67
+ /**
68
+ * @return int
69
+ */
70
+ public function getSize()
71
+ {
72
+ return $this->size;
73
+ }
74
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Model/PostObject.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Model;
18
+
19
+ use Aws\Common\Enum\DateFormat;
20
+ use Aws\S3\S3Client;
21
+ use Guzzle\Common\Collection;
22
+ use Guzzle\Http\Url;
23
+
24
+ /**
25
+ * Encapsulates the logic for getting the data for an S3 object POST upload form
26
+ */
27
+ class PostObject extends Collection
28
+ {
29
+ /**
30
+ * @var S3Client The S3 client being used to sign the policy
31
+ */
32
+ protected $client;
33
+
34
+ /**
35
+ * @var string The bucket name where the object will be posted
36
+ */
37
+ protected $bucket;
38
+
39
+ /**
40
+ * @var array The <form> tag attributes as an array
41
+ */
42
+ protected $formAttributes;
43
+
44
+ /**
45
+ * @var array The form's <input> elements as an array
46
+ */
47
+ protected $formInputs;
48
+
49
+ /**
50
+ * @var string The raw json policy
51
+ */
52
+ protected $jsonPolicy;
53
+
54
+ /**
55
+ * Constructs the PostObject
56
+ *
57
+ * The options array accepts the following keys:
58
+ *
59
+ * - acl: The access control setting to apply to the uploaded file. Accepts any of the
60
+ * CannedAcl constants
61
+ * - Cache-Control: The Cache-Control HTTP header value to apply to the uploaded file
62
+ * - Content-Disposition: The Content-Disposition HTTP header value to apply to the uploaded file
63
+ * - Content-Encoding: The Content-Encoding HTTP header value to apply to the uploaded file
64
+ * - Content-Type: The Content-Type HTTP header value to apply to the uploaded file. The default
65
+ * value is `application/octet-stream`
66
+ * - Expires: The Expires HTTP header value to apply to the uploaded file
67
+ * - key: The location where the file should be uploaded to. The default value is
68
+ * `^${filename}` which will use the name of the uploaded file
69
+ * - policy: A raw policy in JSON format. By default, the PostObject creates one for you
70
+ * - policy_callback: A callback used to modify the policy before encoding and signing it. The
71
+ * method signature for the callback should accept an array of the policy data as
72
+ * the 1st argument, (optionally) the PostObject as the 2nd argument, and return
73
+ * the policy data with the desired modifications.
74
+ * - success_action_redirect: The URI for Amazon S3 to redirect to upon successful upload
75
+ * - success_action_status: The status code for Amazon S3 to return upon successful upload
76
+ * - ttd: The expiration time for the generated upload form data
77
+ * - x-amz-meta-*: Any custom meta tag that should be set to the object
78
+ * - x-amz-server-side-encryption: The server-side encryption mechanism to use
79
+ * - x-amz-storage-class: The storage setting to apply to the object
80
+ * - x-amz-server-side​-encryption​-customer-algorithm: The SSE-C algorithm
81
+ * - x-amz-server-side​-encryption​-customer-key: The SSE-C customer secret key
82
+ * - x-amz-server-side​-encryption​-customer-key-MD5: The MD5 hash of the SSE-C customer secret key
83
+ *
84
+ * For the Cache-Control, Content-Disposition, Content-Encoding,
85
+ * Content-Type, Expires, and key options, to use a "starts-with" comparison
86
+ * instead of an equals comparison, prefix the value with a ^ (carat)
87
+ * character
88
+ *
89
+ * @param S3Client $client
90
+ * @param $bucket
91
+ * @param array $options
92
+ */
93
+ public function __construct(S3Client $client, $bucket, array $options = array())
94
+ {
95
+ $this->setClient($client);
96
+ $this->setBucket($bucket);
97
+ parent::__construct($options);
98
+ }
99
+
100
+ /**
101
+ * Analyzes the provided data and turns it into useful data that can be
102
+ * consumed and used to build an upload form
103
+ *
104
+ * @return PostObject
105
+ */
106
+ public function prepareData()
107
+ {
108
+ // Validate required options
109
+ $options = Collection::fromConfig($this->data, array(
110
+ 'ttd' => '+1 hour',
111
+ 'key' => '^${filename}',
112
+ ));
113
+
114
+ // Format ttd option
115
+ $ttd = $options['ttd'];
116
+ $ttd = is_numeric($ttd) ? (int) $ttd : strtotime($ttd);
117
+ unset($options['ttd']);
118
+
119
+ // If a policy or policy callback were provided, extract those from the options
120
+ $rawJsonPolicy = $options['policy'];
121
+ $policyCallback = $options['policy_callback'];
122
+ unset($options['policy'], $options['policy_callback']);
123
+
124
+ // Setup policy document
125
+ $policy = array(
126
+ 'expiration' => gmdate(DateFormat::ISO8601_S3, $ttd),
127
+ 'conditions' => array(array('bucket' => $this->bucket))
128
+ );
129
+
130
+ // Configure the endpoint/action
131
+ $url = Url::factory($this->client->getBaseUrl());
132
+ if ($url->getScheme() === 'https' && strpos($this->bucket, '.') !== false) {
133
+ // Use path-style URLs
134
+ $url->setPath($this->bucket);
135
+ } else {
136
+ // Use virtual-style URLs
137
+ $url->setHost($this->bucket . '.' . $url->getHost());
138
+ }
139
+
140
+ // Setup basic form
141
+ $this->formAttributes = array(
142
+ 'action' => (string) $url,
143
+ 'method' => 'POST',
144
+ 'enctype' => 'multipart/form-data'
145
+ );
146
+ $this->formInputs = array(
147
+ 'AWSAccessKeyId' => $this->client->getCredentials()->getAccessKeyId()
148
+ );
149
+
150
+ // Add success action status
151
+ $status = (int) $options->get('success_action_status');
152
+ if ($status && in_array($status, array(200, 201, 204))) {
153
+ $this->formInputs['success_action_status'] = (string) $status;
154
+ $policy['conditions'][] = array(
155
+ 'success_action_status' => (string) $status
156
+ );
157
+ unset($options['success_action_status']);
158
+ }
159
+
160
+ // Add other options
161
+ foreach ($options as $key => $value) {
162
+ $value = (string) $value;
163
+ if ($value[0] === '^') {
164
+ $value = substr($value, 1);
165
+ $this->formInputs[$key] = $value;
166
+ $value = preg_replace('/\$\{(\w*)\}/', '', $value);
167
+ $policy['conditions'][] = array('starts-with', '$' . $key, $value);
168
+ } else {
169
+ $this->formInputs[$key] = $value;
170
+ $policy['conditions'][] = array($key => $value);
171
+ }
172
+ }
173
+
174
+ // Handle the policy
175
+ $policy = is_callable($policyCallback) ? $policyCallback($policy, $this) : $policy;
176
+ $this->jsonPolicy = $rawJsonPolicy ?: json_encode($policy);
177
+ $this->applyPolicy();
178
+
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * Sets the S3 client
184
+ *
185
+ * @param S3Client $client
186
+ *
187
+ * @return PostObject
188
+ */
189
+ public function setClient(S3Client $client)
190
+ {
191
+ $this->client = $client;
192
+
193
+ return $this;
194
+ }
195
+
196
+ /**
197
+ * Gets the S3 client
198
+ *
199
+ * @return S3Client
200
+ */
201
+ public function getClient()
202
+ {
203
+ return $this->client;
204
+ }
205
+
206
+ /**
207
+ * Sets the bucket and makes sure it is a valid bucket name
208
+ *
209
+ * @param string $bucket
210
+ *
211
+ * @return PostObject
212
+ */
213
+ public function setBucket($bucket)
214
+ {
215
+ $this->bucket = $bucket;
216
+
217
+ return $this;
218
+ }
219
+
220
+ /**
221
+ * Gets the bucket name
222
+ *
223
+ * @return string
224
+ */
225
+ public function getBucket()
226
+ {
227
+ return $this->bucket;
228
+ }
229
+
230
+ /**
231
+ * Gets the form attributes as an array
232
+ *
233
+ * @return array
234
+ */
235
+ public function getFormAttributes()
236
+ {
237
+ return $this->formAttributes;
238
+ }
239
+
240
+ /**
241
+ * Gets the form inputs as an array
242
+ *
243
+ * @return array
244
+ */
245
+ public function getFormInputs()
246
+ {
247
+ return $this->formInputs;
248
+ }
249
+
250
+ /**
251
+ * Gets the raw JSON policy
252
+ *
253
+ * @return string
254
+ */
255
+ public function getJsonPolicy()
256
+ {
257
+ return $this->jsonPolicy;
258
+ }
259
+
260
+ /**
261
+ * Handles the encoding, singing, and injecting of the policy
262
+ */
263
+ protected function applyPolicy()
264
+ {
265
+ $jsonPolicy64 = base64_encode($this->jsonPolicy);
266
+ $this->formInputs['policy'] = $jsonPolicy64;
267
+
268
+ $this->formInputs['signature'] = base64_encode(hash_hmac(
269
+ 'sha1',
270
+ $jsonPolicy64,
271
+ $this->client->getCredentials()->getSecretKey(),
272
+ true
273
+ ));
274
+ }
275
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Resources/s3-2006-03-01.php ADDED
@@ -0,0 +1,5022 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ return array (
18
+ 'apiVersion' => '2006-03-01',
19
+ 'endpointPrefix' => 's3',
20
+ 'serviceFullName' => 'Amazon Simple Storage Service',
21
+ 'serviceAbbreviation' => 'Amazon S3',
22
+ 'serviceType' => 'rest-xml',
23
+ 'timestampFormat' => 'rfc822',
24
+ 'globalEndpoint' => 's3.amazonaws.com',
25
+ 'signatureVersion' => 's3',
26
+ 'namespace' => 'S3',
27
+ 'regions' => array(
28
+ 'us-east-1' => array(
29
+ 'http' => true,
30
+ 'https' => true,
31
+ 'hostname' => 's3.amazonaws.com',
32
+ ),
33
+ 'us-west-1' => array(
34
+ 'http' => true,
35
+ 'https' => true,
36
+ 'hostname' => 's3-us-west-1.amazonaws.com',
37
+ ),
38
+ 'us-west-2' => array(
39
+ 'http' => true,
40
+ 'https' => true,
41
+ 'hostname' => 's3-us-west-2.amazonaws.com',
42
+ ),
43
+ 'eu-west-1' => array(
44
+ 'http' => true,
45
+ 'https' => true,
46
+ 'hostname' => 's3-eu-west-1.amazonaws.com',
47
+ ),
48
+ 'eu-central-1' => array(
49
+ 'http' => true,
50
+ 'https' => true,
51
+ 'hostname' => 's3-eu-central-1.amazonaws.com',
52
+ ),
53
+ 'ap-northeast-1' => array(
54
+ 'http' => true,
55
+ 'https' => true,
56
+ 'hostname' => 's3-ap-northeast-1.amazonaws.com',
57
+ ),
58
+ 'ap-southeast-1' => array(
59
+ 'http' => true,
60
+ 'https' => true,
61
+ 'hostname' => 's3-ap-southeast-1.amazonaws.com',
62
+ ),
63
+ 'ap-southeast-2' => array(
64
+ 'http' => true,
65
+ 'https' => true,
66
+ 'hostname' => 's3-ap-southeast-2.amazonaws.com',
67
+ ),
68
+ 'sa-east-1' => array(
69
+ 'http' => true,
70
+ 'https' => true,
71
+ 'hostname' => 's3-sa-east-1.amazonaws.com',
72
+ ),
73
+ 'cn-north-1' => array(
74
+ 'http' => true,
75
+ 'https' => true,
76
+ 'hostname' => 's3.cn-north-1.amazonaws.com.cn',
77
+ ),
78
+ 'us-gov-west-1' => array(
79
+ 'http' => true,
80
+ 'https' => true,
81
+ 'hostname' => 's3-us-gov-west-1.amazonaws.com',
82
+ ),
83
+ ),
84
+ 'operations' => array(
85
+ 'AbortMultipartUpload' => array(
86
+ 'httpMethod' => 'DELETE',
87
+ 'uri' => '/{Bucket}{/Key*}',
88
+ 'class' => 'Aws\\S3\\Command\\S3Command',
89
+ 'responseClass' => 'AbortMultipartUploadOutput',
90
+ 'responseType' => 'model',
91
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadAbort.html',
92
+ 'parameters' => array(
93
+ 'Bucket' => array(
94
+ 'required' => true,
95
+ 'type' => 'string',
96
+ 'location' => 'uri',
97
+ ),
98
+ 'Key' => array(
99
+ 'required' => true,
100
+ 'type' => 'string',
101
+ 'location' => 'uri',
102
+ 'filters' => array(
103
+ 'Aws\\S3\\S3Client::explodeKey',
104
+ ),
105
+ ),
106
+ 'UploadId' => array(
107
+ 'required' => true,
108
+ 'type' => 'string',
109
+ 'location' => 'query',
110
+ 'sentAs' => 'uploadId',
111
+ ),
112
+ 'RequestPayer' => array(
113
+ 'type' => 'string',
114
+ 'location' => 'header',
115
+ 'sentAs' => 'x-amz-request-payer',
116
+ ),
117
+ ),
118
+ 'errorResponses' => array(
119
+ array(
120
+ 'reason' => 'The specified multipart upload does not exist.',
121
+ 'class' => 'NoSuchUploadException',
122
+ ),
123
+ ),
124
+ ),
125
+ 'CompleteMultipartUpload' => array(
126
+ 'httpMethod' => 'POST',
127
+ 'uri' => '/{Bucket}{/Key*}',
128
+ 'class' => 'Aws\\S3\\Command\\S3Command',
129
+ 'responseClass' => 'CompleteMultipartUploadOutput',
130
+ 'responseType' => 'model',
131
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadComplete.html',
132
+ 'data' => array(
133
+ 'xmlRoot' => array(
134
+ 'name' => 'CompleteMultipartUpload',
135
+ 'namespaces' => array(
136
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
137
+ ),
138
+ ),
139
+ ),
140
+ 'parameters' => array(
141
+ 'Bucket' => array(
142
+ 'required' => true,
143
+ 'type' => 'string',
144
+ 'location' => 'uri',
145
+ ),
146
+ 'Key' => array(
147
+ 'required' => true,
148
+ 'type' => 'string',
149
+ 'location' => 'uri',
150
+ 'filters' => array(
151
+ 'Aws\\S3\\S3Client::explodeKey',
152
+ ),
153
+ ),
154
+ 'Parts' => array(
155
+ 'type' => 'array',
156
+ 'location' => 'xml',
157
+ 'data' => array(
158
+ 'xmlFlattened' => true,
159
+ ),
160
+ 'items' => array(
161
+ 'name' => 'CompletedPart',
162
+ 'type' => 'object',
163
+ 'sentAs' => 'Part',
164
+ 'properties' => array(
165
+ 'ETag' => array(
166
+ 'type' => 'string',
167
+ ),
168
+ 'PartNumber' => array(
169
+ 'type' => 'numeric',
170
+ ),
171
+ ),
172
+ ),
173
+ ),
174
+ 'UploadId' => array(
175
+ 'required' => true,
176
+ 'type' => 'string',
177
+ 'location' => 'query',
178
+ 'sentAs' => 'uploadId',
179
+ ),
180
+ 'RequestPayer' => array(
181
+ 'type' => 'string',
182
+ 'location' => 'header',
183
+ 'sentAs' => 'x-amz-request-payer',
184
+ ),
185
+ 'command.expects' => array(
186
+ 'static' => true,
187
+ 'default' => 'application/xml',
188
+ ),
189
+ ),
190
+ ),
191
+ 'CopyObject' => array(
192
+ 'httpMethod' => 'PUT',
193
+ 'uri' => '/{Bucket}{/Key*}',
194
+ 'class' => 'Aws\\S3\\Command\\S3Command',
195
+ 'responseClass' => 'CopyObjectOutput',
196
+ 'responseType' => 'model',
197
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html',
198
+ 'data' => array(
199
+ 'xmlRoot' => array(
200
+ 'name' => 'CopyObjectRequest',
201
+ 'namespaces' => array(
202
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
203
+ ),
204
+ ),
205
+ ),
206
+ 'parameters' => array(
207
+ 'ACL' => array(
208
+ 'type' => 'string',
209
+ 'location' => 'header',
210
+ 'sentAs' => 'x-amz-acl',
211
+ ),
212
+ 'Bucket' => array(
213
+ 'required' => true,
214
+ 'type' => 'string',
215
+ 'location' => 'uri',
216
+ ),
217
+ 'CacheControl' => array(
218
+ 'type' => 'string',
219
+ 'location' => 'header',
220
+ 'sentAs' => 'Cache-Control',
221
+ ),
222
+ 'ContentDisposition' => array(
223
+ 'type' => 'string',
224
+ 'location' => 'header',
225
+ 'sentAs' => 'Content-Disposition',
226
+ ),
227
+ 'ContentEncoding' => array(
228
+ 'type' => 'string',
229
+ 'location' => 'header',
230
+ 'sentAs' => 'Content-Encoding',
231
+ ),
232
+ 'ContentLanguage' => array(
233
+ 'type' => 'string',
234
+ 'location' => 'header',
235
+ 'sentAs' => 'Content-Language',
236
+ ),
237
+ 'ContentType' => array(
238
+ 'type' => 'string',
239
+ 'location' => 'header',
240
+ 'sentAs' => 'Content-Type',
241
+ ),
242
+ 'CopySource' => array(
243
+ 'required' => true,
244
+ 'type' => 'string',
245
+ 'location' => 'header',
246
+ 'sentAs' => 'x-amz-copy-source',
247
+ ),
248
+ 'CopySourceIfMatch' => array(
249
+ 'type' => 'string',
250
+ 'location' => 'header',
251
+ 'sentAs' => 'x-amz-copy-source-if-match',
252
+ ),
253
+ 'CopySourceIfModifiedSince' => array(
254
+ 'type' => array(
255
+ 'object',
256
+ 'string',
257
+ 'integer',
258
+ ),
259
+ 'format' => 'date-time-http',
260
+ 'location' => 'header',
261
+ 'sentAs' => 'x-amz-copy-source-if-modified-since',
262
+ ),
263
+ 'CopySourceIfNoneMatch' => array(
264
+ 'type' => 'string',
265
+ 'location' => 'header',
266
+ 'sentAs' => 'x-amz-copy-source-if-none-match',
267
+ ),
268
+ 'CopySourceIfUnmodifiedSince' => array(
269
+ 'type' => array(
270
+ 'object',
271
+ 'string',
272
+ 'integer',
273
+ ),
274
+ 'format' => 'date-time-http',
275
+ 'location' => 'header',
276
+ 'sentAs' => 'x-amz-copy-source-if-unmodified-since',
277
+ ),
278
+ 'Expires' => array(
279
+ 'type' => array(
280
+ 'object',
281
+ 'string',
282
+ 'integer',
283
+ ),
284
+ 'format' => 'date-time-http',
285
+ 'location' => 'header',
286
+ ),
287
+ 'GrantFullControl' => array(
288
+ 'type' => 'string',
289
+ 'location' => 'header',
290
+ 'sentAs' => 'x-amz-grant-full-control',
291
+ ),
292
+ 'GrantRead' => array(
293
+ 'type' => 'string',
294
+ 'location' => 'header',
295
+ 'sentAs' => 'x-amz-grant-read',
296
+ ),
297
+ 'GrantReadACP' => array(
298
+ 'type' => 'string',
299
+ 'location' => 'header',
300
+ 'sentAs' => 'x-amz-grant-read-acp',
301
+ ),
302
+ 'GrantWriteACP' => array(
303
+ 'type' => 'string',
304
+ 'location' => 'header',
305
+ 'sentAs' => 'x-amz-grant-write-acp',
306
+ ),
307
+ 'Key' => array(
308
+ 'required' => true,
309
+ 'type' => 'string',
310
+ 'location' => 'uri',
311
+ 'filters' => array(
312
+ 'Aws\\S3\\S3Client::explodeKey',
313
+ ),
314
+ ),
315
+ 'Metadata' => array(
316
+ 'type' => 'object',
317
+ 'location' => 'header',
318
+ 'sentAs' => 'x-amz-meta-',
319
+ 'additionalProperties' => array(
320
+ 'type' => 'string',
321
+ ),
322
+ ),
323
+ 'MetadataDirective' => array(
324
+ 'type' => 'string',
325
+ 'location' => 'header',
326
+ 'sentAs' => 'x-amz-metadata-directive',
327
+ ),
328
+ 'ServerSideEncryption' => array(
329
+ 'type' => 'string',
330
+ 'location' => 'header',
331
+ 'sentAs' => 'x-amz-server-side-encryption',
332
+ ),
333
+ 'StorageClass' => array(
334
+ 'type' => 'string',
335
+ 'location' => 'header',
336
+ 'sentAs' => 'x-amz-storage-class',
337
+ ),
338
+ 'WebsiteRedirectLocation' => array(
339
+ 'type' => 'string',
340
+ 'location' => 'header',
341
+ 'sentAs' => 'x-amz-website-redirect-location',
342
+ ),
343
+ 'SSECustomerAlgorithm' => array(
344
+ 'type' => 'string',
345
+ 'location' => 'header',
346
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
347
+ ),
348
+ 'SSECustomerKey' => array(
349
+ 'type' => 'string',
350
+ 'location' => 'header',
351
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key',
352
+ ),
353
+ 'SSECustomerKeyMD5' => array(
354
+ 'type' => 'string',
355
+ 'location' => 'header',
356
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
357
+ ),
358
+ 'SSEKMSKeyId' => array(
359
+ 'type' => 'string',
360
+ 'location' => 'header',
361
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
362
+ ),
363
+ 'CopySourceSSECustomerAlgorithm' => array(
364
+ 'type' => 'string',
365
+ 'location' => 'header',
366
+ 'sentAs' => 'x-amz-copy-source-server-side-encryption-customer-algorithm',
367
+ ),
368
+ 'CopySourceSSECustomerKey' => array(
369
+ 'type' => 'string',
370
+ 'location' => 'header',
371
+ 'sentAs' => 'x-amz-copy-source-server-side-encryption-customer-key',
372
+ ),
373
+ 'CopySourceSSECustomerKeyMD5' => array(
374
+ 'type' => 'string',
375
+ 'location' => 'header',
376
+ 'sentAs' => 'x-amz-copy-source-server-side-encryption-customer-key-MD5',
377
+ ),
378
+ 'RequestPayer' => array(
379
+ 'type' => 'string',
380
+ 'location' => 'header',
381
+ 'sentAs' => 'x-amz-request-payer',
382
+ ),
383
+ 'ACP' => array(
384
+ 'type' => 'object',
385
+ 'additionalProperties' => true,
386
+ ),
387
+ 'command.expects' => array(
388
+ 'static' => true,
389
+ 'default' => 'application/xml',
390
+ ),
391
+ ),
392
+ 'errorResponses' => array(
393
+ array(
394
+ 'reason' => 'The source object of the COPY operation is not in the active tier and is only stored in Amazon Glacier.',
395
+ 'class' => 'ObjectNotInActiveTierErrorException',
396
+ ),
397
+ ),
398
+ ),
399
+ 'CreateBucket' => array(
400
+ 'httpMethod' => 'PUT',
401
+ 'uri' => '/{Bucket}',
402
+ 'class' => 'Aws\\S3\\Command\\S3Command',
403
+ 'responseClass' => 'CreateBucketOutput',
404
+ 'responseType' => 'model',
405
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUT.html',
406
+ 'data' => array(
407
+ 'xmlRoot' => array(
408
+ 'name' => 'CreateBucketConfiguration',
409
+ 'namespaces' => array(
410
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
411
+ ),
412
+ ),
413
+ ),
414
+ 'parameters' => array(
415
+ 'ACL' => array(
416
+ 'type' => 'string',
417
+ 'location' => 'header',
418
+ 'sentAs' => 'x-amz-acl',
419
+ ),
420
+ 'Bucket' => array(
421
+ 'required' => true,
422
+ 'type' => 'string',
423
+ 'location' => 'uri',
424
+ ),
425
+ 'LocationConstraint' => array(
426
+ 'type' => 'string',
427
+ 'location' => 'xml',
428
+ ),
429
+ 'GrantFullControl' => array(
430
+ 'type' => 'string',
431
+ 'location' => 'header',
432
+ 'sentAs' => 'x-amz-grant-full-control',
433
+ ),
434
+ 'GrantRead' => array(
435
+ 'type' => 'string',
436
+ 'location' => 'header',
437
+ 'sentAs' => 'x-amz-grant-read',
438
+ ),
439
+ 'GrantReadACP' => array(
440
+ 'type' => 'string',
441
+ 'location' => 'header',
442
+ 'sentAs' => 'x-amz-grant-read-acp',
443
+ ),
444
+ 'GrantWrite' => array(
445
+ 'type' => 'string',
446
+ 'location' => 'header',
447
+ 'sentAs' => 'x-amz-grant-write',
448
+ ),
449
+ 'GrantWriteACP' => array(
450
+ 'type' => 'string',
451
+ 'location' => 'header',
452
+ 'sentAs' => 'x-amz-grant-write-acp',
453
+ ),
454
+ 'ACP' => array(
455
+ 'type' => 'object',
456
+ 'additionalProperties' => true,
457
+ ),
458
+ ),
459
+ 'errorResponses' => array(
460
+ array(
461
+ 'reason' => 'The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.',
462
+ 'class' => 'BucketAlreadyExistsException',
463
+ ),
464
+ ),
465
+ ),
466
+ 'CreateMultipartUpload' => array(
467
+ 'httpMethod' => 'POST',
468
+ 'uri' => '/{Bucket}{/Key*}?uploads',
469
+ 'class' => 'Aws\\S3\\Command\\S3Command',
470
+ 'responseClass' => 'CreateMultipartUploadOutput',
471
+ 'responseType' => 'model',
472
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadInitiate.html',
473
+ 'data' => array(
474
+ 'xmlRoot' => array(
475
+ 'name' => 'CreateMultipartUploadRequest',
476
+ 'namespaces' => array(
477
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
478
+ ),
479
+ ),
480
+ ),
481
+ 'parameters' => array(
482
+ 'ACL' => array(
483
+ 'type' => 'string',
484
+ 'location' => 'header',
485
+ 'sentAs' => 'x-amz-acl',
486
+ ),
487
+ 'Bucket' => array(
488
+ 'required' => true,
489
+ 'type' => 'string',
490
+ 'location' => 'uri',
491
+ ),
492
+ 'CacheControl' => array(
493
+ 'type' => 'string',
494
+ 'location' => 'header',
495
+ 'sentAs' => 'Cache-Control',
496
+ ),
497
+ 'ContentDisposition' => array(
498
+ 'type' => 'string',
499
+ 'location' => 'header',
500
+ 'sentAs' => 'Content-Disposition',
501
+ ),
502
+ 'ContentEncoding' => array(
503
+ 'type' => 'string',
504
+ 'location' => 'header',
505
+ 'sentAs' => 'Content-Encoding',
506
+ ),
507
+ 'ContentLanguage' => array(
508
+ 'type' => 'string',
509
+ 'location' => 'header',
510
+ 'sentAs' => 'Content-Language',
511
+ ),
512
+ 'ContentType' => array(
513
+ 'type' => 'string',
514
+ 'location' => 'header',
515
+ 'sentAs' => 'Content-Type',
516
+ ),
517
+ 'Expires' => array(
518
+ 'type' => array(
519
+ 'object',
520
+ 'string',
521
+ 'integer',
522
+ ),
523
+ 'format' => 'date-time-http',
524
+ 'location' => 'header',
525
+ ),
526
+ 'GrantFullControl' => array(
527
+ 'type' => 'string',
528
+ 'location' => 'header',
529
+ 'sentAs' => 'x-amz-grant-full-control',
530
+ ),
531
+ 'GrantRead' => array(
532
+ 'type' => 'string',
533
+ 'location' => 'header',
534
+ 'sentAs' => 'x-amz-grant-read',
535
+ ),
536
+ 'GrantReadACP' => array(
537
+ 'type' => 'string',
538
+ 'location' => 'header',
539
+ 'sentAs' => 'x-amz-grant-read-acp',
540
+ ),
541
+ 'GrantWriteACP' => array(
542
+ 'type' => 'string',
543
+ 'location' => 'header',
544
+ 'sentAs' => 'x-amz-grant-write-acp',
545
+ ),
546
+ 'Key' => array(
547
+ 'required' => true,
548
+ 'type' => 'string',
549
+ 'location' => 'uri',
550
+ 'filters' => array(
551
+ 'Aws\\S3\\S3Client::explodeKey',
552
+ ),
553
+ ),
554
+ 'Metadata' => array(
555
+ 'type' => 'object',
556
+ 'location' => 'header',
557
+ 'sentAs' => 'x-amz-meta-',
558
+ 'additionalProperties' => array(
559
+ 'type' => 'string',
560
+ ),
561
+ ),
562
+ 'ServerSideEncryption' => array(
563
+ 'type' => 'string',
564
+ 'location' => 'header',
565
+ 'sentAs' => 'x-amz-server-side-encryption',
566
+ ),
567
+ 'StorageClass' => array(
568
+ 'type' => 'string',
569
+ 'location' => 'header',
570
+ 'sentAs' => 'x-amz-storage-class',
571
+ ),
572
+ 'WebsiteRedirectLocation' => array(
573
+ 'type' => 'string',
574
+ 'location' => 'header',
575
+ 'sentAs' => 'x-amz-website-redirect-location',
576
+ ),
577
+ 'SSECustomerAlgorithm' => array(
578
+ 'type' => 'string',
579
+ 'location' => 'header',
580
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
581
+ ),
582
+ 'SSECustomerKey' => array(
583
+ 'type' => 'string',
584
+ 'location' => 'header',
585
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key',
586
+ ),
587
+ 'SSECustomerKeyMD5' => array(
588
+ 'type' => 'string',
589
+ 'location' => 'header',
590
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
591
+ ),
592
+ 'SSEKMSKeyId' => array(
593
+ 'type' => 'string',
594
+ 'location' => 'header',
595
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
596
+ ),
597
+ 'RequestPayer' => array(
598
+ 'type' => 'string',
599
+ 'location' => 'header',
600
+ 'sentAs' => 'x-amz-request-payer',
601
+ ),
602
+ 'ACP' => array(
603
+ 'type' => 'object',
604
+ 'additionalProperties' => true,
605
+ ),
606
+ 'command.expects' => array(
607
+ 'static' => true,
608
+ 'default' => 'application/xml',
609
+ ),
610
+ ),
611
+ ),
612
+ 'DeleteBucket' => array(
613
+ 'httpMethod' => 'DELETE',
614
+ 'uri' => '/{Bucket}',
615
+ 'class' => 'Aws\\S3\\Command\\S3Command',
616
+ 'responseClass' => 'DeleteBucketOutput',
617
+ 'responseType' => 'model',
618
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETE.html',
619
+ 'parameters' => array(
620
+ 'Bucket' => array(
621
+ 'required' => true,
622
+ 'type' => 'string',
623
+ 'location' => 'uri',
624
+ ),
625
+ ),
626
+ ),
627
+ 'DeleteBucketCors' => array(
628
+ 'httpMethod' => 'DELETE',
629
+ 'uri' => '/{Bucket}?cors',
630
+ 'class' => 'Aws\\S3\\Command\\S3Command',
631
+ 'responseClass' => 'DeleteBucketCorsOutput',
632
+ 'responseType' => 'model',
633
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETEcors.html',
634
+ 'parameters' => array(
635
+ 'Bucket' => array(
636
+ 'required' => true,
637
+ 'type' => 'string',
638
+ 'location' => 'uri',
639
+ ),
640
+ ),
641
+ ),
642
+ 'DeleteBucketLifecycle' => array(
643
+ 'httpMethod' => 'DELETE',
644
+ 'uri' => '/{Bucket}?lifecycle',
645
+ 'class' => 'Aws\\S3\\Command\\S3Command',
646
+ 'responseClass' => 'DeleteBucketLifecycleOutput',
647
+ 'responseType' => 'model',
648
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETElifecycle.html',
649
+ 'parameters' => array(
650
+ 'Bucket' => array(
651
+ 'required' => true,
652
+ 'type' => 'string',
653
+ 'location' => 'uri',
654
+ ),
655
+ ),
656
+ ),
657
+ 'DeleteBucketPolicy' => array(
658
+ 'httpMethod' => 'DELETE',
659
+ 'uri' => '/{Bucket}?policy',
660
+ 'class' => 'Aws\\S3\\Command\\S3Command',
661
+ 'responseClass' => 'DeleteBucketPolicyOutput',
662
+ 'responseType' => 'model',
663
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETEpolicy.html',
664
+ 'parameters' => array(
665
+ 'Bucket' => array(
666
+ 'required' => true,
667
+ 'type' => 'string',
668
+ 'location' => 'uri',
669
+ ),
670
+ ),
671
+ ),
672
+ 'DeleteBucketReplication' => array(
673
+ 'httpMethod' => 'DELETE',
674
+ 'uri' => '/{Bucket}?replication',
675
+ 'class' => 'Aws\\S3\\Command\\S3Command',
676
+ 'responseClass' => 'DeleteBucketReplicationOutput',
677
+ 'responseType' => 'model',
678
+ 'parameters' => array(
679
+ 'Bucket' => array(
680
+ 'required' => true,
681
+ 'type' => 'string',
682
+ 'location' => 'uri',
683
+ ),
684
+ ),
685
+ ),
686
+ 'DeleteBucketTagging' => array(
687
+ 'httpMethod' => 'DELETE',
688
+ 'uri' => '/{Bucket}?tagging',
689
+ 'class' => 'Aws\\S3\\Command\\S3Command',
690
+ 'responseClass' => 'DeleteBucketTaggingOutput',
691
+ 'responseType' => 'model',
692
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETEtagging.html',
693
+ 'parameters' => array(
694
+ 'Bucket' => array(
695
+ 'required' => true,
696
+ 'type' => 'string',
697
+ 'location' => 'uri',
698
+ ),
699
+ ),
700
+ ),
701
+ 'DeleteBucketWebsite' => array(
702
+ 'httpMethod' => 'DELETE',
703
+ 'uri' => '/{Bucket}?website',
704
+ 'class' => 'Aws\\S3\\Command\\S3Command',
705
+ 'responseClass' => 'DeleteBucketWebsiteOutput',
706
+ 'responseType' => 'model',
707
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETEwebsite.html',
708
+ 'parameters' => array(
709
+ 'Bucket' => array(
710
+ 'required' => true,
711
+ 'type' => 'string',
712
+ 'location' => 'uri',
713
+ ),
714
+ ),
715
+ ),
716
+ 'DeleteObject' => array(
717
+ 'httpMethod' => 'DELETE',
718
+ 'uri' => '/{Bucket}{/Key*}',
719
+ 'class' => 'Aws\\S3\\Command\\S3Command',
720
+ 'responseClass' => 'DeleteObjectOutput',
721
+ 'responseType' => 'model',
722
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html',
723
+ 'parameters' => array(
724
+ 'Bucket' => array(
725
+ 'required' => true,
726
+ 'type' => 'string',
727
+ 'location' => 'uri',
728
+ ),
729
+ 'Key' => array(
730
+ 'required' => true,
731
+ 'type' => 'string',
732
+ 'location' => 'uri',
733
+ 'filters' => array(
734
+ 'Aws\\S3\\S3Client::explodeKey',
735
+ ),
736
+ ),
737
+ 'MFA' => array(
738
+ 'type' => 'string',
739
+ 'location' => 'header',
740
+ 'sentAs' => 'x-amz-mfa',
741
+ ),
742
+ 'VersionId' => array(
743
+ 'type' => 'string',
744
+ 'location' => 'query',
745
+ 'sentAs' => 'versionId',
746
+ ),
747
+ 'RequestPayer' => array(
748
+ 'type' => 'string',
749
+ 'location' => 'header',
750
+ 'sentAs' => 'x-amz-request-payer',
751
+ ),
752
+ ),
753
+ ),
754
+ 'DeleteObjects' => array(
755
+ 'httpMethod' => 'POST',
756
+ 'uri' => '/{Bucket}?delete',
757
+ 'class' => 'Aws\\S3\\Command\\S3Command',
758
+ 'responseClass' => 'DeleteObjectsOutput',
759
+ 'responseType' => 'model',
760
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html',
761
+ 'data' => array(
762
+ 'xmlRoot' => array(
763
+ 'name' => 'Delete',
764
+ 'namespaces' => array(
765
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
766
+ ),
767
+ ),
768
+ 'contentMd5' => true,
769
+ ),
770
+ 'parameters' => array(
771
+ 'Bucket' => array(
772
+ 'required' => true,
773
+ 'type' => 'string',
774
+ 'location' => 'uri',
775
+ ),
776
+ 'Objects' => array(
777
+ 'required' => true,
778
+ 'type' => 'array',
779
+ 'location' => 'xml',
780
+ 'data' => array(
781
+ 'xmlFlattened' => true,
782
+ ),
783
+ 'items' => array(
784
+ 'name' => 'ObjectIdentifier',
785
+ 'type' => 'object',
786
+ 'sentAs' => 'Object',
787
+ 'properties' => array(
788
+ 'Key' => array(
789
+ 'required' => true,
790
+ 'type' => 'string',
791
+ ),
792
+ 'VersionId' => array(
793
+ 'type' => 'string',
794
+ ),
795
+ ),
796
+ ),
797
+ ),
798
+ 'Quiet' => array(
799
+ 'type' => 'boolean',
800
+ 'format' => 'boolean-string',
801
+ 'location' => 'xml',
802
+ ),
803
+ 'MFA' => array(
804
+ 'type' => 'string',
805
+ 'location' => 'header',
806
+ 'sentAs' => 'x-amz-mfa',
807
+ ),
808
+ 'RequestPayer' => array(
809
+ 'type' => 'string',
810
+ 'location' => 'header',
811
+ 'sentAs' => 'x-amz-request-payer',
812
+ ),
813
+ 'command.expects' => array(
814
+ 'static' => true,
815
+ 'default' => 'application/xml',
816
+ ),
817
+ ),
818
+ ),
819
+ 'GetBucketAcl' => array(
820
+ 'httpMethod' => 'GET',
821
+ 'uri' => '/{Bucket}?acl',
822
+ 'class' => 'Aws\\S3\\Command\\S3Command',
823
+ 'responseClass' => 'GetBucketAclOutput',
824
+ 'responseType' => 'model',
825
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETacl.html',
826
+ 'parameters' => array(
827
+ 'Bucket' => array(
828
+ 'required' => true,
829
+ 'type' => 'string',
830
+ 'location' => 'uri',
831
+ ),
832
+ 'command.expects' => array(
833
+ 'static' => true,
834
+ 'default' => 'application/xml',
835
+ ),
836
+ ),
837
+ ),
838
+ 'GetBucketCors' => array(
839
+ 'httpMethod' => 'GET',
840
+ 'uri' => '/{Bucket}?cors',
841
+ 'class' => 'Aws\\S3\\Command\\S3Command',
842
+ 'responseClass' => 'GetBucketCorsOutput',
843
+ 'responseType' => 'model',
844
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETcors.html',
845
+ 'parameters' => array(
846
+ 'Bucket' => array(
847
+ 'required' => true,
848
+ 'type' => 'string',
849
+ 'location' => 'uri',
850
+ ),
851
+ 'command.expects' => array(
852
+ 'static' => true,
853
+ 'default' => 'application/xml',
854
+ ),
855
+ ),
856
+ ),
857
+ 'GetBucketLifecycle' => array(
858
+ 'httpMethod' => 'GET',
859
+ 'uri' => '/{Bucket}?lifecycle',
860
+ 'class' => 'Aws\\S3\\Command\\S3Command',
861
+ 'responseClass' => 'GetBucketLifecycleOutput',
862
+ 'responseType' => 'model',
863
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlifecycle.html',
864
+ 'parameters' => array(
865
+ 'Bucket' => array(
866
+ 'required' => true,
867
+ 'type' => 'string',
868
+ 'location' => 'uri',
869
+ ),
870
+ 'command.expects' => array(
871
+ 'static' => true,
872
+ 'default' => 'application/xml',
873
+ ),
874
+ ),
875
+ ),
876
+ 'GetBucketLocation' => array(
877
+ 'httpMethod' => 'GET',
878
+ 'uri' => '/{Bucket}?location',
879
+ 'class' => 'Aws\\S3\\Command\\S3Command',
880
+ 'responseClass' => 'GetBucketLocationOutput',
881
+ 'responseType' => 'model',
882
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlocation.html',
883
+ 'parameters' => array(
884
+ 'Bucket' => array(
885
+ 'required' => true,
886
+ 'type' => 'string',
887
+ 'location' => 'uri',
888
+ ),
889
+ ),
890
+ ),
891
+ 'GetBucketLogging' => array(
892
+ 'httpMethod' => 'GET',
893
+ 'uri' => '/{Bucket}?logging',
894
+ 'class' => 'Aws\\S3\\Command\\S3Command',
895
+ 'responseClass' => 'GetBucketLoggingOutput',
896
+ 'responseType' => 'model',
897
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlogging.html',
898
+ 'parameters' => array(
899
+ 'Bucket' => array(
900
+ 'required' => true,
901
+ 'type' => 'string',
902
+ 'location' => 'uri',
903
+ ),
904
+ 'command.expects' => array(
905
+ 'static' => true,
906
+ 'default' => 'application/xml',
907
+ ),
908
+ ),
909
+ ),
910
+ 'GetBucketNotification' => array(
911
+ 'httpMethod' => 'GET',
912
+ 'uri' => '/{Bucket}?notification',
913
+ 'class' => 'Aws\\S3\\Command\\S3Command',
914
+ 'responseClass' => 'GetBucketNotificationOutput',
915
+ 'responseType' => 'model',
916
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETnotification.html',
917
+ 'parameters' => array(
918
+ 'Bucket' => array(
919
+ 'required' => true,
920
+ 'type' => 'string',
921
+ 'location' => 'uri',
922
+ ),
923
+ 'command.expects' => array(
924
+ 'static' => true,
925
+ 'default' => 'application/xml',
926
+ ),
927
+ ),
928
+ ),
929
+ 'GetBucketPolicy' => array(
930
+ 'httpMethod' => 'GET',
931
+ 'uri' => '/{Bucket}?policy',
932
+ 'class' => 'Aws\\S3\\Command\\S3Command',
933
+ 'responseClass' => 'GetBucketPolicyOutput',
934
+ 'responseType' => 'model',
935
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETpolicy.html',
936
+ 'parameters' => array(
937
+ 'Bucket' => array(
938
+ 'required' => true,
939
+ 'type' => 'string',
940
+ 'location' => 'uri',
941
+ ),
942
+ ),
943
+ ),
944
+ 'GetBucketReplication' => array(
945
+ 'httpMethod' => 'GET',
946
+ 'uri' => '/{Bucket}?replication',
947
+ 'class' => 'Aws\\S3\\Command\\S3Command',
948
+ 'responseClass' => 'GetBucketReplicationOutput',
949
+ 'responseType' => 'model',
950
+ 'parameters' => array(
951
+ 'Bucket' => array(
952
+ 'required' => true,
953
+ 'type' => 'string',
954
+ 'location' => 'uri',
955
+ ),
956
+ 'command.expects' => array(
957
+ 'static' => true,
958
+ 'default' => 'application/xml',
959
+ ),
960
+ ),
961
+ ),
962
+ 'GetBucketRequestPayment' => array(
963
+ 'httpMethod' => 'GET',
964
+ 'uri' => '/{Bucket}?requestPayment',
965
+ 'class' => 'Aws\\S3\\Command\\S3Command',
966
+ 'responseClass' => 'GetBucketRequestPaymentOutput',
967
+ 'responseType' => 'model',
968
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTrequestPaymentGET.html',
969
+ 'parameters' => array(
970
+ 'Bucket' => array(
971
+ 'required' => true,
972
+ 'type' => 'string',
973
+ 'location' => 'uri',
974
+ ),
975
+ 'command.expects' => array(
976
+ 'static' => true,
977
+ 'default' => 'application/xml',
978
+ ),
979
+ ),
980
+ ),
981
+ 'GetBucketTagging' => array(
982
+ 'httpMethod' => 'GET',
983
+ 'uri' => '/{Bucket}?tagging',
984
+ 'class' => 'Aws\\S3\\Command\\S3Command',
985
+ 'responseClass' => 'GetBucketTaggingOutput',
986
+ 'responseType' => 'model',
987
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETtagging.html',
988
+ 'parameters' => array(
989
+ 'Bucket' => array(
990
+ 'required' => true,
991
+ 'type' => 'string',
992
+ 'location' => 'uri',
993
+ ),
994
+ 'command.expects' => array(
995
+ 'static' => true,
996
+ 'default' => 'application/xml',
997
+ ),
998
+ ),
999
+ ),
1000
+ 'GetBucketVersioning' => array(
1001
+ 'httpMethod' => 'GET',
1002
+ 'uri' => '/{Bucket}?versioning',
1003
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1004
+ 'responseClass' => 'GetBucketVersioningOutput',
1005
+ 'responseType' => 'model',
1006
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETversioningStatus.html',
1007
+ 'parameters' => array(
1008
+ 'Bucket' => array(
1009
+ 'required' => true,
1010
+ 'type' => 'string',
1011
+ 'location' => 'uri',
1012
+ ),
1013
+ 'command.expects' => array(
1014
+ 'static' => true,
1015
+ 'default' => 'application/xml',
1016
+ ),
1017
+ ),
1018
+ ),
1019
+ 'GetBucketWebsite' => array(
1020
+ 'httpMethod' => 'GET',
1021
+ 'uri' => '/{Bucket}?website',
1022
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1023
+ 'responseClass' => 'GetBucketWebsiteOutput',
1024
+ 'responseType' => 'model',
1025
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETwebsite.html',
1026
+ 'parameters' => array(
1027
+ 'Bucket' => array(
1028
+ 'required' => true,
1029
+ 'type' => 'string',
1030
+ 'location' => 'uri',
1031
+ ),
1032
+ 'command.expects' => array(
1033
+ 'static' => true,
1034
+ 'default' => 'application/xml',
1035
+ ),
1036
+ ),
1037
+ ),
1038
+ 'GetObject' => array(
1039
+ 'httpMethod' => 'GET',
1040
+ 'uri' => '/{Bucket}{/Key*}',
1041
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1042
+ 'responseClass' => 'GetObjectOutput',
1043
+ 'responseType' => 'model',
1044
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html',
1045
+ 'parameters' => array(
1046
+ 'Bucket' => array(
1047
+ 'required' => true,
1048
+ 'type' => 'string',
1049
+ 'location' => 'uri',
1050
+ ),
1051
+ 'IfMatch' => array(
1052
+ 'type' => 'string',
1053
+ 'location' => 'header',
1054
+ 'sentAs' => 'If-Match',
1055
+ ),
1056
+ 'IfModifiedSince' => array(
1057
+ 'type' => array(
1058
+ 'object',
1059
+ 'string',
1060
+ 'integer',
1061
+ ),
1062
+ 'format' => 'date-time-http',
1063
+ 'location' => 'header',
1064
+ 'sentAs' => 'If-Modified-Since',
1065
+ ),
1066
+ 'IfNoneMatch' => array(
1067
+ 'type' => 'string',
1068
+ 'location' => 'header',
1069
+ 'sentAs' => 'If-None-Match',
1070
+ ),
1071
+ 'IfUnmodifiedSince' => array(
1072
+ 'type' => array(
1073
+ 'object',
1074
+ 'string',
1075
+ 'integer',
1076
+ ),
1077
+ 'format' => 'date-time-http',
1078
+ 'location' => 'header',
1079
+ 'sentAs' => 'If-Unmodified-Since',
1080
+ ),
1081
+ 'Key' => array(
1082
+ 'required' => true,
1083
+ 'type' => 'string',
1084
+ 'location' => 'uri',
1085
+ 'filters' => array(
1086
+ 'Aws\\S3\\S3Client::explodeKey',
1087
+ ),
1088
+ ),
1089
+ 'Range' => array(
1090
+ 'type' => 'string',
1091
+ 'location' => 'header',
1092
+ ),
1093
+ 'ResponseCacheControl' => array(
1094
+ 'type' => 'string',
1095
+ 'location' => 'query',
1096
+ 'sentAs' => 'response-cache-control',
1097
+ ),
1098
+ 'ResponseContentDisposition' => array(
1099
+ 'type' => 'string',
1100
+ 'location' => 'query',
1101
+ 'sentAs' => 'response-content-disposition',
1102
+ ),
1103
+ 'ResponseContentEncoding' => array(
1104
+ 'type' => 'string',
1105
+ 'location' => 'query',
1106
+ 'sentAs' => 'response-content-encoding',
1107
+ ),
1108
+ 'ResponseContentLanguage' => array(
1109
+ 'type' => 'string',
1110
+ 'location' => 'query',
1111
+ 'sentAs' => 'response-content-language',
1112
+ ),
1113
+ 'ResponseContentType' => array(
1114
+ 'type' => 'string',
1115
+ 'location' => 'query',
1116
+ 'sentAs' => 'response-content-type',
1117
+ ),
1118
+ 'ResponseExpires' => array(
1119
+ 'type' => array(
1120
+ 'object',
1121
+ 'string',
1122
+ 'integer',
1123
+ ),
1124
+ 'format' => 'date-time-http',
1125
+ 'location' => 'query',
1126
+ 'sentAs' => 'response-expires',
1127
+ ),
1128
+ 'VersionId' => array(
1129
+ 'type' => 'string',
1130
+ 'location' => 'query',
1131
+ 'sentAs' => 'versionId',
1132
+ ),
1133
+ 'SSECustomerAlgorithm' => array(
1134
+ 'type' => 'string',
1135
+ 'location' => 'header',
1136
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
1137
+ ),
1138
+ 'SSECustomerKey' => array(
1139
+ 'type' => 'string',
1140
+ 'location' => 'header',
1141
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key',
1142
+ ),
1143
+ 'SSECustomerKeyMD5' => array(
1144
+ 'type' => 'string',
1145
+ 'location' => 'header',
1146
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
1147
+ ),
1148
+ 'RequestPayer' => array(
1149
+ 'type' => 'string',
1150
+ 'location' => 'header',
1151
+ 'sentAs' => 'x-amz-request-payer',
1152
+ ),
1153
+ 'SaveAs' => array(
1154
+ 'location' => 'response_body',
1155
+ ),
1156
+ ),
1157
+ 'errorResponses' => array(
1158
+ array(
1159
+ 'reason' => 'The specified key does not exist.',
1160
+ 'class' => 'NoSuchKeyException',
1161
+ ),
1162
+ ),
1163
+ ),
1164
+ 'GetObjectAcl' => array(
1165
+ 'httpMethod' => 'GET',
1166
+ 'uri' => '/{Bucket}{/Key*}?acl',
1167
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1168
+ 'responseClass' => 'GetObjectAclOutput',
1169
+ 'responseType' => 'model',
1170
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGETacl.html',
1171
+ 'parameters' => array(
1172
+ 'Bucket' => array(
1173
+ 'required' => true,
1174
+ 'type' => 'string',
1175
+ 'location' => 'uri',
1176
+ ),
1177
+ 'Key' => array(
1178
+ 'required' => true,
1179
+ 'type' => 'string',
1180
+ 'location' => 'uri',
1181
+ 'filters' => array(
1182
+ 'Aws\\S3\\S3Client::explodeKey',
1183
+ ),
1184
+ ),
1185
+ 'VersionId' => array(
1186
+ 'type' => 'string',
1187
+ 'location' => 'query',
1188
+ 'sentAs' => 'versionId',
1189
+ ),
1190
+ 'RequestPayer' => array(
1191
+ 'type' => 'string',
1192
+ 'location' => 'header',
1193
+ 'sentAs' => 'x-amz-request-payer',
1194
+ ),
1195
+ 'command.expects' => array(
1196
+ 'static' => true,
1197
+ 'default' => 'application/xml',
1198
+ ),
1199
+ ),
1200
+ 'errorResponses' => array(
1201
+ array(
1202
+ 'reason' => 'The specified key does not exist.',
1203
+ 'class' => 'NoSuchKeyException',
1204
+ ),
1205
+ ),
1206
+ ),
1207
+ 'GetObjectTorrent' => array(
1208
+ 'httpMethod' => 'GET',
1209
+ 'uri' => '/{Bucket}{/Key*}?torrent',
1210
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1211
+ 'responseClass' => 'GetObjectTorrentOutput',
1212
+ 'responseType' => 'model',
1213
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGETtorrent.html',
1214
+ 'parameters' => array(
1215
+ 'Bucket' => array(
1216
+ 'required' => true,
1217
+ 'type' => 'string',
1218
+ 'location' => 'uri',
1219
+ ),
1220
+ 'Key' => array(
1221
+ 'required' => true,
1222
+ 'type' => 'string',
1223
+ 'location' => 'uri',
1224
+ 'filters' => array(
1225
+ 'Aws\\S3\\S3Client::explodeKey',
1226
+ ),
1227
+ ),
1228
+ 'RequestPayer' => array(
1229
+ 'type' => 'string',
1230
+ 'location' => 'header',
1231
+ 'sentAs' => 'x-amz-request-payer',
1232
+ ),
1233
+ ),
1234
+ ),
1235
+ 'HeadBucket' => array(
1236
+ 'httpMethod' => 'HEAD',
1237
+ 'uri' => '/{Bucket}',
1238
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1239
+ 'responseClass' => 'HeadBucketOutput',
1240
+ 'responseType' => 'model',
1241
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketHEAD.html',
1242
+ 'parameters' => array(
1243
+ 'Bucket' => array(
1244
+ 'required' => true,
1245
+ 'type' => 'string',
1246
+ 'location' => 'uri',
1247
+ ),
1248
+ ),
1249
+ 'errorResponses' => array(
1250
+ array(
1251
+ 'reason' => 'The specified bucket does not exist.',
1252
+ 'class' => 'NoSuchBucketException',
1253
+ ),
1254
+ ),
1255
+ ),
1256
+ 'HeadObject' => array(
1257
+ 'httpMethod' => 'HEAD',
1258
+ 'uri' => '/{Bucket}{/Key*}',
1259
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1260
+ 'responseClass' => 'HeadObjectOutput',
1261
+ 'responseType' => 'model',
1262
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html',
1263
+ 'parameters' => array(
1264
+ 'Bucket' => array(
1265
+ 'required' => true,
1266
+ 'type' => 'string',
1267
+ 'location' => 'uri',
1268
+ ),
1269
+ 'IfMatch' => array(
1270
+ 'type' => 'string',
1271
+ 'location' => 'header',
1272
+ 'sentAs' => 'If-Match',
1273
+ ),
1274
+ 'IfModifiedSince' => array(
1275
+ 'type' => array(
1276
+ 'object',
1277
+ 'string',
1278
+ 'integer',
1279
+ ),
1280
+ 'format' => 'date-time-http',
1281
+ 'location' => 'header',
1282
+ 'sentAs' => 'If-Modified-Since',
1283
+ ),
1284
+ 'IfNoneMatch' => array(
1285
+ 'type' => 'string',
1286
+ 'location' => 'header',
1287
+ 'sentAs' => 'If-None-Match',
1288
+ ),
1289
+ 'IfUnmodifiedSince' => array(
1290
+ 'type' => array(
1291
+ 'object',
1292
+ 'string',
1293
+ 'integer',
1294
+ ),
1295
+ 'format' => 'date-time-http',
1296
+ 'location' => 'header',
1297
+ 'sentAs' => 'If-Unmodified-Since',
1298
+ ),
1299
+ 'Key' => array(
1300
+ 'required' => true,
1301
+ 'type' => 'string',
1302
+ 'location' => 'uri',
1303
+ 'filters' => array(
1304
+ 'Aws\\S3\\S3Client::explodeKey',
1305
+ ),
1306
+ ),
1307
+ 'Range' => array(
1308
+ 'type' => 'string',
1309
+ 'location' => 'header',
1310
+ ),
1311
+ 'VersionId' => array(
1312
+ 'type' => 'string',
1313
+ 'location' => 'query',
1314
+ 'sentAs' => 'versionId',
1315
+ ),
1316
+ 'SSECustomerAlgorithm' => array(
1317
+ 'type' => 'string',
1318
+ 'location' => 'header',
1319
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
1320
+ ),
1321
+ 'SSECustomerKey' => array(
1322
+ 'type' => 'string',
1323
+ 'location' => 'header',
1324
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key',
1325
+ ),
1326
+ 'SSECustomerKeyMD5' => array(
1327
+ 'type' => 'string',
1328
+ 'location' => 'header',
1329
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
1330
+ ),
1331
+ 'RequestPayer' => array(
1332
+ 'type' => 'string',
1333
+ 'location' => 'header',
1334
+ 'sentAs' => 'x-amz-request-payer',
1335
+ ),
1336
+ ),
1337
+ 'errorResponses' => array(
1338
+ array(
1339
+ 'reason' => 'The specified key does not exist.',
1340
+ 'class' => 'NoSuchKeyException',
1341
+ ),
1342
+ ),
1343
+ ),
1344
+ 'ListBuckets' => array(
1345
+ 'httpMethod' => 'GET',
1346
+ 'uri' => '/',
1347
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1348
+ 'responseClass' => 'ListBucketsOutput',
1349
+ 'responseType' => 'model',
1350
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTServiceGET.html',
1351
+ 'parameters' => array(
1352
+ 'command.expects' => array(
1353
+ 'static' => true,
1354
+ 'default' => 'application/xml',
1355
+ ),
1356
+ ),
1357
+ ),
1358
+ 'ListMultipartUploads' => array(
1359
+ 'httpMethod' => 'GET',
1360
+ 'uri' => '/{Bucket}?uploads',
1361
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1362
+ 'responseClass' => 'ListMultipartUploadsOutput',
1363
+ 'responseType' => 'model',
1364
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadListMPUpload.html',
1365
+ 'parameters' => array(
1366
+ 'Bucket' => array(
1367
+ 'required' => true,
1368
+ 'type' => 'string',
1369
+ 'location' => 'uri',
1370
+ ),
1371
+ 'Delimiter' => array(
1372
+ 'type' => 'string',
1373
+ 'location' => 'query',
1374
+ 'sentAs' => 'delimiter',
1375
+ ),
1376
+ 'EncodingType' => array(
1377
+ 'type' => 'string',
1378
+ 'location' => 'query',
1379
+ 'sentAs' => 'encoding-type',
1380
+ ),
1381
+ 'KeyMarker' => array(
1382
+ 'type' => 'string',
1383
+ 'location' => 'query',
1384
+ 'sentAs' => 'key-marker',
1385
+ ),
1386
+ 'MaxUploads' => array(
1387
+ 'type' => 'numeric',
1388
+ 'location' => 'query',
1389
+ 'sentAs' => 'max-uploads',
1390
+ ),
1391
+ 'Prefix' => array(
1392
+ 'type' => 'string',
1393
+ 'location' => 'query',
1394
+ 'sentAs' => 'prefix',
1395
+ ),
1396
+ 'UploadIdMarker' => array(
1397
+ 'type' => 'string',
1398
+ 'location' => 'query',
1399
+ 'sentAs' => 'upload-id-marker',
1400
+ ),
1401
+ 'command.expects' => array(
1402
+ 'static' => true,
1403
+ 'default' => 'application/xml',
1404
+ ),
1405
+ ),
1406
+ ),
1407
+ 'ListObjectVersions' => array(
1408
+ 'httpMethod' => 'GET',
1409
+ 'uri' => '/{Bucket}?versions',
1410
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1411
+ 'responseClass' => 'ListObjectVersionsOutput',
1412
+ 'responseType' => 'model',
1413
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETVersion.html',
1414
+ 'parameters' => array(
1415
+ 'Bucket' => array(
1416
+ 'required' => true,
1417
+ 'type' => 'string',
1418
+ 'location' => 'uri',
1419
+ ),
1420
+ 'Delimiter' => array(
1421
+ 'type' => 'string',
1422
+ 'location' => 'query',
1423
+ 'sentAs' => 'delimiter',
1424
+ ),
1425
+ 'EncodingType' => array(
1426
+ 'type' => 'string',
1427
+ 'location' => 'query',
1428
+ 'sentAs' => 'encoding-type',
1429
+ ),
1430
+ 'KeyMarker' => array(
1431
+ 'type' => 'string',
1432
+ 'location' => 'query',
1433
+ 'sentAs' => 'key-marker',
1434
+ ),
1435
+ 'MaxKeys' => array(
1436
+ 'type' => 'numeric',
1437
+ 'location' => 'query',
1438
+ 'sentAs' => 'max-keys',
1439
+ ),
1440
+ 'Prefix' => array(
1441
+ 'type' => 'string',
1442
+ 'location' => 'query',
1443
+ 'sentAs' => 'prefix',
1444
+ ),
1445
+ 'VersionIdMarker' => array(
1446
+ 'type' => 'string',
1447
+ 'location' => 'query',
1448
+ 'sentAs' => 'version-id-marker',
1449
+ ),
1450
+ 'command.expects' => array(
1451
+ 'static' => true,
1452
+ 'default' => 'application/xml',
1453
+ ),
1454
+ ),
1455
+ ),
1456
+ 'ListObjects' => array(
1457
+ 'httpMethod' => 'GET',
1458
+ 'uri' => '/{Bucket}',
1459
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1460
+ 'responseClass' => 'ListObjectsOutput',
1461
+ 'responseType' => 'model',
1462
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html',
1463
+ 'parameters' => array(
1464
+ 'Bucket' => array(
1465
+ 'required' => true,
1466
+ 'type' => 'string',
1467
+ 'location' => 'uri',
1468
+ ),
1469
+ 'Delimiter' => array(
1470
+ 'type' => 'string',
1471
+ 'location' => 'query',
1472
+ 'sentAs' => 'delimiter',
1473
+ ),
1474
+ 'EncodingType' => array(
1475
+ 'type' => 'string',
1476
+ 'location' => 'query',
1477
+ 'sentAs' => 'encoding-type',
1478
+ ),
1479
+ 'Marker' => array(
1480
+ 'type' => 'string',
1481
+ 'location' => 'query',
1482
+ 'sentAs' => 'marker',
1483
+ ),
1484
+ 'MaxKeys' => array(
1485
+ 'type' => 'numeric',
1486
+ 'location' => 'query',
1487
+ 'sentAs' => 'max-keys',
1488
+ ),
1489
+ 'Prefix' => array(
1490
+ 'type' => 'string',
1491
+ 'location' => 'query',
1492
+ 'sentAs' => 'prefix',
1493
+ ),
1494
+ 'command.expects' => array(
1495
+ 'static' => true,
1496
+ 'default' => 'application/xml',
1497
+ ),
1498
+ ),
1499
+ 'errorResponses' => array(
1500
+ array(
1501
+ 'reason' => 'The specified bucket does not exist.',
1502
+ 'class' => 'NoSuchBucketException',
1503
+ ),
1504
+ ),
1505
+ ),
1506
+ 'ListParts' => array(
1507
+ 'httpMethod' => 'GET',
1508
+ 'uri' => '/{Bucket}{/Key*}',
1509
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1510
+ 'responseClass' => 'ListPartsOutput',
1511
+ 'responseType' => 'model',
1512
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadListParts.html',
1513
+ 'parameters' => array(
1514
+ 'Bucket' => array(
1515
+ 'required' => true,
1516
+ 'type' => 'string',
1517
+ 'location' => 'uri',
1518
+ ),
1519
+ 'Key' => array(
1520
+ 'required' => true,
1521
+ 'type' => 'string',
1522
+ 'location' => 'uri',
1523
+ 'filters' => array(
1524
+ 'Aws\\S3\\S3Client::explodeKey',
1525
+ ),
1526
+ ),
1527
+ 'MaxParts' => array(
1528
+ 'type' => 'numeric',
1529
+ 'location' => 'query',
1530
+ 'sentAs' => 'max-parts',
1531
+ ),
1532
+ 'PartNumberMarker' => array(
1533
+ 'type' => 'numeric',
1534
+ 'location' => 'query',
1535
+ 'sentAs' => 'part-number-marker',
1536
+ ),
1537
+ 'UploadId' => array(
1538
+ 'required' => true,
1539
+ 'type' => 'string',
1540
+ 'location' => 'query',
1541
+ 'sentAs' => 'uploadId',
1542
+ ),
1543
+ 'RequestPayer' => array(
1544
+ 'type' => 'string',
1545
+ 'location' => 'header',
1546
+ 'sentAs' => 'x-amz-request-payer',
1547
+ ),
1548
+ 'command.expects' => array(
1549
+ 'static' => true,
1550
+ 'default' => 'application/xml',
1551
+ ),
1552
+ ),
1553
+ ),
1554
+ 'PutBucketAcl' => array(
1555
+ 'httpMethod' => 'PUT',
1556
+ 'uri' => '/{Bucket}?acl',
1557
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1558
+ 'responseClass' => 'PutBucketAclOutput',
1559
+ 'responseType' => 'model',
1560
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTacl.html',
1561
+ 'data' => array(
1562
+ 'xmlRoot' => array(
1563
+ 'name' => 'AccessControlPolicy',
1564
+ 'namespaces' => array(
1565
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
1566
+ ),
1567
+ ),
1568
+ ),
1569
+ 'parameters' => array(
1570
+ 'ACL' => array(
1571
+ 'type' => 'string',
1572
+ 'location' => 'header',
1573
+ 'sentAs' => 'x-amz-acl',
1574
+ ),
1575
+ 'Grants' => array(
1576
+ 'type' => 'array',
1577
+ 'location' => 'xml',
1578
+ 'sentAs' => 'AccessControlList',
1579
+ 'items' => array(
1580
+ 'name' => 'Grant',
1581
+ 'type' => 'object',
1582
+ 'properties' => array(
1583
+ 'Grantee' => array(
1584
+ 'type' => 'object',
1585
+ 'properties' => array(
1586
+ 'DisplayName' => array(
1587
+ 'type' => 'string',
1588
+ ),
1589
+ 'EmailAddress' => array(
1590
+ 'type' => 'string',
1591
+ ),
1592
+ 'ID' => array(
1593
+ 'type' => 'string',
1594
+ ),
1595
+ 'Type' => array(
1596
+ 'required' => true,
1597
+ 'type' => 'string',
1598
+ 'sentAs' => 'xsi:type',
1599
+ 'data' => array(
1600
+ 'xmlAttribute' => true,
1601
+ 'xmlNamespace' => 'http://www.w3.org/2001/XMLSchema-instance',
1602
+ ),
1603
+ ),
1604
+ 'URI' => array(
1605
+ 'type' => 'string',
1606
+ ),
1607
+ ),
1608
+ ),
1609
+ 'Permission' => array(
1610
+ 'type' => 'string',
1611
+ ),
1612
+ ),
1613
+ ),
1614
+ ),
1615
+ 'Owner' => array(
1616
+ 'type' => 'object',
1617
+ 'location' => 'xml',
1618
+ 'properties' => array(
1619
+ 'DisplayName' => array(
1620
+ 'type' => 'string',
1621
+ ),
1622
+ 'ID' => array(
1623
+ 'type' => 'string',
1624
+ ),
1625
+ ),
1626
+ ),
1627
+ 'Bucket' => array(
1628
+ 'required' => true,
1629
+ 'type' => 'string',
1630
+ 'location' => 'uri',
1631
+ ),
1632
+ 'GrantFullControl' => array(
1633
+ 'type' => 'string',
1634
+ 'location' => 'header',
1635
+ 'sentAs' => 'x-amz-grant-full-control',
1636
+ ),
1637
+ 'GrantRead' => array(
1638
+ 'type' => 'string',
1639
+ 'location' => 'header',
1640
+ 'sentAs' => 'x-amz-grant-read',
1641
+ ),
1642
+ 'GrantReadACP' => array(
1643
+ 'type' => 'string',
1644
+ 'location' => 'header',
1645
+ 'sentAs' => 'x-amz-grant-read-acp',
1646
+ ),
1647
+ 'GrantWrite' => array(
1648
+ 'type' => 'string',
1649
+ 'location' => 'header',
1650
+ 'sentAs' => 'x-amz-grant-write',
1651
+ ),
1652
+ 'GrantWriteACP' => array(
1653
+ 'type' => 'string',
1654
+ 'location' => 'header',
1655
+ 'sentAs' => 'x-amz-grant-write-acp',
1656
+ ),
1657
+ 'ACP' => array(
1658
+ 'type' => 'object',
1659
+ 'additionalProperties' => true,
1660
+ ),
1661
+ ),
1662
+ ),
1663
+ 'PutBucketCors' => array(
1664
+ 'httpMethod' => 'PUT',
1665
+ 'uri' => '/{Bucket}?cors',
1666
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1667
+ 'responseClass' => 'PutBucketCorsOutput',
1668
+ 'responseType' => 'model',
1669
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTcors.html',
1670
+ 'data' => array(
1671
+ 'xmlRoot' => array(
1672
+ 'name' => 'CORSConfiguration',
1673
+ 'namespaces' => array(
1674
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
1675
+ ),
1676
+ ),
1677
+ 'contentMd5' => true,
1678
+ ),
1679
+ 'parameters' => array(
1680
+ 'Bucket' => array(
1681
+ 'required' => true,
1682
+ 'type' => 'string',
1683
+ 'location' => 'uri',
1684
+ ),
1685
+ 'CORSRules' => array(
1686
+ 'type' => 'array',
1687
+ 'location' => 'xml',
1688
+ 'data' => array(
1689
+ 'xmlFlattened' => true,
1690
+ ),
1691
+ 'items' => array(
1692
+ 'name' => 'CORSRule',
1693
+ 'type' => 'object',
1694
+ 'sentAs' => 'CORSRule',
1695
+ 'properties' => array(
1696
+ 'AllowedHeaders' => array(
1697
+ 'type' => 'array',
1698
+ 'data' => array(
1699
+ 'xmlFlattened' => true,
1700
+ ),
1701
+ 'items' => array(
1702
+ 'name' => 'AllowedHeader',
1703
+ 'type' => 'string',
1704
+ 'sentAs' => 'AllowedHeader',
1705
+ ),
1706
+ ),
1707
+ 'AllowedMethods' => array(
1708
+ 'type' => 'array',
1709
+ 'data' => array(
1710
+ 'xmlFlattened' => true,
1711
+ ),
1712
+ 'items' => array(
1713
+ 'name' => 'AllowedMethod',
1714
+ 'type' => 'string',
1715
+ 'sentAs' => 'AllowedMethod',
1716
+ ),
1717
+ ),
1718
+ 'AllowedOrigins' => array(
1719
+ 'type' => 'array',
1720
+ 'data' => array(
1721
+ 'xmlFlattened' => true,
1722
+ ),
1723
+ 'items' => array(
1724
+ 'name' => 'AllowedOrigin',
1725
+ 'type' => 'string',
1726
+ 'sentAs' => 'AllowedOrigin',
1727
+ ),
1728
+ ),
1729
+ 'ExposeHeaders' => array(
1730
+ 'type' => 'array',
1731
+ 'data' => array(
1732
+ 'xmlFlattened' => true,
1733
+ ),
1734
+ 'items' => array(
1735
+ 'name' => 'ExposeHeader',
1736
+ 'type' => 'string',
1737
+ 'sentAs' => 'ExposeHeader',
1738
+ ),
1739
+ ),
1740
+ 'MaxAgeSeconds' => array(
1741
+ 'type' => 'numeric',
1742
+ ),
1743
+ ),
1744
+ ),
1745
+ ),
1746
+ ),
1747
+ ),
1748
+ 'PutBucketLifecycle' => array(
1749
+ 'httpMethod' => 'PUT',
1750
+ 'uri' => '/{Bucket}?lifecycle',
1751
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1752
+ 'responseClass' => 'PutBucketLifecycleOutput',
1753
+ 'responseType' => 'model',
1754
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTlifecycle.html',
1755
+ 'data' => array(
1756
+ 'xmlRoot' => array(
1757
+ 'name' => 'LifecycleConfiguration',
1758
+ 'namespaces' => array(
1759
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
1760
+ ),
1761
+ ),
1762
+ 'contentMd5' => true,
1763
+ ),
1764
+ 'parameters' => array(
1765
+ 'Bucket' => array(
1766
+ 'required' => true,
1767
+ 'type' => 'string',
1768
+ 'location' => 'uri',
1769
+ ),
1770
+ 'Rules' => array(
1771
+ 'required' => true,
1772
+ 'type' => 'array',
1773
+ 'location' => 'xml',
1774
+ 'data' => array(
1775
+ 'xmlFlattened' => true,
1776
+ ),
1777
+ 'items' => array(
1778
+ 'name' => 'Rule',
1779
+ 'type' => 'object',
1780
+ 'sentAs' => 'Rule',
1781
+ 'properties' => array(
1782
+ 'Expiration' => array(
1783
+ 'type' => 'object',
1784
+ 'properties' => array(
1785
+ 'Date' => array(
1786
+ 'type' => array(
1787
+ 'object',
1788
+ 'string',
1789
+ 'integer',
1790
+ ),
1791
+ 'format' => 'date-time',
1792
+ ),
1793
+ 'Days' => array(
1794
+ 'type' => 'numeric',
1795
+ ),
1796
+ ),
1797
+ ),
1798
+ 'ID' => array(
1799
+ 'type' => 'string',
1800
+ ),
1801
+ 'Prefix' => array(
1802
+ 'required' => true,
1803
+ 'type' => 'string',
1804
+ ),
1805
+ 'Status' => array(
1806
+ 'required' => true,
1807
+ 'type' => 'string',
1808
+ ),
1809
+ 'Transition' => array(
1810
+ 'type' => 'object',
1811
+ 'properties' => array(
1812
+ 'Date' => array(
1813
+ 'type' => array(
1814
+ 'object',
1815
+ 'string',
1816
+ 'integer',
1817
+ ),
1818
+ 'format' => 'date-time',
1819
+ ),
1820
+ 'Days' => array(
1821
+ 'type' => 'numeric',
1822
+ ),
1823
+ 'StorageClass' => array(
1824
+ 'type' => 'string',
1825
+ ),
1826
+ ),
1827
+ ),
1828
+ 'NoncurrentVersionTransition' => array(
1829
+ 'type' => 'object',
1830
+ 'properties' => array(
1831
+ 'NoncurrentDays' => array(
1832
+ 'type' => 'numeric',
1833
+ ),
1834
+ 'StorageClass' => array(
1835
+ 'type' => 'string',
1836
+ ),
1837
+ ),
1838
+ ),
1839
+ 'NoncurrentVersionExpiration' => array(
1840
+ 'type' => 'object',
1841
+ 'properties' => array(
1842
+ 'NoncurrentDays' => array(
1843
+ 'type' => 'numeric',
1844
+ ),
1845
+ ),
1846
+ ),
1847
+ ),
1848
+ ),
1849
+ ),
1850
+ ),
1851
+ ),
1852
+ 'PutBucketLogging' => array(
1853
+ 'httpMethod' => 'PUT',
1854
+ 'uri' => '/{Bucket}?logging',
1855
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1856
+ 'responseClass' => 'PutBucketLoggingOutput',
1857
+ 'responseType' => 'model',
1858
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTlogging.html',
1859
+ 'data' => array(
1860
+ 'xmlRoot' => array(
1861
+ 'name' => 'BucketLoggingStatus',
1862
+ 'namespaces' => array(
1863
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
1864
+ ),
1865
+ ),
1866
+ 'xmlAllowEmpty' => true,
1867
+ ),
1868
+ 'parameters' => array(
1869
+ 'Bucket' => array(
1870
+ 'required' => true,
1871
+ 'type' => 'string',
1872
+ 'location' => 'uri',
1873
+ ),
1874
+ 'LoggingEnabled' => array(
1875
+ 'type' => 'object',
1876
+ 'location' => 'xml',
1877
+ 'properties' => array(
1878
+ 'TargetBucket' => array(
1879
+ 'type' => 'string',
1880
+ ),
1881
+ 'TargetGrants' => array(
1882
+ 'type' => 'array',
1883
+ 'items' => array(
1884
+ 'name' => 'Grant',
1885
+ 'type' => 'object',
1886
+ 'properties' => array(
1887
+ 'Grantee' => array(
1888
+ 'type' => 'object',
1889
+ 'properties' => array(
1890
+ 'DisplayName' => array(
1891
+ 'type' => 'string',
1892
+ ),
1893
+ 'EmailAddress' => array(
1894
+ 'type' => 'string',
1895
+ ),
1896
+ 'ID' => array(
1897
+ 'type' => 'string',
1898
+ ),
1899
+ 'Type' => array(
1900
+ 'required' => true,
1901
+ 'type' => 'string',
1902
+ 'sentAs' => 'xsi:type',
1903
+ 'data' => array(
1904
+ 'xmlAttribute' => true,
1905
+ 'xmlNamespace' => 'http://www.w3.org/2001/XMLSchema-instance',
1906
+ ),
1907
+ ),
1908
+ 'URI' => array(
1909
+ 'type' => 'string',
1910
+ ),
1911
+ ),
1912
+ ),
1913
+ 'Permission' => array(
1914
+ 'type' => 'string',
1915
+ ),
1916
+ ),
1917
+ ),
1918
+ ),
1919
+ 'TargetPrefix' => array(
1920
+ 'type' => 'string',
1921
+ ),
1922
+ ),
1923
+ ),
1924
+ ),
1925
+ ),
1926
+ 'PutBucketNotification' => array(
1927
+ 'httpMethod' => 'PUT',
1928
+ 'uri' => '/{Bucket}?notification',
1929
+ 'class' => 'Aws\\S3\\Command\\S3Command',
1930
+ 'responseClass' => 'PutBucketNotificationOutput',
1931
+ 'responseType' => 'model',
1932
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html',
1933
+ 'data' => array(
1934
+ 'xmlRoot' => array(
1935
+ 'name' => 'NotificationConfiguration',
1936
+ 'namespaces' => array(
1937
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
1938
+ ),
1939
+ ),
1940
+ ),
1941
+ 'parameters' => array(
1942
+ 'Bucket' => array(
1943
+ 'required' => true,
1944
+ 'type' => 'string',
1945
+ 'location' => 'uri',
1946
+ ),
1947
+ 'TopicConfiguration' => array(
1948
+ 'type' => 'object',
1949
+ 'location' => 'xml',
1950
+ 'properties' => array(
1951
+ 'Id' => array(
1952
+ 'type' => 'string',
1953
+ ),
1954
+ 'Events' => array(
1955
+ 'type' => 'array',
1956
+ 'data' => array(
1957
+ 'xmlFlattened' => true,
1958
+ ),
1959
+ 'items' => array(
1960
+ 'name' => 'Event',
1961
+ 'type' => 'string',
1962
+ ),
1963
+ ),
1964
+ 'Event' => array(
1965
+ 'type' => 'string',
1966
+ ),
1967
+ 'Topic' => array(
1968
+ 'type' => 'string',
1969
+ ),
1970
+ ),
1971
+ ),
1972
+ 'QueueConfiguration' => array(
1973
+ 'type' => 'object',
1974
+ 'location' => 'xml',
1975
+ 'properties' => array(
1976
+ 'Id' => array(
1977
+ 'type' => 'string',
1978
+ ),
1979
+ 'Event' => array(
1980
+ 'type' => 'string',
1981
+ ),
1982
+ 'Events' => array(
1983
+ 'type' => 'array',
1984
+ 'data' => array(
1985
+ 'xmlFlattened' => true,
1986
+ ),
1987
+ 'items' => array(
1988
+ 'name' => 'Event',
1989
+ 'type' => 'string',
1990
+ ),
1991
+ ),
1992
+ 'Queue' => array(
1993
+ 'type' => 'string',
1994
+ ),
1995
+ ),
1996
+ ),
1997
+ 'CloudFunctionConfiguration' => array(
1998
+ 'type' => 'object',
1999
+ 'location' => 'xml',
2000
+ 'properties' => array(
2001
+ 'Id' => array(
2002
+ 'type' => 'string',
2003
+ ),
2004
+ 'Event' => array(
2005
+ 'type' => 'string',
2006
+ ),
2007
+ 'Events' => array(
2008
+ 'type' => 'array',
2009
+ 'data' => array(
2010
+ 'xmlFlattened' => true,
2011
+ ),
2012
+ 'items' => array(
2013
+ 'name' => 'Event',
2014
+ 'type' => 'string',
2015
+ ),
2016
+ ),
2017
+ 'CloudFunction' => array(
2018
+ 'type' => 'string',
2019
+ ),
2020
+ 'InvocationRole' => array(
2021
+ 'type' => 'string',
2022
+ ),
2023
+ ),
2024
+ ),
2025
+ ),
2026
+ ),
2027
+ 'PutBucketPolicy' => array(
2028
+ 'httpMethod' => 'PUT',
2029
+ 'uri' => '/{Bucket}?policy',
2030
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2031
+ 'responseClass' => 'PutBucketPolicyOutput',
2032
+ 'responseType' => 'model',
2033
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTpolicy.html',
2034
+ 'data' => array(
2035
+ 'xmlRoot' => array(
2036
+ 'name' => 'PutBucketPolicyRequest',
2037
+ 'namespaces' => array(
2038
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2039
+ ),
2040
+ ),
2041
+ ),
2042
+ 'parameters' => array(
2043
+ 'Bucket' => array(
2044
+ 'required' => true,
2045
+ 'type' => 'string',
2046
+ 'location' => 'uri',
2047
+ ),
2048
+ 'Policy' => array(
2049
+ 'required' => true,
2050
+ 'type' => array(
2051
+ 'string',
2052
+ 'object',
2053
+ ),
2054
+ 'location' => 'body',
2055
+ ),
2056
+ ),
2057
+ ),
2058
+ 'PutBucketReplication' => array(
2059
+ 'httpMethod' => 'PUT',
2060
+ 'uri' => '/{Bucket}?replication',
2061
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2062
+ 'responseClass' => 'PutBucketReplicationOutput',
2063
+ 'responseType' => 'model',
2064
+ 'data' => array(
2065
+ 'xmlRoot' => array(
2066
+ 'name' => 'ReplicationConfiguration',
2067
+ 'namespaces' => array(
2068
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2069
+ ),
2070
+ ),
2071
+ ),
2072
+ 'parameters' => array(
2073
+ 'Bucket' => array(
2074
+ 'required' => true,
2075
+ 'type' => 'string',
2076
+ 'location' => 'uri',
2077
+ ),
2078
+ 'Role' => array(
2079
+ 'required' => true,
2080
+ 'type' => 'string',
2081
+ 'location' => 'xml',
2082
+ ),
2083
+ 'Rules' => array(
2084
+ 'required' => true,
2085
+ 'type' => 'array',
2086
+ 'location' => 'xml',
2087
+ 'data' => array(
2088
+ 'xmlFlattened' => true,
2089
+ ),
2090
+ 'items' => array(
2091
+ 'name' => 'ReplicationRule',
2092
+ 'type' => 'object',
2093
+ 'sentAs' => 'Rule',
2094
+ 'properties' => array(
2095
+ 'ID' => array(
2096
+ 'type' => 'string',
2097
+ ),
2098
+ 'Prefix' => array(
2099
+ 'required' => true,
2100
+ 'type' => 'string',
2101
+ ),
2102
+ 'Status' => array(
2103
+ 'required' => true,
2104
+ 'type' => 'string',
2105
+ ),
2106
+ 'Destination' => array(
2107
+ 'required' => true,
2108
+ 'type' => 'object',
2109
+ 'properties' => array(
2110
+ 'Bucket' => array(
2111
+ 'required' => true,
2112
+ 'type' => 'string',
2113
+ ),
2114
+ ),
2115
+ ),
2116
+ ),
2117
+ ),
2118
+ ),
2119
+ ),
2120
+ ),
2121
+ 'PutBucketRequestPayment' => array(
2122
+ 'httpMethod' => 'PUT',
2123
+ 'uri' => '/{Bucket}?requestPayment',
2124
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2125
+ 'responseClass' => 'PutBucketRequestPaymentOutput',
2126
+ 'responseType' => 'model',
2127
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTrequestPaymentPUT.html',
2128
+ 'data' => array(
2129
+ 'xmlRoot' => array(
2130
+ 'name' => 'RequestPaymentConfiguration',
2131
+ 'namespaces' => array(
2132
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2133
+ ),
2134
+ ),
2135
+ ),
2136
+ 'parameters' => array(
2137
+ 'Bucket' => array(
2138
+ 'required' => true,
2139
+ 'type' => 'string',
2140
+ 'location' => 'uri',
2141
+ ),
2142
+ 'Payer' => array(
2143
+ 'required' => true,
2144
+ 'type' => 'string',
2145
+ 'location' => 'xml',
2146
+ ),
2147
+ ),
2148
+ ),
2149
+ 'PutBucketTagging' => array(
2150
+ 'httpMethod' => 'PUT',
2151
+ 'uri' => '/{Bucket}?tagging',
2152
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2153
+ 'responseClass' => 'PutBucketTaggingOutput',
2154
+ 'responseType' => 'model',
2155
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTtagging.html',
2156
+ 'data' => array(
2157
+ 'xmlRoot' => array(
2158
+ 'name' => 'Tagging',
2159
+ 'namespaces' => array(
2160
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2161
+ ),
2162
+ ),
2163
+ 'contentMd5' => true,
2164
+ ),
2165
+ 'parameters' => array(
2166
+ 'Bucket' => array(
2167
+ 'required' => true,
2168
+ 'type' => 'string',
2169
+ 'location' => 'uri',
2170
+ ),
2171
+ 'TagSet' => array(
2172
+ 'required' => true,
2173
+ 'type' => 'array',
2174
+ 'location' => 'xml',
2175
+ 'items' => array(
2176
+ 'name' => 'Tag',
2177
+ 'type' => 'object',
2178
+ 'properties' => array(
2179
+ 'Key' => array(
2180
+ 'required' => true,
2181
+ 'type' => 'string',
2182
+ ),
2183
+ 'Value' => array(
2184
+ 'required' => true,
2185
+ 'type' => 'string',
2186
+ ),
2187
+ ),
2188
+ ),
2189
+ ),
2190
+ ),
2191
+ ),
2192
+ 'PutBucketVersioning' => array(
2193
+ 'httpMethod' => 'PUT',
2194
+ 'uri' => '/{Bucket}?versioning',
2195
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2196
+ 'responseClass' => 'PutBucketVersioningOutput',
2197
+ 'responseType' => 'model',
2198
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTVersioningStatus.html',
2199
+ 'data' => array(
2200
+ 'xmlRoot' => array(
2201
+ 'name' => 'VersioningConfiguration',
2202
+ 'namespaces' => array(
2203
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2204
+ ),
2205
+ ),
2206
+ ),
2207
+ 'parameters' => array(
2208
+ 'Bucket' => array(
2209
+ 'required' => true,
2210
+ 'type' => 'string',
2211
+ 'location' => 'uri',
2212
+ ),
2213
+ 'MFA' => array(
2214
+ 'type' => 'string',
2215
+ 'location' => 'header',
2216
+ 'sentAs' => 'x-amz-mfa',
2217
+ ),
2218
+ 'MFADelete' => array(
2219
+ 'type' => 'string',
2220
+ 'location' => 'xml',
2221
+ 'sentAs' => 'MfaDelete',
2222
+ ),
2223
+ 'Status' => array(
2224
+ 'type' => 'string',
2225
+ 'location' => 'xml',
2226
+ ),
2227
+ ),
2228
+ ),
2229
+ 'PutBucketWebsite' => array(
2230
+ 'httpMethod' => 'PUT',
2231
+ 'uri' => '/{Bucket}?website',
2232
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2233
+ 'responseClass' => 'PutBucketWebsiteOutput',
2234
+ 'responseType' => 'model',
2235
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html',
2236
+ 'data' => array(
2237
+ 'xmlRoot' => array(
2238
+ 'name' => 'WebsiteConfiguration',
2239
+ 'namespaces' => array(
2240
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2241
+ ),
2242
+ ),
2243
+ 'xmlAllowEmpty' => true,
2244
+ ),
2245
+ 'parameters' => array(
2246
+ 'Bucket' => array(
2247
+ 'required' => true,
2248
+ 'type' => 'string',
2249
+ 'location' => 'uri',
2250
+ ),
2251
+ 'ErrorDocument' => array(
2252
+ 'type' => 'object',
2253
+ 'location' => 'xml',
2254
+ 'properties' => array(
2255
+ 'Key' => array(
2256
+ 'required' => true,
2257
+ 'type' => 'string',
2258
+ ),
2259
+ ),
2260
+ ),
2261
+ 'IndexDocument' => array(
2262
+ 'type' => 'object',
2263
+ 'location' => 'xml',
2264
+ 'properties' => array(
2265
+ 'Suffix' => array(
2266
+ 'required' => true,
2267
+ 'type' => 'string',
2268
+ ),
2269
+ ),
2270
+ ),
2271
+ 'RedirectAllRequestsTo' => array(
2272
+ 'type' => 'object',
2273
+ 'location' => 'xml',
2274
+ 'properties' => array(
2275
+ 'HostName' => array(
2276
+ 'required' => true,
2277
+ 'type' => 'string',
2278
+ ),
2279
+ 'Protocol' => array(
2280
+ 'type' => 'string',
2281
+ ),
2282
+ ),
2283
+ ),
2284
+ 'RoutingRules' => array(
2285
+ 'type' => 'array',
2286
+ 'location' => 'xml',
2287
+ 'items' => array(
2288
+ 'name' => 'RoutingRule',
2289
+ 'type' => 'object',
2290
+ 'properties' => array(
2291
+ 'Condition' => array(
2292
+ 'type' => 'object',
2293
+ 'properties' => array(
2294
+ 'HttpErrorCodeReturnedEquals' => array(
2295
+ 'type' => 'string',
2296
+ ),
2297
+ 'KeyPrefixEquals' => array(
2298
+ 'type' => 'string',
2299
+ ),
2300
+ ),
2301
+ ),
2302
+ 'Redirect' => array(
2303
+ 'required' => true,
2304
+ 'type' => 'object',
2305
+ 'properties' => array(
2306
+ 'HostName' => array(
2307
+ 'type' => 'string',
2308
+ ),
2309
+ 'HttpRedirectCode' => array(
2310
+ 'type' => 'string',
2311
+ ),
2312
+ 'Protocol' => array(
2313
+ 'type' => 'string',
2314
+ ),
2315
+ 'ReplaceKeyPrefixWith' => array(
2316
+ 'type' => 'string',
2317
+ ),
2318
+ 'ReplaceKeyWith' => array(
2319
+ 'type' => 'string',
2320
+ ),
2321
+ ),
2322
+ ),
2323
+ ),
2324
+ ),
2325
+ ),
2326
+ ),
2327
+ ),
2328
+ 'PutObject' => array(
2329
+ 'httpMethod' => 'PUT',
2330
+ 'uri' => '/{Bucket}{/Key*}',
2331
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2332
+ 'responseClass' => 'PutObjectOutput',
2333
+ 'responseType' => 'model',
2334
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html',
2335
+ 'data' => array(
2336
+ 'xmlRoot' => array(
2337
+ 'name' => 'PutObjectRequest',
2338
+ 'namespaces' => array(
2339
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2340
+ ),
2341
+ ),
2342
+ ),
2343
+ 'parameters' => array(
2344
+ 'ACL' => array(
2345
+ 'type' => 'string',
2346
+ 'location' => 'header',
2347
+ 'sentAs' => 'x-amz-acl',
2348
+ ),
2349
+ 'Body' => array(
2350
+ 'type' => array(
2351
+ 'string',
2352
+ 'object',
2353
+ ),
2354
+ 'location' => 'body',
2355
+ ),
2356
+ 'Bucket' => array(
2357
+ 'required' => true,
2358
+ 'type' => 'string',
2359
+ 'location' => 'uri',
2360
+ ),
2361
+ 'CacheControl' => array(
2362
+ 'type' => 'string',
2363
+ 'location' => 'header',
2364
+ 'sentAs' => 'Cache-Control',
2365
+ ),
2366
+ 'ContentDisposition' => array(
2367
+ 'type' => 'string',
2368
+ 'location' => 'header',
2369
+ 'sentAs' => 'Content-Disposition',
2370
+ ),
2371
+ 'ContentEncoding' => array(
2372
+ 'type' => 'string',
2373
+ 'location' => 'header',
2374
+ 'sentAs' => 'Content-Encoding',
2375
+ ),
2376
+ 'ContentLanguage' => array(
2377
+ 'type' => 'string',
2378
+ 'location' => 'header',
2379
+ 'sentAs' => 'Content-Language',
2380
+ ),
2381
+ 'ContentLength' => array(
2382
+ 'type' => 'numeric',
2383
+ 'location' => 'header',
2384
+ 'sentAs' => 'Content-Length',
2385
+ ),
2386
+ 'ContentMD5' => array(
2387
+ 'type' => array(
2388
+ 'string',
2389
+ 'boolean',
2390
+ ),
2391
+ 'location' => 'header',
2392
+ 'sentAs' => 'Content-MD5',
2393
+ ),
2394
+ 'ContentType' => array(
2395
+ 'type' => 'string',
2396
+ 'location' => 'header',
2397
+ 'sentAs' => 'Content-Type',
2398
+ ),
2399
+ 'Expires' => array(
2400
+ 'type' => array(
2401
+ 'object',
2402
+ 'string',
2403
+ 'integer',
2404
+ ),
2405
+ 'format' => 'date-time-http',
2406
+ 'location' => 'header',
2407
+ ),
2408
+ 'GrantFullControl' => array(
2409
+ 'type' => 'string',
2410
+ 'location' => 'header',
2411
+ 'sentAs' => 'x-amz-grant-full-control',
2412
+ ),
2413
+ 'GrantRead' => array(
2414
+ 'type' => 'string',
2415
+ 'location' => 'header',
2416
+ 'sentAs' => 'x-amz-grant-read',
2417
+ ),
2418
+ 'GrantReadACP' => array(
2419
+ 'type' => 'string',
2420
+ 'location' => 'header',
2421
+ 'sentAs' => 'x-amz-grant-read-acp',
2422
+ ),
2423
+ 'GrantWriteACP' => array(
2424
+ 'type' => 'string',
2425
+ 'location' => 'header',
2426
+ 'sentAs' => 'x-amz-grant-write-acp',
2427
+ ),
2428
+ 'Key' => array(
2429
+ 'required' => true,
2430
+ 'type' => 'string',
2431
+ 'location' => 'uri',
2432
+ 'filters' => array(
2433
+ 'Aws\\S3\\S3Client::explodeKey',
2434
+ ),
2435
+ ),
2436
+ 'Metadata' => array(
2437
+ 'type' => 'object',
2438
+ 'location' => 'header',
2439
+ 'sentAs' => 'x-amz-meta-',
2440
+ 'additionalProperties' => array(
2441
+ 'type' => 'string',
2442
+ ),
2443
+ ),
2444
+ 'ServerSideEncryption' => array(
2445
+ 'type' => 'string',
2446
+ 'location' => 'header',
2447
+ 'sentAs' => 'x-amz-server-side-encryption',
2448
+ ),
2449
+ 'StorageClass' => array(
2450
+ 'type' => 'string',
2451
+ 'location' => 'header',
2452
+ 'sentAs' => 'x-amz-storage-class',
2453
+ ),
2454
+ 'WebsiteRedirectLocation' => array(
2455
+ 'type' => 'string',
2456
+ 'location' => 'header',
2457
+ 'sentAs' => 'x-amz-website-redirect-location',
2458
+ ),
2459
+ 'SSECustomerAlgorithm' => array(
2460
+ 'type' => 'string',
2461
+ 'location' => 'header',
2462
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
2463
+ ),
2464
+ 'SSECustomerKey' => array(
2465
+ 'type' => 'string',
2466
+ 'location' => 'header',
2467
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key',
2468
+ ),
2469
+ 'SSECustomerKeyMD5' => array(
2470
+ 'type' => 'string',
2471
+ 'location' => 'header',
2472
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
2473
+ ),
2474
+ 'SSEKMSKeyId' => array(
2475
+ 'type' => 'string',
2476
+ 'location' => 'header',
2477
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
2478
+ ),
2479
+ 'RequestPayer' => array(
2480
+ 'type' => 'string',
2481
+ 'location' => 'header',
2482
+ 'sentAs' => 'x-amz-request-payer',
2483
+ ),
2484
+ 'ACP' => array(
2485
+ 'type' => 'object',
2486
+ 'additionalProperties' => true,
2487
+ ),
2488
+ ),
2489
+ ),
2490
+ 'PutObjectAcl' => array(
2491
+ 'httpMethod' => 'PUT',
2492
+ 'uri' => '/{Bucket}{/Key*}?acl',
2493
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2494
+ 'responseClass' => 'PutObjectAclOutput',
2495
+ 'responseType' => 'model',
2496
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUTacl.html',
2497
+ 'data' => array(
2498
+ 'xmlRoot' => array(
2499
+ 'name' => 'AccessControlPolicy',
2500
+ 'namespaces' => array(
2501
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2502
+ ),
2503
+ ),
2504
+ ),
2505
+ 'parameters' => array(
2506
+ 'ACL' => array(
2507
+ 'type' => 'string',
2508
+ 'location' => 'header',
2509
+ 'sentAs' => 'x-amz-acl',
2510
+ ),
2511
+ 'Grants' => array(
2512
+ 'type' => 'array',
2513
+ 'location' => 'xml',
2514
+ 'sentAs' => 'AccessControlList',
2515
+ 'items' => array(
2516
+ 'name' => 'Grant',
2517
+ 'type' => 'object',
2518
+ 'properties' => array(
2519
+ 'Grantee' => array(
2520
+ 'type' => 'object',
2521
+ 'properties' => array(
2522
+ 'DisplayName' => array(
2523
+ 'type' => 'string',
2524
+ ),
2525
+ 'EmailAddress' => array(
2526
+ 'type' => 'string',
2527
+ ),
2528
+ 'ID' => array(
2529
+ 'type' => 'string',
2530
+ ),
2531
+ 'Type' => array(
2532
+ 'required' => true,
2533
+ 'type' => 'string',
2534
+ 'sentAs' => 'xsi:type',
2535
+ 'data' => array(
2536
+ 'xmlAttribute' => true,
2537
+ 'xmlNamespace' => 'http://www.w3.org/2001/XMLSchema-instance',
2538
+ ),
2539
+ ),
2540
+ 'URI' => array(
2541
+ 'type' => 'string',
2542
+ ),
2543
+ ),
2544
+ ),
2545
+ 'Permission' => array(
2546
+ 'type' => 'string',
2547
+ ),
2548
+ ),
2549
+ ),
2550
+ ),
2551
+ 'Owner' => array(
2552
+ 'type' => 'object',
2553
+ 'location' => 'xml',
2554
+ 'properties' => array(
2555
+ 'DisplayName' => array(
2556
+ 'type' => 'string',
2557
+ ),
2558
+ 'ID' => array(
2559
+ 'type' => 'string',
2560
+ ),
2561
+ ),
2562
+ ),
2563
+ 'Bucket' => array(
2564
+ 'required' => true,
2565
+ 'type' => 'string',
2566
+ 'location' => 'uri',
2567
+ ),
2568
+ 'GrantFullControl' => array(
2569
+ 'type' => 'string',
2570
+ 'location' => 'header',
2571
+ 'sentAs' => 'x-amz-grant-full-control',
2572
+ ),
2573
+ 'GrantRead' => array(
2574
+ 'type' => 'string',
2575
+ 'location' => 'header',
2576
+ 'sentAs' => 'x-amz-grant-read',
2577
+ ),
2578
+ 'GrantReadACP' => array(
2579
+ 'type' => 'string',
2580
+ 'location' => 'header',
2581
+ 'sentAs' => 'x-amz-grant-read-acp',
2582
+ ),
2583
+ 'GrantWrite' => array(
2584
+ 'type' => 'string',
2585
+ 'location' => 'header',
2586
+ 'sentAs' => 'x-amz-grant-write',
2587
+ ),
2588
+ 'GrantWriteACP' => array(
2589
+ 'type' => 'string',
2590
+ 'location' => 'header',
2591
+ 'sentAs' => 'x-amz-grant-write-acp',
2592
+ ),
2593
+ 'Key' => array(
2594
+ 'required' => true,
2595
+ 'type' => 'string',
2596
+ 'location' => 'uri',
2597
+ 'filters' => array(
2598
+ 'Aws\\S3\\S3Client::explodeKey',
2599
+ ),
2600
+ ),
2601
+ 'RequestPayer' => array(
2602
+ 'type' => 'string',
2603
+ 'location' => 'header',
2604
+ 'sentAs' => 'x-amz-request-payer',
2605
+ ),
2606
+ 'ACP' => array(
2607
+ 'type' => 'object',
2608
+ 'additionalProperties' => true,
2609
+ ),
2610
+ ),
2611
+ 'errorResponses' => array(
2612
+ array(
2613
+ 'reason' => 'The specified key does not exist.',
2614
+ 'class' => 'NoSuchKeyException',
2615
+ ),
2616
+ ),
2617
+ ),
2618
+ 'RestoreObject' => array(
2619
+ 'httpMethod' => 'POST',
2620
+ 'uri' => '/{Bucket}{/Key*}?restore',
2621
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2622
+ 'responseClass' => 'RestoreObjectOutput',
2623
+ 'responseType' => 'model',
2624
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectRestore.html',
2625
+ 'data' => array(
2626
+ 'xmlRoot' => array(
2627
+ 'name' => 'RestoreRequest',
2628
+ 'namespaces' => array(
2629
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2630
+ ),
2631
+ ),
2632
+ ),
2633
+ 'parameters' => array(
2634
+ 'Bucket' => array(
2635
+ 'required' => true,
2636
+ 'type' => 'string',
2637
+ 'location' => 'uri',
2638
+ ),
2639
+ 'Key' => array(
2640
+ 'required' => true,
2641
+ 'type' => 'string',
2642
+ 'location' => 'uri',
2643
+ 'filters' => array(
2644
+ 'Aws\\S3\\S3Client::explodeKey',
2645
+ ),
2646
+ ),
2647
+ 'VersionId' => array(
2648
+ 'type' => 'string',
2649
+ 'location' => 'query',
2650
+ 'sentAs' => 'versionId',
2651
+ ),
2652
+ 'Days' => array(
2653
+ 'required' => true,
2654
+ 'type' => 'numeric',
2655
+ 'location' => 'xml',
2656
+ ),
2657
+ 'RequestPayer' => array(
2658
+ 'type' => 'string',
2659
+ 'location' => 'header',
2660
+ 'sentAs' => 'x-amz-request-payer',
2661
+ ),
2662
+ ),
2663
+ 'errorResponses' => array(
2664
+ array(
2665
+ 'reason' => 'This operation is not allowed against this storage tier',
2666
+ 'class' => 'ObjectAlreadyInActiveTierErrorException',
2667
+ ),
2668
+ ),
2669
+ ),
2670
+ 'UploadPart' => array(
2671
+ 'httpMethod' => 'PUT',
2672
+ 'uri' => '/{Bucket}{/Key*}',
2673
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2674
+ 'responseClass' => 'UploadPartOutput',
2675
+ 'responseType' => 'model',
2676
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPart.html',
2677
+ 'data' => array(
2678
+ 'xmlRoot' => array(
2679
+ 'name' => 'UploadPartRequest',
2680
+ 'namespaces' => array(
2681
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2682
+ ),
2683
+ ),
2684
+ ),
2685
+ 'parameters' => array(
2686
+ 'Body' => array(
2687
+ 'type' => array(
2688
+ 'string',
2689
+ 'object',
2690
+ ),
2691
+ 'location' => 'body',
2692
+ ),
2693
+ 'Bucket' => array(
2694
+ 'required' => true,
2695
+ 'type' => 'string',
2696
+ 'location' => 'uri',
2697
+ ),
2698
+ 'ContentLength' => array(
2699
+ 'type' => 'numeric',
2700
+ 'location' => 'header',
2701
+ 'sentAs' => 'Content-Length',
2702
+ ),
2703
+ 'ContentMD5' => array(
2704
+ 'type' => array(
2705
+ 'string',
2706
+ 'boolean',
2707
+ ),
2708
+ 'location' => 'header',
2709
+ 'sentAs' => 'Content-MD5',
2710
+ ),
2711
+ 'Key' => array(
2712
+ 'required' => true,
2713
+ 'type' => 'string',
2714
+ 'location' => 'uri',
2715
+ 'filters' => array(
2716
+ 'Aws\\S3\\S3Client::explodeKey',
2717
+ ),
2718
+ ),
2719
+ 'PartNumber' => array(
2720
+ 'required' => true,
2721
+ 'type' => 'numeric',
2722
+ 'location' => 'query',
2723
+ 'sentAs' => 'partNumber',
2724
+ ),
2725
+ 'UploadId' => array(
2726
+ 'required' => true,
2727
+ 'type' => 'string',
2728
+ 'location' => 'query',
2729
+ 'sentAs' => 'uploadId',
2730
+ ),
2731
+ 'SSECustomerAlgorithm' => array(
2732
+ 'type' => 'string',
2733
+ 'location' => 'header',
2734
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
2735
+ ),
2736
+ 'SSECustomerKey' => array(
2737
+ 'type' => 'string',
2738
+ 'location' => 'header',
2739
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key',
2740
+ ),
2741
+ 'SSECustomerKeyMD5' => array(
2742
+ 'type' => 'string',
2743
+ 'location' => 'header',
2744
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
2745
+ ),
2746
+ 'RequestPayer' => array(
2747
+ 'type' => 'string',
2748
+ 'location' => 'header',
2749
+ 'sentAs' => 'x-amz-request-payer',
2750
+ ),
2751
+ ),
2752
+ ),
2753
+ 'UploadPartCopy' => array(
2754
+ 'httpMethod' => 'PUT',
2755
+ 'uri' => '/{Bucket}{/Key*}',
2756
+ 'class' => 'Aws\\S3\\Command\\S3Command',
2757
+ 'responseClass' => 'UploadPartCopyOutput',
2758
+ 'responseType' => 'model',
2759
+ 'documentationUrl' => 'http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPartCopy.html',
2760
+ 'data' => array(
2761
+ 'xmlRoot' => array(
2762
+ 'name' => 'UploadPartCopyRequest',
2763
+ 'namespaces' => array(
2764
+ 'http://s3.amazonaws.com/doc/2006-03-01/',
2765
+ ),
2766
+ ),
2767
+ ),
2768
+ 'parameters' => array(
2769
+ 'Bucket' => array(
2770
+ 'required' => true,
2771
+ 'type' => 'string',
2772
+ 'location' => 'uri',
2773
+ ),
2774
+ 'CopySource' => array(
2775
+ 'required' => true,
2776
+ 'type' => 'string',
2777
+ 'location' => 'header',
2778
+ 'sentAs' => 'x-amz-copy-source',
2779
+ ),
2780
+ 'CopySourceIfMatch' => array(
2781
+ 'type' => 'string',
2782
+ 'location' => 'header',
2783
+ 'sentAs' => 'x-amz-copy-source-if-match',
2784
+ ),
2785
+ 'CopySourceIfModifiedSince' => array(
2786
+ 'type' => array(
2787
+ 'object',
2788
+ 'string',
2789
+ 'integer',
2790
+ ),
2791
+ 'format' => 'date-time-http',
2792
+ 'location' => 'header',
2793
+ 'sentAs' => 'x-amz-copy-source-if-modified-since',
2794
+ ),
2795
+ 'CopySourceIfNoneMatch' => array(
2796
+ 'type' => 'string',
2797
+ 'location' => 'header',
2798
+ 'sentAs' => 'x-amz-copy-source-if-none-match',
2799
+ ),
2800
+ 'CopySourceIfUnmodifiedSince' => array(
2801
+ 'type' => array(
2802
+ 'object',
2803
+ 'string',
2804
+ 'integer',
2805
+ ),
2806
+ 'format' => 'date-time-http',
2807
+ 'location' => 'header',
2808
+ 'sentAs' => 'x-amz-copy-source-if-unmodified-since',
2809
+ ),
2810
+ 'CopySourceRange' => array(
2811
+ 'type' => 'string',
2812
+ 'location' => 'header',
2813
+ 'sentAs' => 'x-amz-copy-source-range',
2814
+ ),
2815
+ 'Key' => array(
2816
+ 'required' => true,
2817
+ 'type' => 'string',
2818
+ 'location' => 'uri',
2819
+ 'filters' => array(
2820
+ 'Aws\\S3\\S3Client::explodeKey',
2821
+ ),
2822
+ ),
2823
+ 'PartNumber' => array(
2824
+ 'required' => true,
2825
+ 'type' => 'numeric',
2826
+ 'location' => 'query',
2827
+ 'sentAs' => 'partNumber',
2828
+ ),
2829
+ 'UploadId' => array(
2830
+ 'required' => true,
2831
+ 'type' => 'string',
2832
+ 'location' => 'query',
2833
+ 'sentAs' => 'uploadId',
2834
+ ),
2835
+ 'SSECustomerAlgorithm' => array(
2836
+ 'type' => 'string',
2837
+ 'location' => 'header',
2838
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
2839
+ ),
2840
+ 'SSECustomerKey' => array(
2841
+ 'type' => 'string',
2842
+ 'location' => 'header',
2843
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key',
2844
+ ),
2845
+ 'SSECustomerKeyMD5' => array(
2846
+ 'type' => 'string',
2847
+ 'location' => 'header',
2848
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
2849
+ ),
2850
+ 'CopySourceSSECustomerAlgorithm' => array(
2851
+ 'type' => 'string',
2852
+ 'location' => 'header',
2853
+ 'sentAs' => 'x-amz-copy-source-server-side-encryption-customer-algorithm',
2854
+ ),
2855
+ 'CopySourceSSECustomerKey' => array(
2856
+ 'type' => 'string',
2857
+ 'location' => 'header',
2858
+ 'sentAs' => 'x-amz-copy-source-server-side-encryption-customer-key',
2859
+ ),
2860
+ 'CopySourceSSECustomerKeyMD5' => array(
2861
+ 'type' => 'string',
2862
+ 'location' => 'header',
2863
+ 'sentAs' => 'x-amz-copy-source-server-side-encryption-customer-key-MD5',
2864
+ ),
2865
+ 'RequestPayer' => array(
2866
+ 'type' => 'string',
2867
+ 'location' => 'header',
2868
+ 'sentAs' => 'x-amz-request-payer',
2869
+ ),
2870
+ 'command.expects' => array(
2871
+ 'static' => true,
2872
+ 'default' => 'application/xml',
2873
+ ),
2874
+ ),
2875
+ ),
2876
+ ),
2877
+ 'models' => array(
2878
+ 'AbortMultipartUploadOutput' => array(
2879
+ 'type' => 'object',
2880
+ 'additionalProperties' => true,
2881
+ 'properties' => array(
2882
+ 'RequestCharged' => array(
2883
+ 'type' => 'string',
2884
+ 'location' => 'header',
2885
+ 'sentAs' => 'x-amz-request-charged',
2886
+ ),
2887
+ 'RequestId' => array(
2888
+ 'location' => 'header',
2889
+ 'sentAs' => 'x-amz-request-id',
2890
+ ),
2891
+ ),
2892
+ ),
2893
+ 'CompleteMultipartUploadOutput' => array(
2894
+ 'type' => 'object',
2895
+ 'additionalProperties' => true,
2896
+ 'properties' => array(
2897
+ 'Location' => array(
2898
+ 'type' => 'string',
2899
+ 'location' => 'xml',
2900
+ ),
2901
+ 'Bucket' => array(
2902
+ 'type' => 'string',
2903
+ 'location' => 'xml',
2904
+ ),
2905
+ 'Key' => array(
2906
+ 'type' => 'string',
2907
+ 'location' => 'xml',
2908
+ ),
2909
+ 'Expiration' => array(
2910
+ 'type' => 'string',
2911
+ 'location' => 'header',
2912
+ 'sentAs' => 'x-amz-expiration',
2913
+ ),
2914
+ 'ETag' => array(
2915
+ 'type' => 'string',
2916
+ 'location' => 'xml',
2917
+ ),
2918
+ 'ServerSideEncryption' => array(
2919
+ 'type' => 'string',
2920
+ 'location' => 'header',
2921
+ 'sentAs' => 'x-amz-server-side-encryption',
2922
+ ),
2923
+ 'VersionId' => array(
2924
+ 'type' => 'string',
2925
+ 'location' => 'header',
2926
+ 'sentAs' => 'x-amz-version-id',
2927
+ ),
2928
+ 'SSEKMSKeyId' => array(
2929
+ 'type' => 'string',
2930
+ 'location' => 'header',
2931
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
2932
+ ),
2933
+ 'RequestCharged' => array(
2934
+ 'type' => 'string',
2935
+ 'location' => 'header',
2936
+ 'sentAs' => 'x-amz-request-charged',
2937
+ ),
2938
+ 'RequestId' => array(
2939
+ 'location' => 'header',
2940
+ 'sentAs' => 'x-amz-request-id',
2941
+ ),
2942
+ ),
2943
+ ),
2944
+ 'CopyObjectOutput' => array(
2945
+ 'type' => 'object',
2946
+ 'additionalProperties' => true,
2947
+ 'properties' => array(
2948
+ 'ETag' => array(
2949
+ 'type' => 'string',
2950
+ 'location' => 'xml',
2951
+ ),
2952
+ 'LastModified' => array(
2953
+ 'type' => 'string',
2954
+ 'location' => 'xml',
2955
+ ),
2956
+ 'Expiration' => array(
2957
+ 'type' => 'string',
2958
+ 'location' => 'header',
2959
+ 'sentAs' => 'x-amz-expiration',
2960
+ ),
2961
+ 'CopySourceVersionId' => array(
2962
+ 'type' => 'string',
2963
+ 'location' => 'header',
2964
+ 'sentAs' => 'x-amz-copy-source-version-id',
2965
+ ),
2966
+ 'ServerSideEncryption' => array(
2967
+ 'type' => 'string',
2968
+ 'location' => 'header',
2969
+ 'sentAs' => 'x-amz-server-side-encryption',
2970
+ ),
2971
+ 'SSECustomerAlgorithm' => array(
2972
+ 'type' => 'string',
2973
+ 'location' => 'header',
2974
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
2975
+ ),
2976
+ 'SSECustomerKeyMD5' => array(
2977
+ 'type' => 'string',
2978
+ 'location' => 'header',
2979
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
2980
+ ),
2981
+ 'SSEKMSKeyId' => array(
2982
+ 'type' => 'string',
2983
+ 'location' => 'header',
2984
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
2985
+ ),
2986
+ 'RequestCharged' => array(
2987
+ 'type' => 'string',
2988
+ 'location' => 'header',
2989
+ 'sentAs' => 'x-amz-request-charged',
2990
+ ),
2991
+ 'RequestId' => array(
2992
+ 'location' => 'header',
2993
+ 'sentAs' => 'x-amz-request-id',
2994
+ ),
2995
+ ),
2996
+ ),
2997
+ 'CreateBucketOutput' => array(
2998
+ 'type' => 'object',
2999
+ 'additionalProperties' => true,
3000
+ 'properties' => array(
3001
+ 'Location' => array(
3002
+ 'type' => 'string',
3003
+ 'location' => 'header',
3004
+ ),
3005
+ 'RequestId' => array(
3006
+ 'location' => 'header',
3007
+ 'sentAs' => 'x-amz-request-id',
3008
+ ),
3009
+ ),
3010
+ ),
3011
+ 'CreateMultipartUploadOutput' => array(
3012
+ 'type' => 'object',
3013
+ 'additionalProperties' => true,
3014
+ 'properties' => array(
3015
+ 'Bucket' => array(
3016
+ 'type' => 'string',
3017
+ 'location' => 'xml',
3018
+ 'sentAs' => 'Bucket',
3019
+ ),
3020
+ 'Key' => array(
3021
+ 'type' => 'string',
3022
+ 'location' => 'xml',
3023
+ ),
3024
+ 'UploadId' => array(
3025
+ 'type' => 'string',
3026
+ 'location' => 'xml',
3027
+ ),
3028
+ 'ServerSideEncryption' => array(
3029
+ 'type' => 'string',
3030
+ 'location' => 'header',
3031
+ 'sentAs' => 'x-amz-server-side-encryption',
3032
+ ),
3033
+ 'SSECustomerAlgorithm' => array(
3034
+ 'type' => 'string',
3035
+ 'location' => 'header',
3036
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
3037
+ ),
3038
+ 'SSECustomerKeyMD5' => array(
3039
+ 'type' => 'string',
3040
+ 'location' => 'header',
3041
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
3042
+ ),
3043
+ 'SSEKMSKeyId' => array(
3044
+ 'type' => 'string',
3045
+ 'location' => 'header',
3046
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
3047
+ ),
3048
+ 'RequestCharged' => array(
3049
+ 'type' => 'string',
3050
+ 'location' => 'header',
3051
+ 'sentAs' => 'x-amz-request-charged',
3052
+ ),
3053
+ 'RequestId' => array(
3054
+ 'location' => 'header',
3055
+ 'sentAs' => 'x-amz-request-id',
3056
+ ),
3057
+ ),
3058
+ ),
3059
+ 'DeleteBucketOutput' => array(
3060
+ 'type' => 'object',
3061
+ 'additionalProperties' => true,
3062
+ 'properties' => array(
3063
+ 'RequestId' => array(
3064
+ 'location' => 'header',
3065
+ 'sentAs' => 'x-amz-request-id',
3066
+ ),
3067
+ ),
3068
+ ),
3069
+ 'DeleteBucketCorsOutput' => array(
3070
+ 'type' => 'object',
3071
+ 'additionalProperties' => true,
3072
+ 'properties' => array(
3073
+ 'RequestId' => array(
3074
+ 'location' => 'header',
3075
+ 'sentAs' => 'x-amz-request-id',
3076
+ ),
3077
+ ),
3078
+ ),
3079
+ 'DeleteBucketLifecycleOutput' => array(
3080
+ 'type' => 'object',
3081
+ 'additionalProperties' => true,
3082
+ 'properties' => array(
3083
+ 'RequestId' => array(
3084
+ 'location' => 'header',
3085
+ 'sentAs' => 'x-amz-request-id',
3086
+ ),
3087
+ ),
3088
+ ),
3089
+ 'DeleteBucketPolicyOutput' => array(
3090
+ 'type' => 'object',
3091
+ 'additionalProperties' => true,
3092
+ 'properties' => array(
3093
+ 'RequestId' => array(
3094
+ 'location' => 'header',
3095
+ 'sentAs' => 'x-amz-request-id',
3096
+ ),
3097
+ ),
3098
+ ),
3099
+ 'DeleteBucketReplicationOutput' => array(
3100
+ 'type' => 'object',
3101
+ 'additionalProperties' => true,
3102
+ 'properties' => array(
3103
+ 'RequestId' => array(
3104
+ 'location' => 'header',
3105
+ 'sentAs' => 'x-amz-request-id',
3106
+ ),
3107
+ ),
3108
+ ),
3109
+ 'DeleteBucketTaggingOutput' => array(
3110
+ 'type' => 'object',
3111
+ 'additionalProperties' => true,
3112
+ 'properties' => array(
3113
+ 'RequestId' => array(
3114
+ 'location' => 'header',
3115
+ 'sentAs' => 'x-amz-request-id',
3116
+ ),
3117
+ ),
3118
+ ),
3119
+ 'DeleteBucketWebsiteOutput' => array(
3120
+ 'type' => 'object',
3121
+ 'additionalProperties' => true,
3122
+ 'properties' => array(
3123
+ 'RequestId' => array(
3124
+ 'location' => 'header',
3125
+ 'sentAs' => 'x-amz-request-id',
3126
+ ),
3127
+ ),
3128
+ ),
3129
+ 'DeleteObjectOutput' => array(
3130
+ 'type' => 'object',
3131
+ 'additionalProperties' => true,
3132
+ 'properties' => array(
3133
+ 'DeleteMarker' => array(
3134
+ 'type' => 'boolean',
3135
+ 'location' => 'header',
3136
+ 'sentAs' => 'x-amz-delete-marker',
3137
+ ),
3138
+ 'VersionId' => array(
3139
+ 'type' => 'string',
3140
+ 'location' => 'header',
3141
+ 'sentAs' => 'x-amz-version-id',
3142
+ ),
3143
+ 'RequestCharged' => array(
3144
+ 'type' => 'string',
3145
+ 'location' => 'header',
3146
+ 'sentAs' => 'x-amz-request-charged',
3147
+ ),
3148
+ 'RequestId' => array(
3149
+ 'location' => 'header',
3150
+ 'sentAs' => 'x-amz-request-id',
3151
+ ),
3152
+ ),
3153
+ ),
3154
+ 'DeleteObjectsOutput' => array(
3155
+ 'type' => 'object',
3156
+ 'additionalProperties' => true,
3157
+ 'properties' => array(
3158
+ 'Deleted' => array(
3159
+ 'type' => 'array',
3160
+ 'location' => 'xml',
3161
+ 'data' => array(
3162
+ 'xmlFlattened' => true,
3163
+ ),
3164
+ 'items' => array(
3165
+ 'name' => 'DeletedObject',
3166
+ 'type' => 'object',
3167
+ 'properties' => array(
3168
+ 'Key' => array(
3169
+ 'type' => 'string',
3170
+ ),
3171
+ 'VersionId' => array(
3172
+ 'type' => 'string',
3173
+ ),
3174
+ 'DeleteMarker' => array(
3175
+ 'type' => 'boolean',
3176
+ ),
3177
+ 'DeleteMarkerVersionId' => array(
3178
+ 'type' => 'string',
3179
+ ),
3180
+ ),
3181
+ ),
3182
+ ),
3183
+ 'RequestCharged' => array(
3184
+ 'type' => 'string',
3185
+ 'location' => 'header',
3186
+ 'sentAs' => 'x-amz-request-charged',
3187
+ ),
3188
+ 'Errors' => array(
3189
+ 'type' => 'array',
3190
+ 'location' => 'xml',
3191
+ 'sentAs' => 'Error',
3192
+ 'data' => array(
3193
+ 'xmlFlattened' => true,
3194
+ ),
3195
+ 'items' => array(
3196
+ 'name' => 'Error',
3197
+ 'type' => 'object',
3198
+ 'sentAs' => 'Error',
3199
+ 'properties' => array(
3200
+ 'Key' => array(
3201
+ 'type' => 'string',
3202
+ ),
3203
+ 'VersionId' => array(
3204
+ 'type' => 'string',
3205
+ ),
3206
+ 'Code' => array(
3207
+ 'type' => 'string',
3208
+ ),
3209
+ 'Message' => array(
3210
+ 'type' => 'string',
3211
+ ),
3212
+ ),
3213
+ ),
3214
+ ),
3215
+ 'RequestId' => array(
3216
+ 'location' => 'header',
3217
+ 'sentAs' => 'x-amz-request-id',
3218
+ ),
3219
+ ),
3220
+ ),
3221
+ 'GetBucketAclOutput' => array(
3222
+ 'type' => 'object',
3223
+ 'additionalProperties' => true,
3224
+ 'properties' => array(
3225
+ 'Owner' => array(
3226
+ 'type' => 'object',
3227
+ 'location' => 'xml',
3228
+ 'properties' => array(
3229
+ 'DisplayName' => array(
3230
+ 'type' => 'string',
3231
+ ),
3232
+ 'ID' => array(
3233
+ 'type' => 'string',
3234
+ ),
3235
+ ),
3236
+ ),
3237
+ 'Grants' => array(
3238
+ 'type' => 'array',
3239
+ 'location' => 'xml',
3240
+ 'sentAs' => 'AccessControlList',
3241
+ 'items' => array(
3242
+ 'name' => 'Grant',
3243
+ 'type' => 'object',
3244
+ 'sentAs' => 'Grant',
3245
+ 'properties' => array(
3246
+ 'Grantee' => array(
3247
+ 'type' => 'object',
3248
+ 'properties' => array(
3249
+ 'DisplayName' => array(
3250
+ 'type' => 'string',
3251
+ ),
3252
+ 'EmailAddress' => array(
3253
+ 'type' => 'string',
3254
+ ),
3255
+ 'ID' => array(
3256
+ 'type' => 'string',
3257
+ ),
3258
+ 'Type' => array(
3259
+ 'type' => 'string',
3260
+ 'sentAs' => 'xsi:type',
3261
+ 'data' => array(
3262
+ 'xmlAttribute' => true,
3263
+ 'xmlNamespace' => 'http://www.w3.org/2001/XMLSchema-instance',
3264
+ ),
3265
+ ),
3266
+ 'URI' => array(
3267
+ 'type' => 'string',
3268
+ ),
3269
+ ),
3270
+ ),
3271
+ 'Permission' => array(
3272
+ 'type' => 'string',
3273
+ ),
3274
+ ),
3275
+ ),
3276
+ ),
3277
+ 'RequestId' => array(
3278
+ 'location' => 'header',
3279
+ 'sentAs' => 'x-amz-request-id',
3280
+ ),
3281
+ ),
3282
+ ),
3283
+ 'GetBucketCorsOutput' => array(
3284
+ 'type' => 'object',
3285
+ 'additionalProperties' => true,
3286
+ 'properties' => array(
3287
+ 'CORSRules' => array(
3288
+ 'type' => 'array',
3289
+ 'location' => 'xml',
3290
+ 'sentAs' => 'CORSRule',
3291
+ 'data' => array(
3292
+ 'xmlFlattened' => true,
3293
+ ),
3294
+ 'items' => array(
3295
+ 'name' => 'CORSRule',
3296
+ 'type' => 'object',
3297
+ 'sentAs' => 'CORSRule',
3298
+ 'properties' => array(
3299
+ 'AllowedHeaders' => array(
3300
+ 'type' => 'array',
3301
+ 'sentAs' => 'AllowedHeader',
3302
+ 'data' => array(
3303
+ 'xmlFlattened' => true,
3304
+ ),
3305
+ 'items' => array(
3306
+ 'name' => 'AllowedHeader',
3307
+ 'type' => 'string',
3308
+ 'sentAs' => 'AllowedHeader',
3309
+ ),
3310
+ ),
3311
+ 'AllowedMethods' => array(
3312
+ 'type' => 'array',
3313
+ 'sentAs' => 'AllowedMethod',
3314
+ 'data' => array(
3315
+ 'xmlFlattened' => true,
3316
+ ),
3317
+ 'items' => array(
3318
+ 'name' => 'AllowedMethod',
3319
+ 'type' => 'string',
3320
+ 'sentAs' => 'AllowedMethod',
3321
+ ),
3322
+ ),
3323
+ 'AllowedOrigins' => array(
3324
+ 'type' => 'array',
3325
+ 'sentAs' => 'AllowedOrigin',
3326
+ 'data' => array(
3327
+ 'xmlFlattened' => true,
3328
+ ),
3329
+ 'items' => array(
3330
+ 'name' => 'AllowedOrigin',
3331
+ 'type' => 'string',
3332
+ 'sentAs' => 'AllowedOrigin',
3333
+ ),
3334
+ ),
3335
+ 'ExposeHeaders' => array(
3336
+ 'type' => 'array',
3337
+ 'sentAs' => 'ExposeHeader',
3338
+ 'data' => array(
3339
+ 'xmlFlattened' => true,
3340
+ ),
3341
+ 'items' => array(
3342
+ 'name' => 'ExposeHeader',
3343
+ 'type' => 'string',
3344
+ 'sentAs' => 'ExposeHeader',
3345
+ ),
3346
+ ),
3347
+ 'MaxAgeSeconds' => array(
3348
+ 'type' => 'numeric',
3349
+ ),
3350
+ ),
3351
+ ),
3352
+ ),
3353
+ 'RequestId' => array(
3354
+ 'location' => 'header',
3355
+ 'sentAs' => 'x-amz-request-id',
3356
+ ),
3357
+ ),
3358
+ ),
3359
+ 'GetBucketLifecycleOutput' => array(
3360
+ 'type' => 'object',
3361
+ 'additionalProperties' => true,
3362
+ 'properties' => array(
3363
+ 'Rules' => array(
3364
+ 'type' => 'array',
3365
+ 'location' => 'xml',
3366
+ 'sentAs' => 'Rule',
3367
+ 'data' => array(
3368
+ 'xmlFlattened' => true,
3369
+ ),
3370
+ 'items' => array(
3371
+ 'name' => 'Rule',
3372
+ 'type' => 'object',
3373
+ 'sentAs' => 'Rule',
3374
+ 'properties' => array(
3375
+ 'Expiration' => array(
3376
+ 'type' => 'object',
3377
+ 'properties' => array(
3378
+ 'Date' => array(
3379
+ 'type' => 'string',
3380
+ ),
3381
+ 'Days' => array(
3382
+ 'type' => 'numeric',
3383
+ ),
3384
+ ),
3385
+ ),
3386
+ 'ID' => array(
3387
+ 'type' => 'string',
3388
+ ),
3389
+ 'Prefix' => array(
3390
+ 'type' => 'string',
3391
+ ),
3392
+ 'Status' => array(
3393
+ 'type' => 'string',
3394
+ ),
3395
+ 'Transition' => array(
3396
+ 'type' => 'object',
3397
+ 'properties' => array(
3398
+ 'Date' => array(
3399
+ 'type' => 'string',
3400
+ ),
3401
+ 'Days' => array(
3402
+ 'type' => 'numeric',
3403
+ ),
3404
+ 'StorageClass' => array(
3405
+ 'type' => 'string',
3406
+ ),
3407
+ ),
3408
+ ),
3409
+ 'NoncurrentVersionTransition' => array(
3410
+ 'type' => 'object',
3411
+ 'properties' => array(
3412
+ 'NoncurrentDays' => array(
3413
+ 'type' => 'numeric',
3414
+ ),
3415
+ 'StorageClass' => array(
3416
+ 'type' => 'string',
3417
+ ),
3418
+ ),
3419
+ ),
3420
+ 'NoncurrentVersionExpiration' => array(
3421
+ 'type' => 'object',
3422
+ 'properties' => array(
3423
+ 'NoncurrentDays' => array(
3424
+ 'type' => 'numeric',
3425
+ ),
3426
+ ),
3427
+ ),
3428
+ ),
3429
+ ),
3430
+ ),
3431
+ 'RequestId' => array(
3432
+ 'location' => 'header',
3433
+ 'sentAs' => 'x-amz-request-id',
3434
+ ),
3435
+ ),
3436
+ ),
3437
+ 'GetBucketLocationOutput' => array(
3438
+ 'type' => 'object',
3439
+ 'additionalProperties' => true,
3440
+ 'properties' => array(
3441
+ 'Location' => array(
3442
+ 'type' => 'string',
3443
+ 'location' => 'body',
3444
+ 'filters' => array(
3445
+ 'strval',
3446
+ 'strip_tags',
3447
+ 'trim',
3448
+ ),
3449
+ ),
3450
+ ),
3451
+ ),
3452
+ 'GetBucketLoggingOutput' => array(
3453
+ 'type' => 'object',
3454
+ 'additionalProperties' => true,
3455
+ 'properties' => array(
3456
+ 'LoggingEnabled' => array(
3457
+ 'type' => 'object',
3458
+ 'location' => 'xml',
3459
+ 'properties' => array(
3460
+ 'TargetBucket' => array(
3461
+ 'type' => 'string',
3462
+ ),
3463
+ 'TargetGrants' => array(
3464
+ 'type' => 'array',
3465
+ 'items' => array(
3466
+ 'name' => 'Grant',
3467
+ 'type' => 'object',
3468
+ 'sentAs' => 'Grant',
3469
+ 'properties' => array(
3470
+ 'Grantee' => array(
3471
+ 'type' => 'object',
3472
+ 'properties' => array(
3473
+ 'DisplayName' => array(
3474
+ 'type' => 'string',
3475
+ ),
3476
+ 'EmailAddress' => array(
3477
+ 'type' => 'string',
3478
+ ),
3479
+ 'ID' => array(
3480
+ 'type' => 'string',
3481
+ ),
3482
+ 'Type' => array(
3483
+ 'type' => 'string',
3484
+ 'sentAs' => 'xsi:type',
3485
+ 'data' => array(
3486
+ 'xmlAttribute' => true,
3487
+ 'xmlNamespace' => 'http://www.w3.org/2001/XMLSchema-instance',
3488
+ ),
3489
+ ),
3490
+ 'URI' => array(
3491
+ 'type' => 'string',
3492
+ ),
3493
+ ),
3494
+ ),
3495
+ 'Permission' => array(
3496
+ 'type' => 'string',
3497
+ ),
3498
+ ),
3499
+ ),
3500
+ ),
3501
+ 'TargetPrefix' => array(
3502
+ 'type' => 'string',
3503
+ ),
3504
+ ),
3505
+ ),
3506
+ 'RequestId' => array(
3507
+ 'location' => 'header',
3508
+ 'sentAs' => 'x-amz-request-id',
3509
+ ),
3510
+ ),
3511
+ ),
3512
+ 'GetBucketNotificationOutput' => array(
3513
+ 'type' => 'object',
3514
+ 'additionalProperties' => true,
3515
+ 'properties' => array(
3516
+ 'TopicConfiguration' => array(
3517
+ 'type' => 'object',
3518
+ 'location' => 'xml',
3519
+ 'properties' => array(
3520
+ 'Id' => array(
3521
+ 'type' => 'string',
3522
+ ),
3523
+ 'Events' => array(
3524
+ 'type' => 'array',
3525
+ 'sentAs' => 'Event',
3526
+ 'data' => array(
3527
+ 'xmlFlattened' => true,
3528
+ ),
3529
+ 'items' => array(
3530
+ 'name' => 'Event',
3531
+ 'type' => 'string',
3532
+ 'sentAs' => 'Event',
3533
+ ),
3534
+ ),
3535
+ 'Event' => array(
3536
+ 'type' => 'string',
3537
+ ),
3538
+ 'Topic' => array(
3539
+ 'type' => 'string',
3540
+ ),
3541
+ ),
3542
+ ),
3543
+ 'QueueConfiguration' => array(
3544
+ 'type' => 'object',
3545
+ 'location' => 'xml',
3546
+ 'properties' => array(
3547
+ 'Id' => array(
3548
+ 'type' => 'string',
3549
+ ),
3550
+ 'Event' => array(
3551
+ 'type' => 'string',
3552
+ ),
3553
+ 'Events' => array(
3554
+ 'type' => 'array',
3555
+ 'sentAs' => 'Event',
3556
+ 'data' => array(
3557
+ 'xmlFlattened' => true,
3558
+ ),
3559
+ 'items' => array(
3560
+ 'name' => 'Event',
3561
+ 'type' => 'string',
3562
+ 'sentAs' => 'Event',
3563
+ ),
3564
+ ),
3565
+ 'Queue' => array(
3566
+ 'type' => 'string',
3567
+ ),
3568
+ ),
3569
+ ),
3570
+ 'CloudFunctionConfiguration' => array(
3571
+ 'type' => 'object',
3572
+ 'location' => 'xml',
3573
+ 'properties' => array(
3574
+ 'Id' => array(
3575
+ 'type' => 'string',
3576
+ ),
3577
+ 'Event' => array(
3578
+ 'type' => 'string',
3579
+ ),
3580
+ 'Events' => array(
3581
+ 'type' => 'array',
3582
+ 'sentAs' => 'Event',
3583
+ 'data' => array(
3584
+ 'xmlFlattened' => true,
3585
+ ),
3586
+ 'items' => array(
3587
+ 'name' => 'Event',
3588
+ 'type' => 'string',
3589
+ 'sentAs' => 'Event',
3590
+ ),
3591
+ ),
3592
+ 'CloudFunction' => array(
3593
+ 'type' => 'string',
3594
+ ),
3595
+ 'InvocationRole' => array(
3596
+ 'type' => 'string',
3597
+ ),
3598
+ ),
3599
+ ),
3600
+ 'RequestId' => array(
3601
+ 'location' => 'header',
3602
+ 'sentAs' => 'x-amz-request-id',
3603
+ ),
3604
+ ),
3605
+ ),
3606
+ 'GetBucketPolicyOutput' => array(
3607
+ 'type' => 'object',
3608
+ 'additionalProperties' => true,
3609
+ 'properties' => array(
3610
+ 'Policy' => array(
3611
+ 'type' => 'string',
3612
+ 'instanceOf' => 'Guzzle\\Http\\EntityBody',
3613
+ 'location' => 'body',
3614
+ ),
3615
+ 'RequestId' => array(
3616
+ 'location' => 'header',
3617
+ 'sentAs' => 'x-amz-request-id',
3618
+ ),
3619
+ ),
3620
+ ),
3621
+ 'GetBucketReplicationOutput' => array(
3622
+ 'type' => 'object',
3623
+ 'additionalProperties' => true,
3624
+ 'properties' => array(
3625
+ 'Role' => array(
3626
+ 'type' => 'string',
3627
+ 'location' => 'xml',
3628
+ ),
3629
+ 'Rules' => array(
3630
+ 'type' => 'array',
3631
+ 'location' => 'xml',
3632
+ 'sentAs' => 'Rule',
3633
+ 'data' => array(
3634
+ 'xmlFlattened' => true,
3635
+ ),
3636
+ 'items' => array(
3637
+ 'name' => 'ReplicationRule',
3638
+ 'type' => 'object',
3639
+ 'sentAs' => 'Rule',
3640
+ 'properties' => array(
3641
+ 'ID' => array(
3642
+ 'type' => 'string',
3643
+ ),
3644
+ 'Prefix' => array(
3645
+ 'type' => 'string',
3646
+ ),
3647
+ 'Status' => array(
3648
+ 'type' => 'string',
3649
+ ),
3650
+ 'Destination' => array(
3651
+ 'type' => 'object',
3652
+ 'properties' => array(
3653
+ 'Bucket' => array(
3654
+ 'type' => 'string',
3655
+ ),
3656
+ ),
3657
+ ),
3658
+ ),
3659
+ ),
3660
+ ),
3661
+ 'RequestId' => array(
3662
+ 'location' => 'header',
3663
+ 'sentAs' => 'x-amz-request-id',
3664
+ ),
3665
+ ),
3666
+ ),
3667
+ 'GetBucketRequestPaymentOutput' => array(
3668
+ 'type' => 'object',
3669
+ 'additionalProperties' => true,
3670
+ 'properties' => array(
3671
+ 'Payer' => array(
3672
+ 'type' => 'string',
3673
+ 'location' => 'xml',
3674
+ ),
3675
+ 'RequestId' => array(
3676
+ 'location' => 'header',
3677
+ 'sentAs' => 'x-amz-request-id',
3678
+ ),
3679
+ ),
3680
+ ),
3681
+ 'GetBucketTaggingOutput' => array(
3682
+ 'type' => 'object',
3683
+ 'additionalProperties' => true,
3684
+ 'properties' => array(
3685
+ 'TagSet' => array(
3686
+ 'type' => 'array',
3687
+ 'location' => 'xml',
3688
+ 'items' => array(
3689
+ 'name' => 'Tag',
3690
+ 'type' => 'object',
3691
+ 'sentAs' => 'Tag',
3692
+ 'properties' => array(
3693
+ 'Key' => array(
3694
+ 'type' => 'string',
3695
+ ),
3696
+ 'Value' => array(
3697
+ 'type' => 'string',
3698
+ ),
3699
+ ),
3700
+ ),
3701
+ ),
3702
+ 'RequestId' => array(
3703
+ 'location' => 'header',
3704
+ 'sentAs' => 'x-amz-request-id',
3705
+ ),
3706
+ ),
3707
+ ),
3708
+ 'GetBucketVersioningOutput' => array(
3709
+ 'type' => 'object',
3710
+ 'additionalProperties' => true,
3711
+ 'properties' => array(
3712
+ 'Status' => array(
3713
+ 'type' => 'string',
3714
+ 'location' => 'xml',
3715
+ ),
3716
+ 'MFADelete' => array(
3717
+ 'type' => 'string',
3718
+ 'location' => 'xml',
3719
+ 'sentAs' => 'MfaDelete',
3720
+ ),
3721
+ 'RequestId' => array(
3722
+ 'location' => 'header',
3723
+ 'sentAs' => 'x-amz-request-id',
3724
+ ),
3725
+ ),
3726
+ ),
3727
+ 'GetBucketWebsiteOutput' => array(
3728
+ 'type' => 'object',
3729
+ 'additionalProperties' => true,
3730
+ 'properties' => array(
3731
+ 'RedirectAllRequestsTo' => array(
3732
+ 'type' => 'object',
3733
+ 'location' => 'xml',
3734
+ 'properties' => array(
3735
+ 'HostName' => array(
3736
+ 'type' => 'string',
3737
+ ),
3738
+ 'Protocol' => array(
3739
+ 'type' => 'string',
3740
+ ),
3741
+ ),
3742
+ ),
3743
+ 'IndexDocument' => array(
3744
+ 'type' => 'object',
3745
+ 'location' => 'xml',
3746
+ 'properties' => array(
3747
+ 'Suffix' => array(
3748
+ 'type' => 'string',
3749
+ ),
3750
+ ),
3751
+ ),
3752
+ 'ErrorDocument' => array(
3753
+ 'type' => 'object',
3754
+ 'location' => 'xml',
3755
+ 'properties' => array(
3756
+ 'Key' => array(
3757
+ 'type' => 'string',
3758
+ ),
3759
+ ),
3760
+ ),
3761
+ 'RoutingRules' => array(
3762
+ 'type' => 'array',
3763
+ 'location' => 'xml',
3764
+ 'items' => array(
3765
+ 'name' => 'RoutingRule',
3766
+ 'type' => 'object',
3767
+ 'sentAs' => 'RoutingRule',
3768
+ 'properties' => array(
3769
+ 'Condition' => array(
3770
+ 'type' => 'object',
3771
+ 'properties' => array(
3772
+ 'HttpErrorCodeReturnedEquals' => array(
3773
+ 'type' => 'string',
3774
+ ),
3775
+ 'KeyPrefixEquals' => array(
3776
+ 'type' => 'string',
3777
+ ),
3778
+ ),
3779
+ ),
3780
+ 'Redirect' => array(
3781
+ 'type' => 'object',
3782
+ 'properties' => array(
3783
+ 'HostName' => array(
3784
+ 'type' => 'string',
3785
+ ),
3786
+ 'HttpRedirectCode' => array(
3787
+ 'type' => 'string',
3788
+ ),
3789
+ 'Protocol' => array(
3790
+ 'type' => 'string',
3791
+ ),
3792
+ 'ReplaceKeyPrefixWith' => array(
3793
+ 'type' => 'string',
3794
+ ),
3795
+ 'ReplaceKeyWith' => array(
3796
+ 'type' => 'string',
3797
+ ),
3798
+ ),
3799
+ ),
3800
+ ),
3801
+ ),
3802
+ ),
3803
+ 'RequestId' => array(
3804
+ 'location' => 'header',
3805
+ 'sentAs' => 'x-amz-request-id',
3806
+ ),
3807
+ ),
3808
+ ),
3809
+ 'GetObjectOutput' => array(
3810
+ 'type' => 'object',
3811
+ 'additionalProperties' => true,
3812
+ 'properties' => array(
3813
+ 'Body' => array(
3814
+ 'type' => 'string',
3815
+ 'instanceOf' => 'Guzzle\\Http\\EntityBody',
3816
+ 'location' => 'body',
3817
+ ),
3818
+ 'DeleteMarker' => array(
3819
+ 'type' => 'boolean',
3820
+ 'location' => 'header',
3821
+ 'sentAs' => 'x-amz-delete-marker',
3822
+ ),
3823
+ 'AcceptRanges' => array(
3824
+ 'type' => 'string',
3825
+ 'location' => 'header',
3826
+ 'sentAs' => 'accept-ranges',
3827
+ ),
3828
+ 'Expiration' => array(
3829
+ 'type' => 'string',
3830
+ 'location' => 'header',
3831
+ 'sentAs' => 'x-amz-expiration',
3832
+ ),
3833
+ 'Restore' => array(
3834
+ 'type' => 'string',
3835
+ 'location' => 'header',
3836
+ 'sentAs' => 'x-amz-restore',
3837
+ ),
3838
+ 'LastModified' => array(
3839
+ 'type' => 'string',
3840
+ 'location' => 'header',
3841
+ 'sentAs' => 'Last-Modified',
3842
+ ),
3843
+ 'ContentLength' => array(
3844
+ 'type' => 'numeric',
3845
+ 'location' => 'header',
3846
+ 'sentAs' => 'Content-Length',
3847
+ ),
3848
+ 'ETag' => array(
3849
+ 'type' => 'string',
3850
+ 'location' => 'header',
3851
+ ),
3852
+ 'MissingMeta' => array(
3853
+ 'type' => 'numeric',
3854
+ 'location' => 'header',
3855
+ 'sentAs' => 'x-amz-missing-meta',
3856
+ ),
3857
+ 'VersionId' => array(
3858
+ 'type' => 'string',
3859
+ 'location' => 'header',
3860
+ 'sentAs' => 'x-amz-version-id',
3861
+ ),
3862
+ 'CacheControl' => array(
3863
+ 'type' => 'string',
3864
+ 'location' => 'header',
3865
+ 'sentAs' => 'Cache-Control',
3866
+ ),
3867
+ 'ContentDisposition' => array(
3868
+ 'type' => 'string',
3869
+ 'location' => 'header',
3870
+ 'sentAs' => 'Content-Disposition',
3871
+ ),
3872
+ 'ContentEncoding' => array(
3873
+ 'type' => 'string',
3874
+ 'location' => 'header',
3875
+ 'sentAs' => 'Content-Encoding',
3876
+ ),
3877
+ 'ContentLanguage' => array(
3878
+ 'type' => 'string',
3879
+ 'location' => 'header',
3880
+ 'sentAs' => 'Content-Language',
3881
+ ),
3882
+ 'ContentType' => array(
3883
+ 'type' => 'string',
3884
+ 'location' => 'header',
3885
+ 'sentAs' => 'Content-Type',
3886
+ ),
3887
+ 'Expires' => array(
3888
+ 'type' => 'string',
3889
+ 'location' => 'header',
3890
+ ),
3891
+ 'WebsiteRedirectLocation' => array(
3892
+ 'type' => 'string',
3893
+ 'location' => 'header',
3894
+ 'sentAs' => 'x-amz-website-redirect-location',
3895
+ ),
3896
+ 'ServerSideEncryption' => array(
3897
+ 'type' => 'string',
3898
+ 'location' => 'header',
3899
+ 'sentAs' => 'x-amz-server-side-encryption',
3900
+ ),
3901
+ 'Metadata' => array(
3902
+ 'type' => 'object',
3903
+ 'location' => 'header',
3904
+ 'sentAs' => 'x-amz-meta-',
3905
+ 'additionalProperties' => array(
3906
+ 'type' => 'string',
3907
+ ),
3908
+ ),
3909
+ 'SSECustomerAlgorithm' => array(
3910
+ 'type' => 'string',
3911
+ 'location' => 'header',
3912
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
3913
+ ),
3914
+ 'SSECustomerKeyMD5' => array(
3915
+ 'type' => 'string',
3916
+ 'location' => 'header',
3917
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
3918
+ ),
3919
+ 'SSEKMSKeyId' => array(
3920
+ 'type' => 'string',
3921
+ 'location' => 'header',
3922
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
3923
+ ),
3924
+ 'RequestCharged' => array(
3925
+ 'type' => 'string',
3926
+ 'location' => 'header',
3927
+ 'sentAs' => 'x-amz-request-charged',
3928
+ ),
3929
+ 'ReplicationStatus' => array(
3930
+ 'type' => 'string',
3931
+ 'location' => 'header',
3932
+ 'sentAs' => 'x-amz-replication-status',
3933
+ ),
3934
+ 'RequestId' => array(
3935
+ 'location' => 'header',
3936
+ 'sentAs' => 'x-amz-request-id',
3937
+ ),
3938
+ ),
3939
+ ),
3940
+ 'GetObjectAclOutput' => array(
3941
+ 'type' => 'object',
3942
+ 'additionalProperties' => true,
3943
+ 'properties' => array(
3944
+ 'Owner' => array(
3945
+ 'type' => 'object',
3946
+ 'location' => 'xml',
3947
+ 'properties' => array(
3948
+ 'DisplayName' => array(
3949
+ 'type' => 'string',
3950
+ ),
3951
+ 'ID' => array(
3952
+ 'type' => 'string',
3953
+ ),
3954
+ ),
3955
+ ),
3956
+ 'Grants' => array(
3957
+ 'type' => 'array',
3958
+ 'location' => 'xml',
3959
+ 'sentAs' => 'AccessControlList',
3960
+ 'items' => array(
3961
+ 'name' => 'Grant',
3962
+ 'type' => 'object',
3963
+ 'sentAs' => 'Grant',
3964
+ 'properties' => array(
3965
+ 'Grantee' => array(
3966
+ 'type' => 'object',
3967
+ 'properties' => array(
3968
+ 'DisplayName' => array(
3969
+ 'type' => 'string',
3970
+ ),
3971
+ 'EmailAddress' => array(
3972
+ 'type' => 'string',
3973
+ ),
3974
+ 'ID' => array(
3975
+ 'type' => 'string',
3976
+ ),
3977
+ 'Type' => array(
3978
+ 'type' => 'string',
3979
+ 'sentAs' => 'xsi:type',
3980
+ 'data' => array(
3981
+ 'xmlAttribute' => true,
3982
+ 'xmlNamespace' => 'http://www.w3.org/2001/XMLSchema-instance',
3983
+ ),
3984
+ ),
3985
+ 'URI' => array(
3986
+ 'type' => 'string',
3987
+ ),
3988
+ ),
3989
+ ),
3990
+ 'Permission' => array(
3991
+ 'type' => 'string',
3992
+ ),
3993
+ ),
3994
+ ),
3995
+ ),
3996
+ 'RequestCharged' => array(
3997
+ 'type' => 'string',
3998
+ 'location' => 'header',
3999
+ 'sentAs' => 'x-amz-request-charged',
4000
+ ),
4001
+ 'RequestId' => array(
4002
+ 'location' => 'header',
4003
+ 'sentAs' => 'x-amz-request-id',
4004
+ ),
4005
+ ),
4006
+ ),
4007
+ 'GetObjectTorrentOutput' => array(
4008
+ 'type' => 'object',
4009
+ 'additionalProperties' => true,
4010
+ 'properties' => array(
4011
+ 'Body' => array(
4012
+ 'type' => 'string',
4013
+ 'instanceOf' => 'Guzzle\\Http\\EntityBody',
4014
+ 'location' => 'body',
4015
+ ),
4016
+ 'RequestCharged' => array(
4017
+ 'type' => 'string',
4018
+ 'location' => 'header',
4019
+ 'sentAs' => 'x-amz-request-charged',
4020
+ ),
4021
+ 'RequestId' => array(
4022
+ 'location' => 'header',
4023
+ 'sentAs' => 'x-amz-request-id',
4024
+ ),
4025
+ ),
4026
+ ),
4027
+ 'HeadBucketOutput' => array(
4028
+ 'type' => 'object',
4029
+ 'additionalProperties' => true,
4030
+ 'properties' => array(
4031
+ 'RequestId' => array(
4032
+ 'location' => 'header',
4033
+ 'sentAs' => 'x-amz-request-id',
4034
+ ),
4035
+ ),
4036
+ ),
4037
+ 'HeadObjectOutput' => array(
4038
+ 'type' => 'object',
4039
+ 'additionalProperties' => true,
4040
+ 'properties' => array(
4041
+ 'DeleteMarker' => array(
4042
+ 'type' => 'boolean',
4043
+ 'location' => 'header',
4044
+ 'sentAs' => 'x-amz-delete-marker',
4045
+ ),
4046
+ 'AcceptRanges' => array(
4047
+ 'type' => 'string',
4048
+ 'location' => 'header',
4049
+ 'sentAs' => 'accept-ranges',
4050
+ ),
4051
+ 'Expiration' => array(
4052
+ 'type' => 'string',
4053
+ 'location' => 'header',
4054
+ 'sentAs' => 'x-amz-expiration',
4055
+ ),
4056
+ 'Restore' => array(
4057
+ 'type' => 'string',
4058
+ 'location' => 'header',
4059
+ 'sentAs' => 'x-amz-restore',
4060
+ ),
4061
+ 'LastModified' => array(
4062
+ 'type' => 'string',
4063
+ 'location' => 'header',
4064
+ 'sentAs' => 'Last-Modified',
4065
+ ),
4066
+ 'ContentLength' => array(
4067
+ 'type' => 'numeric',
4068
+ 'location' => 'header',
4069
+ 'sentAs' => 'Content-Length',
4070
+ ),
4071
+ 'ETag' => array(
4072
+ 'type' => 'string',
4073
+ 'location' => 'header',
4074
+ ),
4075
+ 'MissingMeta' => array(
4076
+ 'type' => 'numeric',
4077
+ 'location' => 'header',
4078
+ 'sentAs' => 'x-amz-missing-meta',
4079
+ ),
4080
+ 'VersionId' => array(
4081
+ 'type' => 'string',
4082
+ 'location' => 'header',
4083
+ 'sentAs' => 'x-amz-version-id',
4084
+ ),
4085
+ 'CacheControl' => array(
4086
+ 'type' => 'string',
4087
+ 'location' => 'header',
4088
+ 'sentAs' => 'Cache-Control',
4089
+ ),
4090
+ 'ContentDisposition' => array(
4091
+ 'type' => 'string',
4092
+ 'location' => 'header',
4093
+ 'sentAs' => 'Content-Disposition',
4094
+ ),
4095
+ 'ContentEncoding' => array(
4096
+ 'type' => 'string',
4097
+ 'location' => 'header',
4098
+ 'sentAs' => 'Content-Encoding',
4099
+ ),
4100
+ 'ContentLanguage' => array(
4101
+ 'type' => 'string',
4102
+ 'location' => 'header',
4103
+ 'sentAs' => 'Content-Language',
4104
+ ),
4105
+ 'ContentType' => array(
4106
+ 'type' => 'string',
4107
+ 'location' => 'header',
4108
+ 'sentAs' => 'Content-Type',
4109
+ ),
4110
+ 'Expires' => array(
4111
+ 'type' => 'string',
4112
+ 'location' => 'header',
4113
+ ),
4114
+ 'WebsiteRedirectLocation' => array(
4115
+ 'type' => 'string',
4116
+ 'location' => 'header',
4117
+ 'sentAs' => 'x-amz-website-redirect-location',
4118
+ ),
4119
+ 'ServerSideEncryption' => array(
4120
+ 'type' => 'string',
4121
+ 'location' => 'header',
4122
+ 'sentAs' => 'x-amz-server-side-encryption',
4123
+ ),
4124
+ 'Metadata' => array(
4125
+ 'type' => 'object',
4126
+ 'location' => 'header',
4127
+ 'sentAs' => 'x-amz-meta-',
4128
+ 'additionalProperties' => array(
4129
+ 'type' => 'string',
4130
+ ),
4131
+ ),
4132
+ 'SSECustomerAlgorithm' => array(
4133
+ 'type' => 'string',
4134
+ 'location' => 'header',
4135
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
4136
+ ),
4137
+ 'SSECustomerKeyMD5' => array(
4138
+ 'type' => 'string',
4139
+ 'location' => 'header',
4140
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
4141
+ ),
4142
+ 'SSEKMSKeyId' => array(
4143
+ 'type' => 'string',
4144
+ 'location' => 'header',
4145
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
4146
+ ),
4147
+ 'RequestCharged' => array(
4148
+ 'type' => 'string',
4149
+ 'location' => 'header',
4150
+ 'sentAs' => 'x-amz-request-charged',
4151
+ ),
4152
+ 'ReplicationStatus' => array(
4153
+ 'type' => 'string',
4154
+ 'location' => 'header',
4155
+ 'sentAs' => 'x-amz-replication-status',
4156
+ ),
4157
+ 'RequestId' => array(
4158
+ 'location' => 'header',
4159
+ 'sentAs' => 'x-amz-request-id',
4160
+ ),
4161
+ ),
4162
+ ),
4163
+ 'ListBucketsOutput' => array(
4164
+ 'type' => 'object',
4165
+ 'additionalProperties' => true,
4166
+ 'properties' => array(
4167
+ 'Buckets' => array(
4168
+ 'type' => 'array',
4169
+ 'location' => 'xml',
4170
+ 'items' => array(
4171
+ 'name' => 'Bucket',
4172
+ 'type' => 'object',
4173
+ 'sentAs' => 'Bucket',
4174
+ 'properties' => array(
4175
+ 'Name' => array(
4176
+ 'type' => 'string',
4177
+ ),
4178
+ 'CreationDate' => array(
4179
+ 'type' => 'string',
4180
+ ),
4181
+ ),
4182
+ ),
4183
+ ),
4184
+ 'Owner' => array(
4185
+ 'type' => 'object',
4186
+ 'location' => 'xml',
4187
+ 'properties' => array(
4188
+ 'DisplayName' => array(
4189
+ 'type' => 'string',
4190
+ ),
4191
+ 'ID' => array(
4192
+ 'type' => 'string',
4193
+ ),
4194
+ ),
4195
+ ),
4196
+ 'RequestId' => array(
4197
+ 'location' => 'header',
4198
+ 'sentAs' => 'x-amz-request-id',
4199
+ ),
4200
+ ),
4201
+ ),
4202
+ 'ListMultipartUploadsOutput' => array(
4203
+ 'type' => 'object',
4204
+ 'additionalProperties' => true,
4205
+ 'properties' => array(
4206
+ 'Bucket' => array(
4207
+ 'type' => 'string',
4208
+ 'location' => 'xml',
4209
+ ),
4210
+ 'KeyMarker' => array(
4211
+ 'type' => 'string',
4212
+ 'location' => 'xml',
4213
+ ),
4214
+ 'UploadIdMarker' => array(
4215
+ 'type' => 'string',
4216
+ 'location' => 'xml',
4217
+ ),
4218
+ 'NextKeyMarker' => array(
4219
+ 'type' => 'string',
4220
+ 'location' => 'xml',
4221
+ ),
4222
+ 'Prefix' => array(
4223
+ 'type' => 'string',
4224
+ 'location' => 'xml',
4225
+ ),
4226
+ 'Delimiter' => array(
4227
+ 'type' => 'string',
4228
+ 'location' => 'xml',
4229
+ ),
4230
+ 'NextUploadIdMarker' => array(
4231
+ 'type' => 'string',
4232
+ 'location' => 'xml',
4233
+ ),
4234
+ 'MaxUploads' => array(
4235
+ 'type' => 'numeric',
4236
+ 'location' => 'xml',
4237
+ ),
4238
+ 'IsTruncated' => array(
4239
+ 'type' => 'boolean',
4240
+ 'location' => 'xml',
4241
+ ),
4242
+ 'Uploads' => array(
4243
+ 'type' => 'array',
4244
+ 'location' => 'xml',
4245
+ 'sentAs' => 'Upload',
4246
+ 'data' => array(
4247
+ 'xmlFlattened' => true,
4248
+ ),
4249
+ 'items' => array(
4250
+ 'name' => 'MultipartUpload',
4251
+ 'type' => 'object',
4252
+ 'sentAs' => 'Upload',
4253
+ 'properties' => array(
4254
+ 'UploadId' => array(
4255
+ 'type' => 'string',
4256
+ ),
4257
+ 'Key' => array(
4258
+ 'type' => 'string',
4259
+ ),
4260
+ 'Initiated' => array(
4261
+ 'type' => 'string',
4262
+ ),
4263
+ 'StorageClass' => array(
4264
+ 'type' => 'string',
4265
+ ),
4266
+ 'Owner' => array(
4267
+ 'type' => 'object',
4268
+ 'properties' => array(
4269
+ 'DisplayName' => array(
4270
+ 'type' => 'string',
4271
+ ),
4272
+ 'ID' => array(
4273
+ 'type' => 'string',
4274
+ ),
4275
+ ),
4276
+ ),
4277
+ 'Initiator' => array(
4278
+ 'type' => 'object',
4279
+ 'properties' => array(
4280
+ 'ID' => array(
4281
+ 'type' => 'string',
4282
+ ),
4283
+ 'DisplayName' => array(
4284
+ 'type' => 'string',
4285
+ ),
4286
+ ),
4287
+ ),
4288
+ ),
4289
+ ),
4290
+ ),
4291
+ 'CommonPrefixes' => array(
4292
+ 'type' => 'array',
4293
+ 'location' => 'xml',
4294
+ 'data' => array(
4295
+ 'xmlFlattened' => true,
4296
+ ),
4297
+ 'items' => array(
4298
+ 'name' => 'CommonPrefix',
4299
+ 'type' => 'object',
4300
+ 'properties' => array(
4301
+ 'Prefix' => array(
4302
+ 'type' => 'string',
4303
+ ),
4304
+ ),
4305
+ ),
4306
+ ),
4307
+ 'EncodingType' => array(
4308
+ 'type' => 'string',
4309
+ 'location' => 'xml',
4310
+ ),
4311
+ 'RequestId' => array(
4312
+ 'location' => 'header',
4313
+ 'sentAs' => 'x-amz-request-id',
4314
+ ),
4315
+ ),
4316
+ ),
4317
+ 'ListObjectVersionsOutput' => array(
4318
+ 'type' => 'object',
4319
+ 'additionalProperties' => true,
4320
+ 'properties' => array(
4321
+ 'IsTruncated' => array(
4322
+ 'type' => 'boolean',
4323
+ 'location' => 'xml',
4324
+ ),
4325
+ 'KeyMarker' => array(
4326
+ 'type' => 'string',
4327
+ 'location' => 'xml',
4328
+ ),
4329
+ 'VersionIdMarker' => array(
4330
+ 'type' => 'string',
4331
+ 'location' => 'xml',
4332
+ ),
4333
+ 'NextKeyMarker' => array(
4334
+ 'type' => 'string',
4335
+ 'location' => 'xml',
4336
+ ),
4337
+ 'NextVersionIdMarker' => array(
4338
+ 'type' => 'string',
4339
+ 'location' => 'xml',
4340
+ ),
4341
+ 'Versions' => array(
4342
+ 'type' => 'array',
4343
+ 'location' => 'xml',
4344
+ 'sentAs' => 'Version',
4345
+ 'data' => array(
4346
+ 'xmlFlattened' => true,
4347
+ ),
4348
+ 'items' => array(
4349
+ 'name' => 'ObjectVersion',
4350
+ 'type' => 'object',
4351
+ 'sentAs' => 'Version',
4352
+ 'properties' => array(
4353
+ 'ETag' => array(
4354
+ 'type' => 'string',
4355
+ ),
4356
+ 'Size' => array(
4357
+ 'type' => 'numeric',
4358
+ ),
4359
+ 'StorageClass' => array(
4360
+ 'type' => 'string',
4361
+ ),
4362
+ 'Key' => array(
4363
+ 'type' => 'string',
4364
+ ),
4365
+ 'VersionId' => array(
4366
+ 'type' => 'string',
4367
+ ),
4368
+ 'IsLatest' => array(
4369
+ 'type' => 'boolean',
4370
+ ),
4371
+ 'LastModified' => array(
4372
+ 'type' => 'string',
4373
+ ),
4374
+ 'Owner' => array(
4375
+ 'type' => 'object',
4376
+ 'properties' => array(
4377
+ 'DisplayName' => array(
4378
+ 'type' => 'string',
4379
+ ),
4380
+ 'ID' => array(
4381
+ 'type' => 'string',
4382
+ ),
4383
+ ),
4384
+ ),
4385
+ ),
4386
+ ),
4387
+ ),
4388
+ 'DeleteMarkers' => array(
4389
+ 'type' => 'array',
4390
+ 'location' => 'xml',
4391
+ 'sentAs' => 'DeleteMarker',
4392
+ 'data' => array(
4393
+ 'xmlFlattened' => true,
4394
+ ),
4395
+ 'items' => array(
4396
+ 'name' => 'DeleteMarkerEntry',
4397
+ 'type' => 'object',
4398
+ 'sentAs' => 'DeleteMarker',
4399
+ 'properties' => array(
4400
+ 'Owner' => array(
4401
+ 'type' => 'object',
4402
+ 'properties' => array(
4403
+ 'DisplayName' => array(
4404
+ 'type' => 'string',
4405
+ ),
4406
+ 'ID' => array(
4407
+ 'type' => 'string',
4408
+ ),
4409
+ ),
4410
+ ),
4411
+ 'Key' => array(
4412
+ 'type' => 'string',
4413
+ ),
4414
+ 'VersionId' => array(
4415
+ 'type' => 'string',
4416
+ ),
4417
+ 'IsLatest' => array(
4418
+ 'type' => 'boolean',
4419
+ ),
4420
+ 'LastModified' => array(
4421
+ 'type' => 'string',
4422
+ ),
4423
+ ),
4424
+ ),
4425
+ ),
4426
+ 'Name' => array(
4427
+ 'type' => 'string',
4428
+ 'location' => 'xml',
4429
+ ),
4430
+ 'Prefix' => array(
4431
+ 'type' => 'string',
4432
+ 'location' => 'xml',
4433
+ ),
4434
+ 'Delimiter' => array(
4435
+ 'type' => 'string',
4436
+ 'location' => 'xml',
4437
+ ),
4438
+ 'MaxKeys' => array(
4439
+ 'type' => 'numeric',
4440
+ 'location' => 'xml',
4441
+ ),
4442
+ 'CommonPrefixes' => array(
4443
+ 'type' => 'array',
4444
+ 'location' => 'xml',
4445
+ 'data' => array(
4446
+ 'xmlFlattened' => true,
4447
+ ),
4448
+ 'items' => array(
4449
+ 'name' => 'CommonPrefix',
4450
+ 'type' => 'object',
4451
+ 'properties' => array(
4452
+ 'Prefix' => array(
4453
+ 'type' => 'string',
4454
+ ),
4455
+ ),
4456
+ ),
4457
+ ),
4458
+ 'EncodingType' => array(
4459
+ 'type' => 'string',
4460
+ 'location' => 'xml',
4461
+ ),
4462
+ 'RequestId' => array(
4463
+ 'location' => 'header',
4464
+ 'sentAs' => 'x-amz-request-id',
4465
+ ),
4466
+ ),
4467
+ ),
4468
+ 'ListObjectsOutput' => array(
4469
+ 'type' => 'object',
4470
+ 'additionalProperties' => true,
4471
+ 'properties' => array(
4472
+ 'IsTruncated' => array(
4473
+ 'type' => 'boolean',
4474
+ 'location' => 'xml',
4475
+ ),
4476
+ 'Marker' => array(
4477
+ 'type' => 'string',
4478
+ 'location' => 'xml',
4479
+ ),
4480
+ 'NextMarker' => array(
4481
+ 'type' => 'string',
4482
+ 'location' => 'xml',
4483
+ ),
4484
+ 'Contents' => array(
4485
+ 'type' => 'array',
4486
+ 'location' => 'xml',
4487
+ 'data' => array(
4488
+ 'xmlFlattened' => true,
4489
+ ),
4490
+ 'items' => array(
4491
+ 'name' => 'Object',
4492
+ 'type' => 'object',
4493
+ 'properties' => array(
4494
+ 'Key' => array(
4495
+ 'type' => 'string',
4496
+ ),
4497
+ 'LastModified' => array(
4498
+ 'type' => 'string',
4499
+ ),
4500
+ 'ETag' => array(
4501
+ 'type' => 'string',
4502
+ ),
4503
+ 'Size' => array(
4504
+ 'type' => 'numeric',
4505
+ ),
4506
+ 'StorageClass' => array(
4507
+ 'type' => 'string',
4508
+ ),
4509
+ 'Owner' => array(
4510
+ 'type' => 'object',
4511
+ 'properties' => array(
4512
+ 'DisplayName' => array(
4513
+ 'type' => 'string',
4514
+ ),
4515
+ 'ID' => array(
4516
+ 'type' => 'string',
4517
+ ),
4518
+ ),
4519
+ ),
4520
+ ),
4521
+ ),
4522
+ ),
4523
+ 'Name' => array(
4524
+ 'type' => 'string',
4525
+ 'location' => 'xml',
4526
+ ),
4527
+ 'Prefix' => array(
4528
+ 'type' => 'string',
4529
+ 'location' => 'xml',
4530
+ ),
4531
+ 'Delimiter' => array(
4532
+ 'type' => 'string',
4533
+ 'location' => 'xml',
4534
+ ),
4535
+ 'MaxKeys' => array(
4536
+ 'type' => 'numeric',
4537
+ 'location' => 'xml',
4538
+ ),
4539
+ 'CommonPrefixes' => array(
4540
+ 'type' => 'array',
4541
+ 'location' => 'xml',
4542
+ 'data' => array(
4543
+ 'xmlFlattened' => true,
4544
+ ),
4545
+ 'items' => array(
4546
+ 'name' => 'CommonPrefix',
4547
+ 'type' => 'object',
4548
+ 'properties' => array(
4549
+ 'Prefix' => array(
4550
+ 'type' => 'string',
4551
+ ),
4552
+ ),
4553
+ ),
4554
+ ),
4555
+ 'EncodingType' => array(
4556
+ 'type' => 'string',
4557
+ 'location' => 'xml',
4558
+ ),
4559
+ 'RequestId' => array(
4560
+ 'location' => 'header',
4561
+ 'sentAs' => 'x-amz-request-id',
4562
+ ),
4563
+ ),
4564
+ ),
4565
+ 'ListPartsOutput' => array(
4566
+ 'type' => 'object',
4567
+ 'additionalProperties' => true,
4568
+ 'properties' => array(
4569
+ 'Bucket' => array(
4570
+ 'type' => 'string',
4571
+ 'location' => 'xml',
4572
+ ),
4573
+ 'Key' => array(
4574
+ 'type' => 'string',
4575
+ 'location' => 'xml',
4576
+ ),
4577
+ 'UploadId' => array(
4578
+ 'type' => 'string',
4579
+ 'location' => 'xml',
4580
+ ),
4581
+ 'PartNumberMarker' => array(
4582
+ 'type' => 'numeric',
4583
+ 'location' => 'xml',
4584
+ ),
4585
+ 'NextPartNumberMarker' => array(
4586
+ 'type' => 'numeric',
4587
+ 'location' => 'xml',
4588
+ ),
4589
+ 'MaxParts' => array(
4590
+ 'type' => 'numeric',
4591
+ 'location' => 'xml',
4592
+ ),
4593
+ 'IsTruncated' => array(
4594
+ 'type' => 'boolean',
4595
+ 'location' => 'xml',
4596
+ ),
4597
+ 'Parts' => array(
4598
+ 'type' => 'array',
4599
+ 'location' => 'xml',
4600
+ 'sentAs' => 'Part',
4601
+ 'data' => array(
4602
+ 'xmlFlattened' => true,
4603
+ ),
4604
+ 'items' => array(
4605
+ 'name' => 'Part',
4606
+ 'type' => 'object',
4607
+ 'sentAs' => 'Part',
4608
+ 'properties' => array(
4609
+ 'PartNumber' => array(
4610
+ 'type' => 'numeric',
4611
+ ),
4612
+ 'LastModified' => array(
4613
+ 'type' => 'string',
4614
+ ),
4615
+ 'ETag' => array(
4616
+ 'type' => 'string',
4617
+ ),
4618
+ 'Size' => array(
4619
+ 'type' => 'numeric',
4620
+ ),
4621
+ ),
4622
+ ),
4623
+ ),
4624
+ 'Initiator' => array(
4625
+ 'type' => 'object',
4626
+ 'location' => 'xml',
4627
+ 'properties' => array(
4628
+ 'ID' => array(
4629
+ 'type' => 'string',
4630
+ ),
4631
+ 'DisplayName' => array(
4632
+ 'type' => 'string',
4633
+ ),
4634
+ ),
4635
+ ),
4636
+ 'Owner' => array(
4637
+ 'type' => 'object',
4638
+ 'location' => 'xml',
4639
+ 'properties' => array(
4640
+ 'DisplayName' => array(
4641
+ 'type' => 'string',
4642
+ ),
4643
+ 'ID' => array(
4644
+ 'type' => 'string',
4645
+ ),
4646
+ ),
4647
+ ),
4648
+ 'StorageClass' => array(
4649
+ 'type' => 'string',
4650
+ 'location' => 'xml',
4651
+ ),
4652
+ 'RequestCharged' => array(
4653
+ 'type' => 'string',
4654
+ 'location' => 'header',
4655
+ 'sentAs' => 'x-amz-request-charged',
4656
+ ),
4657
+ 'RequestId' => array(
4658
+ 'location' => 'header',
4659
+ 'sentAs' => 'x-amz-request-id',
4660
+ ),
4661
+ ),
4662
+ ),
4663
+ 'PutBucketAclOutput' => array(
4664
+ 'type' => 'object',
4665
+ 'additionalProperties' => true,
4666
+ 'properties' => array(
4667
+ 'RequestId' => array(
4668
+ 'location' => 'header',
4669
+ 'sentAs' => 'x-amz-request-id',
4670
+ ),
4671
+ ),
4672
+ ),
4673
+ 'PutBucketCorsOutput' => array(
4674
+ 'type' => 'object',
4675
+ 'additionalProperties' => true,
4676
+ 'properties' => array(
4677
+ 'RequestId' => array(
4678
+ 'location' => 'header',
4679
+ 'sentAs' => 'x-amz-request-id',
4680
+ ),
4681
+ ),
4682
+ ),
4683
+ 'PutBucketLifecycleOutput' => array(
4684
+ 'type' => 'object',
4685
+ 'additionalProperties' => true,
4686
+ 'properties' => array(
4687
+ 'RequestId' => array(
4688
+ 'location' => 'header',
4689
+ 'sentAs' => 'x-amz-request-id',
4690
+ ),
4691
+ ),
4692
+ ),
4693
+ 'PutBucketLoggingOutput' => array(
4694
+ 'type' => 'object',
4695
+ 'additionalProperties' => true,
4696
+ 'properties' => array(
4697
+ 'RequestId' => array(
4698
+ 'location' => 'header',
4699
+ 'sentAs' => 'x-amz-request-id',
4700
+ ),
4701
+ ),
4702
+ ),
4703
+ 'PutBucketNotificationOutput' => array(
4704
+ 'type' => 'object',
4705
+ 'additionalProperties' => true,
4706
+ 'properties' => array(
4707
+ 'RequestId' => array(
4708
+ 'location' => 'header',
4709
+ 'sentAs' => 'x-amz-request-id',
4710
+ ),
4711
+ ),
4712
+ ),
4713
+ 'PutBucketPolicyOutput' => array(
4714
+ 'type' => 'object',
4715
+ 'additionalProperties' => true,
4716
+ 'properties' => array(
4717
+ 'RequestId' => array(
4718
+ 'location' => 'header',
4719
+ 'sentAs' => 'x-amz-request-id',
4720
+ ),
4721
+ ),
4722
+ ),
4723
+ 'PutBucketReplicationOutput' => array(
4724
+ 'type' => 'object',
4725
+ 'additionalProperties' => true,
4726
+ 'properties' => array(
4727
+ 'RequestId' => array(
4728
+ 'location' => 'header',
4729
+ 'sentAs' => 'x-amz-request-id',
4730
+ ),
4731
+ ),
4732
+ ),
4733
+ 'PutBucketRequestPaymentOutput' => array(
4734
+ 'type' => 'object',
4735
+ 'additionalProperties' => true,
4736
+ 'properties' => array(
4737
+ 'RequestId' => array(
4738
+ 'location' => 'header',
4739
+ 'sentAs' => 'x-amz-request-id',
4740
+ ),
4741
+ ),
4742
+ ),
4743
+ 'PutBucketTaggingOutput' => array(
4744
+ 'type' => 'object',
4745
+ 'additionalProperties' => true,
4746
+ 'properties' => array(
4747
+ 'RequestId' => array(
4748
+ 'location' => 'header',
4749
+ 'sentAs' => 'x-amz-request-id',
4750
+ ),
4751
+ ),
4752
+ ),
4753
+ 'PutBucketVersioningOutput' => array(
4754
+ 'type' => 'object',
4755
+ 'additionalProperties' => true,
4756
+ 'properties' => array(
4757
+ 'RequestId' => array(
4758
+ 'location' => 'header',
4759
+ 'sentAs' => 'x-amz-request-id',
4760
+ ),
4761
+ ),
4762
+ ),
4763
+ 'PutBucketWebsiteOutput' => array(
4764
+ 'type' => 'object',
4765
+ 'additionalProperties' => true,
4766
+ 'properties' => array(
4767
+ 'RequestId' => array(
4768
+ 'location' => 'header',
4769
+ 'sentAs' => 'x-amz-request-id',
4770
+ ),
4771
+ ),
4772
+ ),
4773
+ 'PutObjectOutput' => array(
4774
+ 'type' => 'object',
4775
+ 'additionalProperties' => true,
4776
+ 'properties' => array(
4777
+ 'Expiration' => array(
4778
+ 'type' => 'string',
4779
+ 'location' => 'header',
4780
+ 'sentAs' => 'x-amz-expiration',
4781
+ ),
4782
+ 'ETag' => array(
4783
+ 'type' => 'string',
4784
+ 'location' => 'header',
4785
+ ),
4786
+ 'ServerSideEncryption' => array(
4787
+ 'type' => 'string',
4788
+ 'location' => 'header',
4789
+ 'sentAs' => 'x-amz-server-side-encryption',
4790
+ ),
4791
+ 'VersionId' => array(
4792
+ 'type' => 'string',
4793
+ 'location' => 'header',
4794
+ 'sentAs' => 'x-amz-version-id',
4795
+ ),
4796
+ 'SSECustomerAlgorithm' => array(
4797
+ 'type' => 'string',
4798
+ 'location' => 'header',
4799
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
4800
+ ),
4801
+ 'SSECustomerKeyMD5' => array(
4802
+ 'type' => 'string',
4803
+ 'location' => 'header',
4804
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
4805
+ ),
4806
+ 'SSEKMSKeyId' => array(
4807
+ 'type' => 'string',
4808
+ 'location' => 'header',
4809
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
4810
+ ),
4811
+ 'RequestCharged' => array(
4812
+ 'type' => 'string',
4813
+ 'location' => 'header',
4814
+ 'sentAs' => 'x-amz-request-charged',
4815
+ ),
4816
+ 'RequestId' => array(
4817
+ 'location' => 'header',
4818
+ 'sentAs' => 'x-amz-request-id',
4819
+ ),
4820
+ 'ObjectURL' => array(
4821
+ ),
4822
+ ),
4823
+ ),
4824
+ 'PutObjectAclOutput' => array(
4825
+ 'type' => 'object',
4826
+ 'additionalProperties' => true,
4827
+ 'properties' => array(
4828
+ 'RequestCharged' => array(
4829
+ 'type' => 'string',
4830
+ 'location' => 'header',
4831
+ 'sentAs' => 'x-amz-request-charged',
4832
+ ),
4833
+ 'RequestId' => array(
4834
+ 'location' => 'header',
4835
+ 'sentAs' => 'x-amz-request-id',
4836
+ ),
4837
+ ),
4838
+ ),
4839
+ 'RestoreObjectOutput' => array(
4840
+ 'type' => 'object',
4841
+ 'additionalProperties' => true,
4842
+ 'properties' => array(
4843
+ 'RequestCharged' => array(
4844
+ 'type' => 'string',
4845
+ 'location' => 'header',
4846
+ 'sentAs' => 'x-amz-request-charged',
4847
+ ),
4848
+ 'RequestId' => array(
4849
+ 'location' => 'header',
4850
+ 'sentAs' => 'x-amz-request-id',
4851
+ ),
4852
+ ),
4853
+ ),
4854
+ 'UploadPartOutput' => array(
4855
+ 'type' => 'object',
4856
+ 'additionalProperties' => true,
4857
+ 'properties' => array(
4858
+ 'ServerSideEncryption' => array(
4859
+ 'type' => 'string',
4860
+ 'location' => 'header',
4861
+ 'sentAs' => 'x-amz-server-side-encryption',
4862
+ ),
4863
+ 'ETag' => array(
4864
+ 'type' => 'string',
4865
+ 'location' => 'header',
4866
+ ),
4867
+ 'SSECustomerAlgorithm' => array(
4868
+ 'type' => 'string',
4869
+ 'location' => 'header',
4870
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
4871
+ ),
4872
+ 'SSECustomerKeyMD5' => array(
4873
+ 'type' => 'string',
4874
+ 'location' => 'header',
4875
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
4876
+ ),
4877
+ 'SSEKMSKeyId' => array(
4878
+ 'type' => 'string',
4879
+ 'location' => 'header',
4880
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
4881
+ ),
4882
+ 'RequestCharged' => array(
4883
+ 'type' => 'string',
4884
+ 'location' => 'header',
4885
+ 'sentAs' => 'x-amz-request-charged',
4886
+ ),
4887
+ 'RequestId' => array(
4888
+ 'location' => 'header',
4889
+ 'sentAs' => 'x-amz-request-id',
4890
+ ),
4891
+ ),
4892
+ ),
4893
+ 'UploadPartCopyOutput' => array(
4894
+ 'type' => 'object',
4895
+ 'additionalProperties' => true,
4896
+ 'properties' => array(
4897
+ 'CopySourceVersionId' => array(
4898
+ 'type' => 'string',
4899
+ 'location' => 'header',
4900
+ 'sentAs' => 'x-amz-copy-source-version-id',
4901
+ ),
4902
+ 'ETag' => array(
4903
+ 'type' => 'string',
4904
+ 'location' => 'xml',
4905
+ ),
4906
+ 'LastModified' => array(
4907
+ 'type' => 'string',
4908
+ 'location' => 'xml',
4909
+ ),
4910
+ 'ServerSideEncryption' => array(
4911
+ 'type' => 'string',
4912
+ 'location' => 'header',
4913
+ 'sentAs' => 'x-amz-server-side-encryption',
4914
+ ),
4915
+ 'SSECustomerAlgorithm' => array(
4916
+ 'type' => 'string',
4917
+ 'location' => 'header',
4918
+ 'sentAs' => 'x-amz-server-side-encryption-customer-algorithm',
4919
+ ),
4920
+ 'SSECustomerKeyMD5' => array(
4921
+ 'type' => 'string',
4922
+ 'location' => 'header',
4923
+ 'sentAs' => 'x-amz-server-side-encryption-customer-key-MD5',
4924
+ ),
4925
+ 'SSEKMSKeyId' => array(
4926
+ 'type' => 'string',
4927
+ 'location' => 'header',
4928
+ 'sentAs' => 'x-amz-server-side-encryption-aws-kms-key-id',
4929
+ ),
4930
+ 'RequestCharged' => array(
4931
+ 'type' => 'string',
4932
+ 'location' => 'header',
4933
+ 'sentAs' => 'x-amz-request-charged',
4934
+ ),
4935
+ 'RequestId' => array(
4936
+ 'location' => 'header',
4937
+ 'sentAs' => 'x-amz-request-id',
4938
+ ),
4939
+ ),
4940
+ ),
4941
+ ),
4942
+ 'iterators' => array(
4943
+ 'ListBuckets' => array(
4944
+ 'result_key' => 'Buckets',
4945
+ ),
4946
+ 'ListMultipartUploads' => array(
4947
+ 'limit_key' => 'MaxUploads',
4948
+ 'more_results' => 'IsTruncated',
4949
+ 'output_token' => array(
4950
+ 'NextKeyMarker',
4951
+ 'NextUploadIdMarker',
4952
+ ),
4953
+ 'input_token' => array(
4954
+ 'KeyMarker',
4955
+ 'UploadIdMarker',
4956
+ ),
4957
+ 'result_key' => array(
4958
+ 'Uploads',
4959
+ 'CommonPrefixes',
4960
+ ),
4961
+ ),
4962
+ 'ListObjectVersions' => array(
4963
+ 'more_results' => 'IsTruncated',
4964
+ 'limit_key' => 'MaxKeys',
4965
+ 'output_token' => array(
4966
+ 'NextKeyMarker',
4967
+ 'NextVersionIdMarker',
4968
+ ),
4969
+ 'input_token' => array(
4970
+ 'KeyMarker',
4971
+ 'VersionIdMarker',
4972
+ ),
4973
+ 'result_key' => array(
4974
+ 'Versions',
4975
+ 'DeleteMarkers',
4976
+ 'CommonPrefixes',
4977
+ ),
4978
+ ),
4979
+ 'ListObjects' => array(
4980
+ 'more_results' => 'IsTruncated',
4981
+ 'limit_key' => 'MaxKeys',
4982
+ 'output_token' => 'NextMarker',
4983
+ 'input_token' => 'Marker',
4984
+ 'result_key' => array(
4985
+ 'Contents',
4986
+ 'CommonPrefixes',
4987
+ ),
4988
+ ),
4989
+ 'ListParts' => array(
4990
+ 'more_results' => 'IsTruncated',
4991
+ 'limit_key' => 'MaxParts',
4992
+ 'output_token' => 'NextPartNumberMarker',
4993
+ 'input_token' => 'PartNumberMarker',
4994
+ 'result_key' => 'Parts',
4995
+ ),
4996
+ ),
4997
+ 'waiters' => array(
4998
+ '__default__' => array(
4999
+ 'interval' => 5,
5000
+ 'max_attempts' => 20,
5001
+ ),
5002
+ 'BucketExists' => array(
5003
+ 'operation' => 'HeadBucket',
5004
+ 'success.type' => 'output',
5005
+ 'ignore_errors' => array(
5006
+ 'NoSuchBucket',
5007
+ ),
5008
+ ),
5009
+ 'BucketNotExists' => array(
5010
+ 'operation' => 'HeadBucket',
5011
+ 'success.type' => 'error',
5012
+ 'success.value' => 'NoSuchBucket',
5013
+ ),
5014
+ 'ObjectExists' => array(
5015
+ 'operation' => 'HeadObject',
5016
+ 'success.type' => 'output',
5017
+ 'ignore_errors' => array(
5018
+ 'NoSuchKey',
5019
+ ),
5020
+ ),
5021
+ ),
5022
+ );
lib/amazon/aws/aws-sdk-php/src/Aws/S3/ResumableDownload.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Aws\Common\Exception\UnexpectedValueException;
21
+ use Guzzle\Http\EntityBody;
22
+ use Guzzle\Http\ReadLimitEntityBody;
23
+ use Guzzle\Http\EntityBodyInterface;
24
+ use Guzzle\Service\Resource\Model;
25
+
26
+ /**
27
+ * Allows you to resume the download of a partially downloaded object.
28
+ *
29
+ * Downloads objects from Amazon S3 in using "Range" downloads. This allows a partially downloaded object to be resumed
30
+ * so that only the remaining portion of the object is downloaded.
31
+ */
32
+ class ResumableDownload
33
+ {
34
+ /** @var S3Client The S3 client to use to download objects and issue HEAD requests */
35
+ protected $client;
36
+
37
+ /** @var \Guzzle\Service\Resource\Model Model object returned when the initial HeadObject operation was called */
38
+ protected $meta;
39
+
40
+ /** @var array Array of parameters to pass to a GetObject operation */
41
+ protected $params;
42
+
43
+ /** @var \Guzzle\Http\EntityBody Where the object will be downloaded */
44
+ protected $target;
45
+
46
+ /**
47
+ * @param S3Client $client Client to use when executing requests
48
+ * @param string $bucket Bucket that holds the object
49
+ * @param string $key Key of the object
50
+ * @param string|resource|EntityBodyInterface $target Where the object should be downloaded to. Pass a string to
51
+ * save the object to a file, pass a resource returned by
52
+ * fopen() to save the object to a stream resource, or pass a
53
+ * Guzzle EntityBody object to save the contents to an
54
+ * EntityBody.
55
+ * @param array $params Any additional GetObject or HeadObject parameters to use
56
+ * with each command issued by the client. (e.g. pass "Version"
57
+ * to download a specific version of an object)
58
+ * @throws RuntimeException if the target variable points to a file that cannot be opened
59
+ */
60
+ public function __construct(S3Client $client, $bucket, $key, $target, array $params = array())
61
+ {
62
+ $this->params = $params;
63
+ $this->client = $client;
64
+ $this->params['Bucket'] = $bucket;
65
+ $this->params['Key'] = $key;
66
+
67
+ // If a string is passed, then assume that the download should stream to a file on disk
68
+ if (is_string($target)) {
69
+ if (!($target = fopen($target, 'a+'))) {
70
+ throw new RuntimeException("Unable to open {$target} for writing");
71
+ }
72
+ // Always append to the file
73
+ fseek($target, 0, SEEK_END);
74
+ }
75
+
76
+ // Get the metadata and Content-MD5 of the object
77
+ $this->target = EntityBody::factory($target);
78
+ }
79
+
80
+ /**
81
+ * Get the bucket of the download
82
+ *
83
+ * @return string
84
+ */
85
+ public function getBucket()
86
+ {
87
+ return $this->params['Bucket'];
88
+ }
89
+
90
+ /**
91
+ * Get the key of the download
92
+ *
93
+ * @return string
94
+ */
95
+ public function getKey()
96
+ {
97
+ return $this->params['Key'];
98
+ }
99
+
100
+ /**
101
+ * Get the file to which the contents are downloaded
102
+ *
103
+ * @return string
104
+ */
105
+ public function getFilename()
106
+ {
107
+ return $this->target->getUri();
108
+ }
109
+
110
+ /**
111
+ * Download the remainder of the object from Amazon S3
112
+ *
113
+ * Performs a message integrity check if possible
114
+ *
115
+ * @return Model
116
+ */
117
+ public function __invoke()
118
+ {
119
+ $command = $this->client->getCommand('HeadObject', $this->params);
120
+ $this->meta = $command->execute();
121
+
122
+ if ($this->target->ftell() >= $this->meta['ContentLength']) {
123
+ return false;
124
+ }
125
+
126
+ $this->meta['ContentMD5'] = (string) $command->getResponse()->getHeader('Content-MD5');
127
+
128
+ // Use a ReadLimitEntityBody so that rewinding the stream after an error does not cause the file pointer
129
+ // to enter an inconsistent state with the data being downloaded
130
+ $this->params['SaveAs'] = new ReadLimitEntityBody(
131
+ $this->target,
132
+ $this->meta['ContentLength'],
133
+ $this->target->ftell()
134
+ );
135
+
136
+ $result = $this->getRemaining();
137
+ $this->checkIntegrity();
138
+
139
+ return $result;
140
+ }
141
+
142
+ /**
143
+ * Send the command to get the remainder of the object
144
+ *
145
+ * @return Model
146
+ */
147
+ protected function getRemaining()
148
+ {
149
+ $current = $this->target->ftell();
150
+ $targetByte = $this->meta['ContentLength'] - 1;
151
+ $this->params['Range'] = "bytes={$current}-{$targetByte}";
152
+
153
+ // Set the starting offset so that the body is never seeked to before this point in the event of a retry
154
+ $this->params['SaveAs']->setOffset($current);
155
+ $command = $this->client->getCommand('GetObject', $this->params);
156
+
157
+ return $command->execute();
158
+ }
159
+
160
+ /**
161
+ * Performs an MD5 message integrity check if possible
162
+ *
163
+ * @throws UnexpectedValueException if the message does not validate
164
+ */
165
+ protected function checkIntegrity()
166
+ {
167
+ if ($this->target->isReadable() && $expected = $this->meta['ContentMD5']) {
168
+ $actual = $this->target->getContentMd5();
169
+ if ($actual != $expected) {
170
+ throw new UnexpectedValueException(
171
+ "Message integrity check failed. Expected {$expected} but got {$actual}."
172
+ );
173
+ }
174
+ }
175
+ }
176
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3Client.php ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Client\AbstractClient;
20
+ use Aws\Common\Client\ClientBuilder;
21
+ use Aws\Common\Client\ExpiredCredentialsChecker;
22
+ use Aws\Common\Client\UploadBodyListener;
23
+ use Aws\Common\Enum\ClientOptions as Options;
24
+ use Aws\Common\Exception\RuntimeException;
25
+ use Aws\Common\Exception\InvalidArgumentException;
26
+ use Aws\Common\Signature\SignatureV4;
27
+ use Aws\Common\Model\MultipartUpload\AbstractTransfer;
28
+ use Aws\S3\Exception\AccessDeniedException;
29
+ use Aws\S3\Exception\Parser\S3ExceptionParser;
30
+ use Aws\S3\Exception\S3Exception;
31
+ use Aws\S3\Model\ClearBucket;
32
+ use Aws\S3\Model\MultipartUpload\AbstractTransfer as AbstractMulti;
33
+ use Aws\S3\Model\MultipartUpload\UploadBuilder;
34
+ use Aws\S3\Sync\DownloadSyncBuilder;
35
+ use Aws\S3\Sync\UploadSyncBuilder;
36
+ use Guzzle\Common\Collection;
37
+ use Guzzle\Http\EntityBody;
38
+ use Guzzle\Http\Message\RequestInterface;
39
+ use Guzzle\Iterator\FilterIterator;
40
+ use Guzzle\Plugin\Backoff\BackoffPlugin;
41
+ use Guzzle\Plugin\Backoff\CurlBackoffStrategy;
42
+ use Guzzle\Plugin\Backoff\ExponentialBackoffStrategy;
43
+ use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
44
+ use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy;
45
+ use Guzzle\Service\Command\CommandInterface;
46
+ use Guzzle\Service\Command\Factory\AliasFactory;
47
+ use Guzzle\Service\Command\Factory\CompositeFactory;
48
+ use Guzzle\Service\Resource\Model;
49
+ use Guzzle\Service\Resource\ResourceIteratorInterface;
50
+
51
+ /**
52
+ * Client to interact with Amazon Simple Storage Service
53
+ *
54
+ * @method S3SignatureInterface getSignature() Returns the signature implementation used with the client
55
+ * @method Model abortMultipartUpload(array $args = array()) {@command S3 AbortMultipartUpload}
56
+ * @method Model completeMultipartUpload(array $args = array()) {@command S3 CompleteMultipartUpload}
57
+ * @method Model copyObject(array $args = array()) {@command S3 CopyObject}
58
+ * @method Model createBucket(array $args = array()) {@command S3 CreateBucket}
59
+ * @method Model createMultipartUpload(array $args = array()) {@command S3 CreateMultipartUpload}
60
+ * @method Model deleteBucket(array $args = array()) {@command S3 DeleteBucket}
61
+ * @method Model deleteBucketCors(array $args = array()) {@command S3 DeleteBucketCors}
62
+ * @method Model deleteBucketLifecycle(array $args = array()) {@command S3 DeleteBucketLifecycle}
63
+ * @method Model deleteBucketPolicy(array $args = array()) {@command S3 DeleteBucketPolicy}
64
+ * @method Model deleteBucketReplication(array $args = array()) {@command S3 DeleteBucketReplication}
65
+ * @method Model deleteBucketTagging(array $args = array()) {@command S3 DeleteBucketTagging}
66
+ * @method Model deleteBucketWebsite(array $args = array()) {@command S3 DeleteBucketWebsite}
67
+ * @method Model deleteObject(array $args = array()) {@command S3 DeleteObject}
68
+ * @method Model deleteObjects(array $args = array()) {@command S3 DeleteObjects}
69
+ * @method Model getBucketAcl(array $args = array()) {@command S3 GetBucketAcl}
70
+ * @method Model getBucketCors(array $args = array()) {@command S3 GetBucketCors}
71
+ * @method Model getBucketLifecycle(array $args = array()) {@command S3 GetBucketLifecycle}
72
+ * @method Model getBucketLocation(array $args = array()) {@command S3 GetBucketLocation}
73
+ * @method Model getBucketLogging(array $args = array()) {@command S3 GetBucketLogging}
74
+ * @method Model getBucketNotification(array $args = array()) {@command S3 GetBucketNotification}
75
+ * @method Model getBucketPolicy(array $args = array()) {@command S3 GetBucketPolicy}
76
+ * @method Model getBucketReplication(array $args = array()) {@command S3 GetBucketReplication}
77
+ * @method Model getBucketRequestPayment(array $args = array()) {@command S3 GetBucketRequestPayment}
78
+ * @method Model getBucketTagging(array $args = array()) {@command S3 GetBucketTagging}
79
+ * @method Model getBucketVersioning(array $args = array()) {@command S3 GetBucketVersioning}
80
+ * @method Model getBucketWebsite(array $args = array()) {@command S3 GetBucketWebsite}
81
+ * @method Model getObject(array $args = array()) {@command S3 GetObject}
82
+ * @method Model getObjectAcl(array $args = array()) {@command S3 GetObjectAcl}
83
+ * @method Model getObjectTorrent(array $args = array()) {@command S3 GetObjectTorrent}
84
+ * @method Model headBucket(array $args = array()) {@command S3 HeadBucket}
85
+ * @method Model headObject(array $args = array()) {@command S3 HeadObject}
86
+ * @method Model listBuckets(array $args = array()) {@command S3 ListBuckets}
87
+ * @method Model listMultipartUploads(array $args = array()) {@command S3 ListMultipartUploads}
88
+ * @method Model listObjectVersions(array $args = array()) {@command S3 ListObjectVersions}
89
+ * @method Model listObjects(array $args = array()) {@command S3 ListObjects}
90
+ * @method Model listParts(array $args = array()) {@command S3 ListParts}
91
+ * @method Model putBucketAcl(array $args = array()) {@command S3 PutBucketAcl}
92
+ * @method Model putBucketCors(array $args = array()) {@command S3 PutBucketCors}
93
+ * @method Model putBucketLifecycle(array $args = array()) {@command S3 PutBucketLifecycle}
94
+ * @method Model putBucketLogging(array $args = array()) {@command S3 PutBucketLogging}
95
+ * @method Model putBucketNotification(array $args = array()) {@command S3 PutBucketNotification}
96
+ * @method Model putBucketPolicy(array $args = array()) {@command S3 PutBucketPolicy}
97
+ * @method Model putBucketReplication(array $args = array()) {@command S3 PutBucketReplication}
98
+ * @method Model putBucketRequestPayment(array $args = array()) {@command S3 PutBucketRequestPayment}
99
+ * @method Model putBucketTagging(array $args = array()) {@command S3 PutBucketTagging}
100
+ * @method Model putBucketVersioning(array $args = array()) {@command S3 PutBucketVersioning}
101
+ * @method Model putBucketWebsite(array $args = array()) {@command S3 PutBucketWebsite}
102
+ * @method Model putObject(array $args = array()) {@command S3 PutObject}
103
+ * @method Model putObjectAcl(array $args = array()) {@command S3 PutObjectAcl}
104
+ * @method Model restoreObject(array $args = array()) {@command S3 RestoreObject}
105
+ * @method Model uploadPart(array $args = array()) {@command S3 UploadPart}
106
+ * @method Model uploadPartCopy(array $args = array()) {@command S3 UploadPartCopy}
107
+ * @method waitUntilBucketExists(array $input) The input array uses the parameters of the HeadBucket operation and waiter specific settings
108
+ * @method waitUntilBucketNotExists(array $input) The input array uses the parameters of the HeadBucket operation and waiter specific settings
109
+ * @method waitUntilObjectExists(array $input) The input array uses the parameters of the HeadObject operation and waiter specific settings
110
+ * @method ResourceIteratorInterface getListBucketsIterator(array $args = array()) The input array uses the parameters of the ListBuckets operation
111
+ * @method ResourceIteratorInterface getListMultipartUploadsIterator(array $args = array()) The input array uses the parameters of the ListMultipartUploads operation
112
+ * @method ResourceIteratorInterface getListObjectVersionsIterator(array $args = array()) The input array uses the parameters of the ListObjectVersions operation
113
+ * @method ResourceIteratorInterface getListObjectsIterator(array $args = array()) The input array uses the parameters of the ListObjects operation
114
+ * @method ResourceIteratorInterface getListPartsIterator(array $args = array()) The input array uses the parameters of the ListParts operation
115
+ *
116
+ * @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-s3.html User guide
117
+ * @link http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.S3.S3Client.html API docs
118
+ */
119
+ class S3Client extends AbstractClient
120
+ {
121
+ const LATEST_API_VERSION = '2006-03-01';
122
+
123
+ /**
124
+ * @var array Aliases for S3 operations
125
+ */
126
+ protected static $commandAliases = array(
127
+ // REST API Docs Aliases
128
+ 'GetService' => 'ListBuckets',
129
+ 'GetBucket' => 'ListObjects',
130
+ 'PutBucket' => 'CreateBucket',
131
+
132
+ // SDK 1.x Aliases
133
+ 'GetBucketHeaders' => 'HeadBucket',
134
+ 'GetObjectHeaders' => 'HeadObject',
135
+ 'SetBucketAcl' => 'PutBucketAcl',
136
+ 'CreateObject' => 'PutObject',
137
+ 'DeleteObjects' => 'DeleteMultipleObjects',
138
+ 'PutObjectCopy' => 'CopyObject',
139
+ 'SetObjectAcl' => 'PutObjectAcl',
140
+ 'GetLogs' => 'GetBucketLogging',
141
+ 'GetVersioningStatus' => 'GetBucketVersioning',
142
+ 'SetBucketPolicy' => 'PutBucketPolicy',
143
+ 'CreateBucketNotification' => 'PutBucketNotification',
144
+ 'GetBucketNotifications' => 'GetBucketNotification',
145
+ 'CopyPart' => 'UploadPartCopy',
146
+ 'CreateWebsiteConfig' => 'PutBucketWebsite',
147
+ 'GetWebsiteConfig' => 'GetBucketWebsite',
148
+ 'DeleteWebsiteConfig' => 'DeleteBucketWebsite',
149
+ 'CreateObjectExpirationConfig' => 'PutBucketLifecycle',
150
+ 'GetObjectExpirationConfig' => 'GetBucketLifecycle',
151
+ 'DeleteObjectExpirationConfig' => 'DeleteBucketLifecycle',
152
+ );
153
+
154
+ protected $directory = __DIR__;
155
+
156
+ /**
157
+ * Factory method to create a new Amazon S3 client using an array of configuration options.
158
+ *
159
+ * @param array|Collection $config Client configuration data
160
+ *
161
+ * @return S3Client
162
+ * @link http://docs.aws.amazon.com/aws-sdk-php/v2/guide/configuration.html#client-configuration-options
163
+ */
164
+ public static function factory($config = array())
165
+ {
166
+ $exceptionParser = new S3ExceptionParser();
167
+
168
+ // Configure the custom exponential backoff plugin for retrying S3 specific errors
169
+ if (!isset($config[Options::BACKOFF])) {
170
+ $config[Options::BACKOFF] = static::createBackoffPlugin($exceptionParser);
171
+ }
172
+
173
+ $config[Options::SIGNATURE] = $signature = static::createSignature($config);
174
+
175
+ $client = ClientBuilder::factory(__NAMESPACE__)
176
+ ->setConfig($config)
177
+ ->setConfigDefaults(array(
178
+ Options::VERSION => self::LATEST_API_VERSION,
179
+ Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/s3-%s.php'
180
+ ))
181
+ ->setExceptionParser($exceptionParser)
182
+ ->setIteratorsConfig(array(
183
+ 'more_key' => 'IsTruncated',
184
+ 'operations' => array(
185
+ 'ListBuckets',
186
+ 'ListMultipartUploads' => array(
187
+ 'limit_param' => 'MaxUploads',
188
+ 'token_param' => array('KeyMarker', 'UploadIdMarker'),
189
+ 'token_key' => array('NextKeyMarker', 'NextUploadIdMarker'),
190
+ ),
191
+ 'ListObjects' => array(
192
+ 'limit_param' => 'MaxKeys',
193
+ 'token_param' => 'Marker',
194
+ 'token_key' => 'NextMarker',
195
+ ),
196
+ 'ListObjectVersions' => array(
197
+ 'limit_param' => 'MaxKeys',
198
+ 'token_param' => array('KeyMarker', 'VersionIdMarker'),
199
+ 'token_key' => array('nextKeyMarker', 'nextVersionIdMarker'),
200
+ ),
201
+ 'ListParts' => array(
202
+ 'limit_param' => 'MaxParts',
203
+ 'result_key' => 'Parts',
204
+ 'token_param' => 'PartNumberMarker',
205
+ 'token_key' => 'NextPartNumberMarker',
206
+ ),
207
+ )
208
+ ))
209
+ ->build();
210
+
211
+ // Use virtual hosted buckets when possible
212
+ $client->addSubscriber(new BucketStyleListener());
213
+ // Ensure that ACP headers are applied when needed
214
+ $client->addSubscriber(new AcpListener());
215
+ // Validate and add required Content-MD5 hashes (e.g. DeleteObjects)
216
+ $client->addSubscriber(new S3Md5Listener($signature));
217
+
218
+ // Allow for specifying bodies with file paths and file handles
219
+ $client->addSubscriber(new UploadBodyListener(array('PutObject', 'UploadPart')));
220
+
221
+ // Ensures that if a SSE-CPK key is provided, the key and md5 are formatted correctly
222
+ $client->addSubscriber(new SseCpkListener);
223
+
224
+ // Add aliases for some S3 operations
225
+ $default = CompositeFactory::getDefaultChain($client);
226
+ $default->add(
227
+ new AliasFactory($client, static::$commandAliases),
228
+ 'Guzzle\Service\Command\Factory\ServiceDescriptionFactory'
229
+ );
230
+ $client->setCommandFactory($default);
231
+
232
+ return $client;
233
+ }
234
+
235
+ /**
236
+ * Create an Amazon S3 specific backoff plugin
237
+ *
238
+ * @param S3ExceptionParser $exceptionParser
239
+ *
240
+ * @return BackoffPlugin
241
+ */
242
+ private static function createBackoffPlugin(S3ExceptionParser $exceptionParser)
243
+ {
244
+ return new BackoffPlugin(
245
+ new TruncatedBackoffStrategy(3,
246
+ new CurlBackoffStrategy(null,
247
+ new HttpBackoffStrategy(null,
248
+ new SocketTimeoutChecker(
249
+ new ExpiredCredentialsChecker($exceptionParser,
250
+ new ExponentialBackoffStrategy()
251
+ )
252
+ )
253
+ )
254
+ )
255
+ )
256
+ );
257
+ }
258
+
259
+ /**
260
+ * Create an appropriate signature based on the configuration settings
261
+ *
262
+ * @param $config
263
+ *
264
+ * @return \Aws\Common\Signature\SignatureInterface
265
+ * @throws InvalidArgumentException
266
+ */
267
+ private static function createSignature($config)
268
+ {
269
+ $currentValue = isset($config[Options::SIGNATURE]) ? $config[Options::SIGNATURE] : null;
270
+
271
+ // Force v4 if no value is provided, a region is in the config, and
272
+ // the region starts with "cn-" or "eu-central-".
273
+ $requiresV4 = !$currentValue
274
+ && isset($config['region'])
275
+ && (strpos($config['region'], 'eu-central-') === 0
276
+ || strpos($config['region'], 'cn-') === 0);
277
+
278
+ // Use the Amazon S3 signature V4 when the value is set to "v4" or when
279
+ // the value is not set and the region starts with "cn-".
280
+ if ($currentValue == 'v4' || $requiresV4) {
281
+ // Force SignatureV4 for specific regions or if specified in the config
282
+ $currentValue = new S3SignatureV4('s3');
283
+ } elseif (!$currentValue || $currentValue == 's3') {
284
+ // Use the Amazon S3 signature by default
285
+ $currentValue = new S3Signature();
286
+ }
287
+
288
+ // A region is require with v4
289
+ if ($currentValue instanceof SignatureV4 && !isset($config['region'])) {
290
+ throw new InvalidArgumentException('A region must be specified '
291
+ . 'when using signature version 4');
292
+ }
293
+
294
+ return $currentValue;
295
+ }
296
+
297
+ /**
298
+ * Determine if a string is a valid name for a DNS compatible Amazon S3
299
+ * bucket, meaning the bucket can be used as a subdomain in a URL (e.g.,
300
+ * "<bucket>.s3.amazonaws.com").
301
+ *
302
+ * @param string $bucket The name of the bucket to check.
303
+ *
304
+ * @return bool TRUE if the bucket name is valid or FALSE if it is invalid.
305
+ */
306
+ public static function isValidBucketName($bucket)
307
+ {
308
+ $bucketLen = strlen($bucket);
309
+ if ($bucketLen < 3 || $bucketLen > 63 ||
310
+ // Cannot look like an IP address
311
+ preg_match('/(\d+\.){3}\d+$/', $bucket) ||
312
+ // Cannot include special characters, must start and end with lower alnum
313
+ !preg_match('/^[a-z0-9]([a-z0-9\-\.]*[a-z0-9])?$/', $bucket)
314
+ ) {
315
+ return false;
316
+ }
317
+
318
+ return true;
319
+ }
320
+
321
+ /**
322
+ * Create a pre-signed URL for a request
323
+ *
324
+ * @param RequestInterface $request Request to generate the URL for. Use the factory methods of the client to
325
+ * create this request object
326
+ * @param int|string|\DateTime $expires The time at which the URL should expire. This can be a Unix timestamp, a
327
+ * PHP DateTime object, or a string that can be evaluated by strtotime
328
+ *
329
+ * @return string
330
+ * @throws InvalidArgumentException if the request is not associated with this client object
331
+ */
332
+ public function createPresignedUrl(RequestInterface $request, $expires)
333
+ {
334
+ if ($request->getClient() !== $this) {
335
+ throw new InvalidArgumentException('The request object must be associated with the client. Use the '
336
+ . '$client->get(), $client->head(), $client->post(), $client->put(), etc. methods when passing in a '
337
+ . 'request object');
338
+ }
339
+
340
+ return $this->signature->createPresignedUrl($request, $this->credentials, $expires);
341
+ }
342
+
343
+ /**
344
+ * Returns the URL to an object identified by its bucket and key. If an expiration time is provided, the URL will
345
+ * be signed and set to expire at the provided time.
346
+ *
347
+ * @param string $bucket The name of the bucket where the object is located
348
+ * @param string $key The key of the object
349
+ * @param mixed $expires The time at which the URL should expire
350
+ * @param array $args Arguments to the GetObject command. Additionally you can specify a "Scheme" if you would
351
+ * like the URL to use a different scheme than what the client is configured to use
352
+ *
353
+ * @return string The URL to the object
354
+ */
355
+ public function getObjectUrl($bucket, $key, $expires = null, array $args = array())
356
+ {
357
+ $command = $this->getCommand('GetObject', $args + array('Bucket' => $bucket, 'Key' => $key));
358
+
359
+ if ($command->hasKey('Scheme')) {
360
+ $scheme = $command['Scheme'];
361
+ $request = $command->remove('Scheme')->prepare()->setScheme($scheme)->setPort(null);
362
+ } else {
363
+ $request = $command->prepare();
364
+ }
365
+
366
+ return $expires ? $this->createPresignedUrl($request, $expires) : $request->getUrl();
367
+ }
368
+
369
+ /**
370
+ * Helper used to clear the contents of a bucket. Use the {@see ClearBucket} object directly
371
+ * for more advanced options and control.
372
+ *
373
+ * @param string $bucket Name of the bucket to clear.
374
+ *
375
+ * @return int Returns the number of deleted keys
376
+ */
377
+ public function clearBucket($bucket)
378
+ {
379
+ $clear = new ClearBucket($this, $bucket);
380
+
381
+ return $clear->clear();
382
+ }
383
+
384
+ /**
385
+ * Determines whether or not a bucket exists by name
386
+ *
387
+ * @param string $bucket The name of the bucket
388
+ * @param bool $accept403 Set to true if 403s are acceptable
389
+ * @param array $options Additional options to add to the executed command
390
+ *
391
+ * @return bool
392
+ */
393
+ public function doesBucketExist($bucket, $accept403 = true, array $options = array())
394
+ {
395
+ return $this->checkExistenceWithCommand(
396
+ $this->getCommand('HeadBucket', array_merge($options, array(
397
+ 'Bucket' => $bucket
398
+ ))), $accept403
399
+ );
400
+ }
401
+
402
+ /**
403
+ * Determines whether or not an object exists by name
404
+ *
405
+ * @param string $bucket The name of the bucket
406
+ * @param string $key The key of the object
407
+ * @param array $options Additional options to add to the executed command
408
+ *
409
+ * @return bool
410
+ */
411
+ public function doesObjectExist($bucket, $key, array $options = array())
412
+ {
413
+ return $this->checkExistenceWithCommand(
414
+ $this->getCommand('HeadObject', array_merge($options, array(
415
+ 'Bucket' => $bucket,
416
+ 'Key' => $key
417
+ )))
418
+ );
419
+ }
420
+
421
+ /**
422
+ * Determines whether or not a bucket policy exists for a bucket
423
+ *
424
+ * @param string $bucket The name of the bucket
425
+ * @param array $options Additional options to add to the executed command
426
+ *
427
+ * @return bool
428
+ */
429
+ public function doesBucketPolicyExist($bucket, array $options = array())
430
+ {
431
+ return $this->checkExistenceWithCommand(
432
+ $this->getCommand('GetBucketPolicy', array_merge($options, array(
433
+ 'Bucket' => $bucket
434
+ )))
435
+ );
436
+ }
437
+
438
+ /**
439
+ * Raw URL encode a key and allow for '/' characters
440
+ *
441
+ * @param string $key Key to encode
442
+ *
443
+ * @return string Returns the encoded key
444
+ */
445
+ public static function encodeKey($key)
446
+ {
447
+ return str_replace('%2F', '/', rawurlencode($key));
448
+ }
449
+
450
+ /**
451
+ * Explode a prefixed key into an array of values
452
+ *
453
+ * @param string $key Key to explode
454
+ *
455
+ * @return array Returns the exploded
456
+ */
457
+ public static function explodeKey($key)
458
+ {
459
+ // Remove a leading slash if one is found
460
+ return explode('/', $key && $key[0] == '/' ? substr($key, 1) : $key);
461
+ }
462
+
463
+ /**
464
+ * Register the Amazon S3 stream wrapper and associates it with this client object
465
+ *
466
+ * @return $this
467
+ */
468
+ public function registerStreamWrapper()
469
+ {
470
+ StreamWrapper::register($this);
471
+
472
+ return $this;
473
+ }
474
+
475
+ /**
476
+ * Upload a file, stream, or string to a bucket. If the upload size exceeds the specified threshold, the upload
477
+ * will be performed using parallel multipart uploads.
478
+ *
479
+ * @param string $bucket Bucket to upload the object
480
+ * @param string $key Key of the object
481
+ * @param mixed $body Object data to upload. Can be a Guzzle\Http\EntityBodyInterface, stream resource, or
482
+ * string of data to upload.
483
+ * @param string $acl ACL to apply to the object
484
+ * @param array $options Custom options used when executing commands:
485
+ * - params: Custom parameters to use with the upload. The parameters must map to a PutObject
486
+ * or InitiateMultipartUpload operation parameters.
487
+ * - min_part_size: Minimum size to allow for each uploaded part when performing a multipart upload.
488
+ * - concurrency: Maximum number of concurrent multipart uploads.
489
+ * - before_upload: Callback to invoke before each multipart upload. The callback will receive a
490
+ * Guzzle\Common\Event object with context.
491
+ *
492
+ * @see Aws\S3\Model\MultipartUpload\UploadBuilder for more options and customization
493
+ * @return \Guzzle\Service\Resource\Model Returns the modeled result of the performed operation
494
+ */
495
+ public function upload($bucket, $key, $body, $acl = 'private', array $options = array())
496
+ {
497
+ $body = EntityBody::factory($body);
498
+ $options = Collection::fromConfig(array_change_key_case($options), array(
499
+ 'min_part_size' => AbstractMulti::MIN_PART_SIZE,
500
+ 'params' => array(),
501
+ 'concurrency' => $body->getWrapper() == 'plainfile' ? 3 : 1
502
+ ));
503
+
504
+ if ($body->getSize() < $options['min_part_size']) {
505
+ // Perform a simple PutObject operation
506
+ return $this->putObject(array(
507
+ 'Bucket' => $bucket,
508
+ 'Key' => $key,
509
+ 'Body' => $body,
510
+ 'ACL' => $acl
511
+ ) + $options['params']);
512
+ }
513
+
514
+ // Perform a multipart upload if the file is large enough
515
+ $transfer = UploadBuilder::newInstance()
516
+ ->setBucket($bucket)
517
+ ->setKey($key)
518
+ ->setMinPartSize($options['min_part_size'])
519
+ ->setConcurrency($options['concurrency'])
520
+ ->setClient($this)
521
+ ->setSource($body)
522
+ ->setTransferOptions($options->toArray())
523
+ ->addOptions($options['params'])
524
+ ->setOption('ACL', $acl)
525
+ ->build();
526
+
527
+ if ($options['before_upload']) {
528
+ $transfer->getEventDispatcher()->addListener(
529
+ AbstractTransfer::BEFORE_PART_UPLOAD,
530
+ $options['before_upload']
531
+ );
532
+ }
533
+
534
+ return $transfer->upload();
535
+ }
536
+
537
+ /**
538
+ * Recursively uploads all files in a given directory to a given bucket.
539
+ *
540
+ * @param string $directory Full path to a directory to upload
541
+ * @param string $bucket Name of the bucket
542
+ * @param string $keyPrefix Virtual directory key prefix to add to each upload
543
+ * @param array $options Associative array of upload options
544
+ * - params: Array of parameters to use with each PutObject operation performed during the transfer
545
+ * - base_dir: Base directory to remove from each object key
546
+ * - force: Set to true to upload every file, even if the file is already in Amazon S3 and has not changed
547
+ * - concurrency: Maximum number of parallel uploads (defaults to 10)
548
+ * - debug: Set to true or an fopen resource to enable debug mode to print information about each upload
549
+ * - multipart_upload_size: When the size of a file exceeds this value, the file will be uploaded using a
550
+ * multipart upload.
551
+ *
552
+ * @see Aws\S3\S3Sync\S3Sync for more options and customization
553
+ */
554
+ public function uploadDirectory($directory, $bucket, $keyPrefix = null, array $options = array())
555
+ {
556
+ $options = Collection::fromConfig(
557
+ $options,
558
+ array(
559
+ 'base_dir' => realpath($directory) ?: $directory
560
+ )
561
+ );
562
+
563
+ $builder = $options['builder'] ?: UploadSyncBuilder::getInstance();
564
+ $builder->uploadFromDirectory($directory)
565
+ ->setClient($this)
566
+ ->setBucket($bucket)
567
+ ->setKeyPrefix($keyPrefix)
568
+ ->setConcurrency($options['concurrency'] ?: 5)
569
+ ->setBaseDir($options['base_dir'])
570
+ ->force($options['force'])
571
+ ->setOperationParams($options['params'] ?: array())
572
+ ->enableDebugOutput($options['debug']);
573
+
574
+ if ($options->hasKey('multipart_upload_size')) {
575
+ $builder->setMultipartUploadSize($options['multipart_upload_size']);
576
+ }
577
+
578
+ $builder->build()->transfer();
579
+ }
580
+
581
+ /**
582
+ * Downloads a bucket to the local filesystem
583
+ *
584
+ * @param string $directory Directory to download to
585
+ * @param string $bucket Bucket to download from
586
+ * @param string $keyPrefix Only download objects that use this key prefix
587
+ * @param array $options Associative array of download options
588
+ * - params: Array of parameters to use with each GetObject operation performed during the transfer
589
+ * - base_dir: Base directory to remove from each object key when storing in the local filesystem
590
+ * - force: Set to true to download every file, even if the file is already on the local filesystem and has not
591
+ * changed
592
+ * - concurrency: Maximum number of parallel downloads (defaults to 10)
593
+ * - debug: Set to true or a fopen resource to enable debug mode to print information about each download
594
+ * - allow_resumable: Set to true to allow previously interrupted downloads to be resumed using a Range GET
595
+ */
596
+ public function downloadBucket($directory, $bucket, $keyPrefix = '', array $options = array())
597
+ {
598
+ $options = new Collection($options);
599
+ $builder = $options['builder'] ?: DownloadSyncBuilder::getInstance();
600
+ $builder->setDirectory($directory)
601
+ ->setClient($this)
602
+ ->setBucket($bucket)
603
+ ->setKeyPrefix($keyPrefix)
604
+ ->setConcurrency($options['concurrency'] ?: 10)
605
+ ->setBaseDir($options['base_dir'])
606
+ ->force($options['force'])
607
+ ->setOperationParams($options['params'] ?: array())
608
+ ->enableDebugOutput($options['debug']);
609
+
610
+ if ($options['allow_resumable']) {
611
+ $builder->allowResumableDownloads();
612
+ }
613
+
614
+ $builder->build()->transfer();
615
+ }
616
+
617
+ /**
618
+ * Deletes objects from Amazon S3 that match the result of a ListObjects operation. For example, this allows you
619
+ * to do things like delete all objects that match a specific key prefix.
620
+ *
621
+ * @param string $bucket Bucket that contains the object keys
622
+ * @param string $prefix Optionally delete only objects under this key prefix
623
+ * @param string $regex Delete only objects that match this regex
624
+ * @param array $options Options used when deleting the object:
625
+ * - before_delete: Callback to invoke before each delete. The callback will receive a
626
+ * Guzzle\Common\Event object with context.
627
+ *
628
+ * @see Aws\S3\S3Client::listObjects
629
+ * @see Aws\S3\Model\ClearBucket For more options or customization
630
+ * @return int Returns the number of deleted keys
631
+ * @throws RuntimeException if no prefix and no regex is given
632
+ */
633
+ public function deleteMatchingObjects($bucket, $prefix = '', $regex = '', array $options = array())
634
+ {
635
+ if (!$prefix && !$regex) {
636
+ throw new RuntimeException('A prefix or regex is required, or use S3Client::clearBucket().');
637
+ }
638
+
639
+ $clear = new ClearBucket($this, $bucket);
640
+ $iterator = $this->getIterator('ListObjects', array('Bucket' => $bucket, 'Prefix' => $prefix));
641
+
642
+ if ($regex) {
643
+ $iterator = new FilterIterator($iterator, function ($current) use ($regex) {
644
+ return preg_match($regex, $current['Key']);
645
+ });
646
+ }
647
+
648
+ $clear->setIterator($iterator);
649
+ if (isset($options['before_delete'])) {
650
+ $clear->getEventDispatcher()->addListener(ClearBucket::BEFORE_CLEAR, $options['before_delete']);
651
+ }
652
+
653
+ return $clear->clear();
654
+ }
655
+
656
+ /**
657
+ * Determines whether or not a resource exists using a command
658
+ *
659
+ * @param CommandInterface $command Command used to poll for the resource
660
+ * @param bool $accept403 Set to true if 403s are acceptable
661
+ *
662
+ * @return bool
663
+ * @throws S3Exception|\Exception if there is an unhandled exception
664
+ */
665
+ protected function checkExistenceWithCommand(CommandInterface $command, $accept403 = false)
666
+ {
667
+ try {
668
+ $command->execute();
669
+ $exists = true;
670
+ } catch (AccessDeniedException $e) {
671
+ $exists = (bool) $accept403;
672
+ } catch (S3Exception $e) {
673
+ $exists = false;
674
+ if ($e->getResponse()->getStatusCode() >= 500) {
675
+ // @codeCoverageIgnoreStart
676
+ throw $e;
677
+ // @codeCoverageIgnoreEnd
678
+ }
679
+ }
680
+
681
+ return $exists;
682
+ }
683
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3Md5Listener.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Signature\SignatureV4;
20
+ use Aws\Common\Signature\SignatureInterface;
21
+ use Guzzle\Common\Event;
22
+ use Guzzle\Service\Command\CommandInterface;
23
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
24
+
25
+ /**
26
+ * Adds required and optional Content-MD5 headers
27
+ */
28
+ class S3Md5Listener implements EventSubscriberInterface
29
+ {
30
+ /** @var S3SignatureInterface */
31
+ private $signature;
32
+
33
+ public static function getSubscribedEvents()
34
+ {
35
+ return array('command.after_prepare' => 'onCommandAfterPrepare');
36
+ }
37
+
38
+ public function __construct(SignatureInterface $signature)
39
+ {
40
+ $this->signature = $signature;
41
+ }
42
+
43
+ public function onCommandAfterPrepare(Event $event)
44
+ {
45
+ $command = $event['command'];
46
+ $operation = $command->getOperation();
47
+
48
+ if ($operation->getData('contentMd5')) {
49
+ // Add the MD5 if it is required for all signers
50
+ $this->addMd5($command);
51
+ } elseif ($operation->hasParam('ContentMD5')) {
52
+ $value = $command['ContentMD5'];
53
+ // Add a computed MD5 if the parameter is set to true or if
54
+ // not using Signature V4 and the value is not set (null).
55
+ if ($value === true ||
56
+ ($value === null && !($this->signature instanceof SignatureV4))
57
+ ) {
58
+ $this->addMd5($command);
59
+ }
60
+ }
61
+ }
62
+
63
+ private function addMd5(CommandInterface $command)
64
+ {
65
+ $request = $command->getRequest();
66
+ $body = $request->getBody();
67
+ if ($body && $body->getSize() > 0) {
68
+ if (false !== ($md5 = $body->getContentMd5(true, true))) {
69
+ $request->setHeader('Content-MD5', $md5);
70
+ }
71
+ }
72
+ }
73
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3Signature.php ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Credentials\CredentialsInterface;
20
+ use Guzzle\Http\Message\RequestInterface;
21
+ use Guzzle\Http\QueryString;
22
+ use Guzzle\Http\Url;
23
+
24
+ /**
25
+ * Default Amazon S3 signature implementation
26
+ * @link http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
27
+ */
28
+ class S3Signature implements S3SignatureInterface
29
+ {
30
+ /**
31
+ * @var array Query string values that must be signed
32
+ */
33
+ protected $signableQueryString = array (
34
+ 'acl',
35
+ 'cors',
36
+ 'delete',
37
+ 'lifecycle',
38
+ 'location',
39
+ 'logging',
40
+ 'notification',
41
+ 'partNumber',
42
+ 'policy',
43
+ 'requestPayment',
44
+ 'response-cache-control',
45
+ 'response-content-disposition',
46
+ 'response-content-encoding',
47
+ 'response-content-language',
48
+ 'response-content-type',
49
+ 'response-expires',
50
+ 'restore',
51
+ 'tagging',
52
+ 'torrent',
53
+ 'uploadId',
54
+ 'uploads',
55
+ 'versionId',
56
+ 'versioning',
57
+ 'versions',
58
+ 'website',
59
+ );
60
+
61
+ /** @var array Sorted headers that must be signed */
62
+ private $signableHeaders = array('Content-MD5', 'Content-Type');
63
+
64
+ public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
65
+ {
66
+ // Ensure that the signable query string parameters are sorted
67
+ sort($this->signableQueryString);
68
+
69
+ // Add the security token header if one is being used by the credentials
70
+ if ($token = $credentials->getSecurityToken()) {
71
+ $request->setHeader('x-amz-security-token', $token);
72
+ }
73
+
74
+ $request->removeHeader('x-amz-date');
75
+ $request->setHeader('Date', gmdate(\DateTime::RFC2822));
76
+
77
+ $stringToSign = $this->createCanonicalizedString($request);
78
+ $request->getParams()->set('aws.string_to_sign', $stringToSign);
79
+
80
+ $request->setHeader(
81
+ 'Authorization',
82
+ 'AWS ' . $credentials->getAccessKeyId() . ':' . $this->signString($stringToSign, $credentials)
83
+ );
84
+ }
85
+
86
+ public function createPresignedUrl(
87
+ RequestInterface $request,
88
+ CredentialsInterface $credentials,
89
+ $expires
90
+ ) {
91
+ if ($expires instanceof \DateTime) {
92
+ $expires = $expires->getTimestamp();
93
+ } elseif (!is_numeric($expires)) {
94
+ $expires = strtotime($expires);
95
+ }
96
+
97
+ // Operate on a clone of the request, so the original is not altered
98
+ $request = clone $request;
99
+
100
+ // URL encoding already occurs in the URI template expansion. Undo that and encode using the same encoding as
101
+ // GET object, PUT object, etc.
102
+ $path = S3Client::encodeKey(rawurldecode($request->getPath()));
103
+ $request->setPath($path);
104
+
105
+ // Make sure to handle temporary credentials
106
+ if ($token = $credentials->getSecurityToken()) {
107
+ $request->setHeader('x-amz-security-token', $token);
108
+ $request->getQuery()->set('x-amz-security-token', $token);
109
+ }
110
+
111
+ // Set query params required for pre-signed URLs
112
+ $request->getQuery()
113
+ ->set('AWSAccessKeyId', $credentials->getAccessKeyId())
114
+ ->set('Expires', $expires)
115
+ ->set('Signature', $this->signString(
116
+ $this->createCanonicalizedString($request, $expires),
117
+ $credentials
118
+ ));
119
+
120
+ // Move X-Amz-* headers to the query string
121
+ foreach ($request->getHeaders() as $name => $header) {
122
+ $name = strtolower($name);
123
+ if (strpos($name, 'x-amz-') === 0) {
124
+ $request->getQuery()->set($name, (string) $header);
125
+ $request->removeHeader($name);
126
+ }
127
+ }
128
+
129
+ return $request->getUrl();
130
+ }
131
+
132
+ public function signString($string, CredentialsInterface $credentials)
133
+ {
134
+ return base64_encode(hash_hmac('sha1', $string, $credentials->getSecretKey(), true));
135
+ }
136
+
137
+ public function createCanonicalizedString(RequestInterface $request, $expires = null)
138
+ {
139
+ $buffer = $request->getMethod() . "\n";
140
+
141
+ // Add the interesting headers
142
+ foreach ($this->signableHeaders as $header) {
143
+ $buffer .= (string) $request->getHeader($header) . "\n";
144
+ }
145
+
146
+ // Choose dates from left to right based on what's set
147
+ $date = $expires ?: (string) $request->getHeader('date');
148
+
149
+ $buffer .= "{$date}\n"
150
+ . $this->createCanonicalizedAmzHeaders($request)
151
+ . $this->createCanonicalizedResource($request);
152
+
153
+ return $buffer;
154
+ }
155
+
156
+ /**
157
+ * Create a canonicalized AmzHeaders string for a signature.
158
+ *
159
+ * @param RequestInterface $request Request from which to gather headers
160
+ *
161
+ * @return string Returns canonicalized AMZ headers.
162
+ */
163
+ private function createCanonicalizedAmzHeaders(RequestInterface $request)
164
+ {
165
+ $headers = array();
166
+ foreach ($request->getHeaders() as $name => $header) {
167
+ $name = strtolower($name);
168
+ if (strpos($name, 'x-amz-') === 0) {
169
+ $value = trim((string) $header);
170
+ if ($value || $value === '0') {
171
+ $headers[$name] = $name . ':' . $value;
172
+ }
173
+ }
174
+ }
175
+
176
+ if (!$headers) {
177
+ return '';
178
+ }
179
+
180
+ ksort($headers);
181
+
182
+ return implode("\n", $headers) . "\n";
183
+ }
184
+
185
+ /**
186
+ * Create a canonicalized resource for a request
187
+ *
188
+ * @param RequestInterface $request Request for the resource
189
+ *
190
+ * @return string
191
+ */
192
+ private function createCanonicalizedResource(RequestInterface $request)
193
+ {
194
+ $buffer = $request->getParams()->get('s3.resource');
195
+ // When sending a raw HTTP request (e.g. $client->get())
196
+ if (null === $buffer) {
197
+ $bucket = $request->getParams()->get('bucket') ?: $this->parseBucketName($request);
198
+ // Use any specified bucket name, the parsed bucket name, or no bucket name when interacting with GetService
199
+ $buffer = $bucket ? "/{$bucket}" : '';
200
+ // Remove encoding from the path and use the S3 specific encoding
201
+ $path = S3Client::encodeKey(rawurldecode($request->getPath()));
202
+ // if the bucket was path style, then ensure that the bucket wasn't duplicated in the resource
203
+ $buffer .= preg_replace("#^/{$bucket}/{$bucket}#", "/{$bucket}", $path);
204
+ }
205
+
206
+ // Remove double slashes
207
+ $buffer = str_replace('//', '/', $buffer);
208
+
209
+ // Add sub resource parameters
210
+ $query = $request->getQuery();
211
+ $first = true;
212
+ foreach ($this->signableQueryString as $key) {
213
+ if ($query->hasKey($key)) {
214
+ $value = $query[$key];
215
+ $buffer .= $first ? '?' : '&';
216
+ $first = false;
217
+ $buffer .= $key;
218
+ // Don't add values for empty sub-resources
219
+ if ($value !== '' &&
220
+ $value !== false &&
221
+ $value !== null &&
222
+ $value !== QueryString::BLANK
223
+ ) {
224
+ $buffer .= "={$value}";
225
+ }
226
+ }
227
+ }
228
+
229
+ return $buffer;
230
+ }
231
+
232
+ /**
233
+ * Parse the bucket name from a request object
234
+ *
235
+ * @param RequestInterface $request Request to parse
236
+ *
237
+ * @return string
238
+ */
239
+ private function parseBucketName(RequestInterface $request)
240
+ {
241
+ $baseUrl = Url::factory($request->getClient()->getBaseUrl());
242
+ $baseHost = $baseUrl->getHost();
243
+ $host = $request->getHost();
244
+
245
+ if (strpos($host, $baseHost) === false) {
246
+ // Does not contain the base URL, so it's either a redirect, CNAME, or using a different region
247
+ $baseHost = '';
248
+ // For every known S3 host, check if that host is present on the request
249
+ $regions = $request->getClient()->getDescription()->getData('regions');
250
+ foreach ($regions as $region) {
251
+ if (strpos($host, $region['hostname']) !== false) {
252
+ // This host matches the request host. Tells use the region and endpoint-- we can derive the bucket
253
+ $baseHost = $region['hostname'];
254
+ break;
255
+ }
256
+ }
257
+ // If no matching base URL was found, then assume that this is a CNAME, and the CNAME is the bucket
258
+ if (!$baseHost) {
259
+ return $host;
260
+ }
261
+ }
262
+
263
+ // Remove the baseURL from the host of the request to attempt to determine the bucket name
264
+ return trim(str_replace($baseHost, '', $request->getHost()), ' .');
265
+ }
266
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3SignatureInterface.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Signature\SignatureInterface;
20
+
21
+ /**
22
+ * @deprecated
23
+ */
24
+ interface S3SignatureInterface extends SignatureInterface {}
lib/amazon/aws/aws-sdk-php/src/Aws/S3/S3SignatureV4.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Signature\SignatureV4;
20
+ use Aws\Common\Credentials\CredentialsInterface;
21
+ use Guzzle\Http\Message\EntityEnclosingRequestInterface;
22
+ use Guzzle\Http\Message\RequestInterface;
23
+
24
+ /**
25
+ * Amazon S3 signature version 4 overrides.
26
+ */
27
+ class S3SignatureV4 extends SignatureV4 implements S3SignatureInterface
28
+ {
29
+ /**
30
+ * Always add a x-amz-content-sha-256 for data integrity.
31
+ */
32
+ public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
33
+ {
34
+ if (!$request->hasHeader('x-amz-content-sha256')) {
35
+ $request->setHeader(
36
+ 'x-amz-content-sha256',
37
+ $this->getPayload($request)
38
+ );
39
+ }
40
+
41
+ parent::signRequest($request, $credentials);
42
+ }
43
+
44
+ /**
45
+ * Override used to allow pre-signed URLs to be created for an
46
+ * in-determinate request payload.
47
+ */
48
+ protected function getPresignedPayload(RequestInterface $request)
49
+ {
50
+ return 'UNSIGNED-PAYLOAD';
51
+ }
52
+
53
+ /**
54
+ * Amazon S3 does not double-encode the path component in the canonical req
55
+ */
56
+ protected function createCanonicalizedPath(RequestInterface $request)
57
+ {
58
+ return '/' . ltrim($request->getPath(), '/');
59
+ }
60
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/SocketTimeoutChecker.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Guzzle\Http\Exception\HttpException;
20
+ use Guzzle\Http\Message\RequestInterface;
21
+ use Guzzle\Http\Message\EntityEnclosingRequestInterface;
22
+ use Guzzle\Http\Message\Response;
23
+ use Guzzle\Plugin\Backoff\BackoffStrategyInterface;
24
+ use Guzzle\Plugin\Backoff\AbstractBackoffStrategy;
25
+
26
+ /**
27
+ * Custom S3 exponential backoff checking use to retry 400 responses containing the following reason phrase:
28
+ * "Your socket connection to the server was not read from or written to within the timeout period.".
29
+ * This error has been reported as intermittent/random, and in most cases, seems to occur during the middle of a
30
+ * transfer. This plugin will attempt to retry these failed requests, and if using a local file, will clear the
31
+ * stat cache of the file and set a new content-length header on the upload.
32
+ */
33
+ class SocketTimeoutChecker extends AbstractBackoffStrategy
34
+ {
35
+ const ERR = 'Your socket connection to the server was not read from or written to within the timeout period';
36
+
37
+ /**
38
+ * {@inheridoc}
39
+ */
40
+ public function __construct(BackoffStrategyInterface $next = null)
41
+ {
42
+ if ($next) {
43
+ $this->setNext($next);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * {@inheridoc}
49
+ */
50
+ public function makesDecision()
51
+ {
52
+ return true;
53
+ }
54
+
55
+ /**
56
+ * {@inheritdoc}
57
+ */
58
+ protected function getDelay(
59
+ $retries,
60
+ RequestInterface $request,
61
+ Response $response = null,
62
+ HttpException $e = null
63
+ ) {
64
+ if ($response
65
+ && $response->getStatusCode() == 400
66
+ && strpos($response->getBody(), self::ERR)
67
+ ) {
68
+ return true;
69
+ }
70
+ }
71
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/SseCpkListener.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Aws\S3;
4
+
5
+ use Aws\Common\Exception\RuntimeException;
6
+ use Guzzle\Common\Event;
7
+ use Guzzle\Service\Command\CommandInterface;
8
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
+
10
+ /**
11
+ * This listener simplifies the SSE-C process by encoding and hashing the key.
12
+ */
13
+ class SseCpkListener implements EventSubscriberInterface
14
+ {
15
+ public static function getSubscribedEvents()
16
+ {
17
+ return array('command.before_prepare' => 'onCommandBeforePrepare');
18
+ }
19
+
20
+ public function onCommandBeforePrepare(Event $event)
21
+ {
22
+ /** @var CommandInterface $command */
23
+ $command = $event['command'];
24
+
25
+ // Allows only HTTPS connections when using SSE-C
26
+ if ($command['SSECustomerKey'] ||
27
+ $command['CopySourceSSECustomerKey']
28
+ ) {
29
+ $this->validateScheme($command);
30
+ }
31
+
32
+ // Prepare the normal SSE-CPK headers
33
+ if ($command['SSECustomerKey']) {
34
+ $this->prepareSseParams($command);
35
+ }
36
+
37
+ // If it's a copy operation, prepare the SSE-CPK headers for the source.
38
+ if ($command['CopySourceSSECustomerKey']) {
39
+ $this->prepareSseParams($command, true);
40
+ }
41
+ }
42
+
43
+ private function validateScheme(CommandInterface $command)
44
+ {
45
+ if ($command->getClient()->getConfig('scheme') !== 'https') {
46
+ throw new RuntimeException('You must configure your S3 client to '
47
+ . 'use HTTPS in order to use the SSE-C features.');
48
+ }
49
+ }
50
+
51
+ private function prepareSseParams(
52
+ CommandInterface $command,
53
+ $isCopy = false
54
+ ) {
55
+ $prefix = $isCopy ? 'CopySource' : '';
56
+
57
+ // Base64 encode the provided key
58
+ $key = $command[$prefix . 'SSECustomerKey'];
59
+ $command[$prefix . 'SSECustomerKey'] = base64_encode($key);
60
+
61
+ // Base64 the provided MD5 or, generate an MD5 if not provided
62
+ if ($md5 = $command[$prefix . 'SSECustomerKeyMD5']) {
63
+ $command[$prefix . 'SSECustomerKeyMD5'] = base64_encode($md5);
64
+ } else {
65
+ $command[$prefix . 'SSECustomerKeyMD5'] = base64_encode(md5($key, true));
66
+ }
67
+ }
68
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/StreamWrapper.php ADDED
@@ -0,0 +1,892 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Aws\S3\Exception\S3Exception;
21
+ use Aws\S3\Exception\NoSuchKeyException;
22
+ use Aws\S3\Iterator\ListObjectsIterator;
23
+ use Guzzle\Http\EntityBody;
24
+ use Guzzle\Http\CachingEntityBody;
25
+ use Guzzle\Http\Mimetypes;
26
+ use Guzzle\Iterator\FilterIterator;
27
+ use Guzzle\Stream\PhpStreamRequestFactory;
28
+ use Guzzle\Service\Command\CommandInterface;
29
+
30
+ /**
31
+ * Amazon S3 stream wrapper to use "s3://<bucket>/<key>" files with PHP streams, supporting "r", "w", "a", "x".
32
+ *
33
+ * # Supported stream related PHP functions:
34
+ * - fopen, fclose, fread, fwrite, fseek, ftell, feof, fflush
35
+ * - opendir, closedir, readdir, rewinddir
36
+ * - copy, rename, unlink
37
+ * - mkdir, rmdir, rmdir (recursive)
38
+ * - file_get_contents, file_put_contents
39
+ * - file_exists, filesize, is_file, is_dir
40
+ *
41
+ * # Opening "r" (read only) streams:
42
+ *
43
+ * Read only streams are truly streaming by default and will not allow you to seek. This is because data
44
+ * read from the stream is not kept in memory or on the local filesystem. You can force a "r" stream to be seekable
45
+ * by setting the "seekable" stream context option true. This will allow true streaming of data from Amazon S3, but
46
+ * will maintain a buffer of previously read bytes in a 'php://temp' stream to allow seeking to previously read bytes
47
+ * from the stream.
48
+ *
49
+ * You may pass any GetObject parameters as 's3' stream context options. These options will affect how the data is
50
+ * downloaded from Amazon S3.
51
+ *
52
+ * # Opening "w" and "x" (write only) streams:
53
+ *
54
+ * Because Amazon S3 requires a Content-Length header, write only streams will maintain a 'php://temp' stream to buffer
55
+ * data written to the stream until the stream is flushed (usually by closing the stream with fclose).
56
+ *
57
+ * You may pass any PutObject parameters as 's3' stream context options. These options will affect how the data is
58
+ * uploaded to Amazon S3.
59
+ *
60
+ * When opening an "x" stream, the file must exist on Amazon S3 for the stream to open successfully.
61
+ *
62
+ * # Opening "a" (write only append) streams:
63
+ *
64
+ * Similar to "w" streams, opening append streams requires that the data be buffered in a "php://temp" stream. Append
65
+ * streams will attempt to download the contents of an object in Amazon S3, seek to the end of the object, then allow
66
+ * you to append to the contents of the object. The data will then be uploaded using a PutObject operation when the
67
+ * stream is flushed (usually with fclose).
68
+ *
69
+ * You may pass any GetObject and/or PutObject parameters as 's3' stream context options. These options will affect how
70
+ * the data is downloaded and uploaded from Amazon S3.
71
+ *
72
+ * Stream context options:
73
+ *
74
+ * - "seekable": Set to true to create a seekable "r" (read only) stream by using a php://temp stream buffer
75
+ * - For "unlink" only: Any option that can be passed to the DeleteObject operation
76
+ */
77
+ class StreamWrapper
78
+ {
79
+ /**
80
+ * @var resource|null Stream context (this is set by PHP when a context is used)
81
+ */
82
+ public $context;
83
+
84
+ /**
85
+ * @var S3Client Client used to send requests
86
+ */
87
+ protected static $client;
88
+
89
+ /**
90
+ * @var string Mode the stream was opened with
91
+ */
92
+ protected $mode;
93
+
94
+ /**
95
+ * @var EntityBody Underlying stream resource
96
+ */
97
+ protected $body;
98
+
99
+ /**
100
+ * @var array Current parameters to use with the flush operation
101
+ */
102
+ protected $params;
103
+
104
+ /**
105
+ * @var ListObjectsIterator Iterator used with opendir() and subsequent readdir() calls
106
+ */
107
+ protected $objectIterator;
108
+
109
+ /**
110
+ * @var string The bucket that was opened when opendir() was called
111
+ */
112
+ protected $openedBucket;
113
+
114
+ /**
115
+ * @var string The prefix of the bucket that was opened with opendir()
116
+ */
117
+ protected $openedBucketPrefix;
118
+
119
+ /**
120
+ * @var array The next key to retrieve when using a directory iterator. Helps for fast directory traversal.
121
+ */
122
+ protected static $nextStat = array();
123
+
124
+ /**
125
+ * Register the 's3://' stream wrapper
126
+ *
127
+ * @param S3Client $client Client to use with the stream wrapper
128
+ */
129
+ public static function register(S3Client $client)
130
+ {
131
+ if (in_array('s3', stream_get_wrappers())) {
132
+ stream_wrapper_unregister('s3');
133
+ }
134
+
135
+ stream_wrapper_register('s3', get_called_class(), STREAM_IS_URL);
136
+ static::$client = $client;
137
+ }
138
+
139
+ /**
140
+ * Close the stream
141
+ */
142
+ public function stream_close()
143
+ {
144
+ $this->body = null;
145
+ }
146
+
147
+ /**
148
+ * @param string $path
149
+ * @param string $mode
150
+ * @param int $options
151
+ * @param string $opened_path
152
+ *
153
+ * @return bool
154
+ */
155
+ public function stream_open($path, $mode, $options, &$opened_path)
156
+ {
157
+ // We don't care about the binary flag
158
+ $this->mode = $mode = rtrim($mode, 'bt');
159
+ $this->params = $params = $this->getParams($path);
160
+ $errors = array();
161
+
162
+ if (!$params['Key']) {
163
+ $errors[] = 'Cannot open a bucket. You must specify a path in the form of s3://bucket/key';
164
+ }
165
+
166
+ if (strpos($mode, '+')) {
167
+ $errors[] = 'The Amazon S3 stream wrapper does not allow simultaneous reading and writing.';
168
+ }
169
+
170
+ if (!in_array($mode, array('r', 'w', 'a', 'x'))) {
171
+ $errors[] = "Mode not supported: {$mode}. Use one 'r', 'w', 'a', or 'x'.";
172
+ }
173
+
174
+ // When using mode "x" validate if the file exists before attempting to read
175
+ if ($mode == 'x' && static::$client->doesObjectExist($params['Bucket'], $params['Key'], $this->getOptions())) {
176
+ $errors[] = "{$path} already exists on Amazon S3";
177
+ }
178
+
179
+ if (!$errors) {
180
+ if ($mode == 'r') {
181
+ $this->openReadStream($params, $errors);
182
+ } elseif ($mode == 'a') {
183
+ $this->openAppendStream($params, $errors);
184
+ } else {
185
+ $this->openWriteStream($params, $errors);
186
+ }
187
+ }
188
+
189
+ return $errors ? $this->triggerError($errors) : true;
190
+ }
191
+
192
+ /**
193
+ * @return bool
194
+ */
195
+ public function stream_eof()
196
+ {
197
+ return $this->body->feof();
198
+ }
199
+
200
+ /**
201
+ * @return bool
202
+ */
203
+ public function stream_flush()
204
+ {
205
+ if ($this->mode == 'r') {
206
+ return false;
207
+ }
208
+
209
+ $this->body->rewind();
210
+ $params = $this->params;
211
+ $params['Body'] = $this->body;
212
+
213
+ // Attempt to guess the ContentType of the upload based on the
214
+ // file extension of the key
215
+ if (!isset($params['ContentType']) &&
216
+ ($type = Mimetypes::getInstance()->fromFilename($params['Key']))
217
+ ) {
218
+ $params['ContentType'] = $type;
219
+ }
220
+
221
+ try {
222
+ static::$client->putObject($params);
223
+ return true;
224
+ } catch (\Exception $e) {
225
+ return $this->triggerError($e->getMessage());
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Read data from the underlying stream
231
+ *
232
+ * @param int $count Amount of bytes to read
233
+ *
234
+ * @return string
235
+ */
236
+ public function stream_read($count)
237
+ {
238
+ return $this->body->read($count);
239
+ }
240
+
241
+ /**
242
+ * Seek to a specific byte in the stream
243
+ *
244
+ * @param int $offset Seek offset
245
+ * @param int $whence Whence (SEEK_SET, SEEK_CUR, SEEK_END)
246
+ *
247
+ * @return bool
248
+ */
249
+ public function stream_seek($offset, $whence = SEEK_SET)
250
+ {
251
+ return $this->body->seek($offset, $whence);
252
+ }
253
+
254
+ /**
255
+ * Get the current position of the stream
256
+ *
257
+ * @return int Returns the current position in the stream
258
+ */
259
+ public function stream_tell()
260
+ {
261
+ return $this->body->ftell();
262
+ }
263
+
264
+ /**
265
+ * Write data the to the stream
266
+ *
267
+ * @param string $data
268
+ *
269
+ * @return int Returns the number of bytes written to the stream
270
+ */
271
+ public function stream_write($data)
272
+ {
273
+ return $this->body->write($data);
274
+ }
275
+
276
+ /**
277
+ * Delete a specific object
278
+ *
279
+ * @param string $path
280
+ * @return bool
281
+ */
282
+ public function unlink($path)
283
+ {
284
+ try {
285
+ $this->clearStatInfo($path);
286
+ static::$client->deleteObject($this->getParams($path));
287
+ return true;
288
+ } catch (\Exception $e) {
289
+ return $this->triggerError($e->getMessage());
290
+ }
291
+ }
292
+
293
+ /**
294
+ * @return array
295
+ */
296
+ public function stream_stat()
297
+ {
298
+ $stat = fstat($this->body->getStream());
299
+ // Add the size of the underlying stream if it is known
300
+ if ($this->mode == 'r' && $this->body->getSize()) {
301
+ $stat[7] = $stat['size'] = $this->body->getSize();
302
+ }
303
+
304
+ return $stat;
305
+ }
306
+
307
+ /**
308
+ * Provides information for is_dir, is_file, filesize, etc. Works on buckets, keys, and prefixes
309
+ *
310
+ * @param string $path
311
+ * @param int $flags
312
+ *
313
+ * @return array Returns an array of stat data
314
+ * @link http://www.php.net/manual/en/streamwrapper.url-stat.php
315
+ */
316
+ public function url_stat($path, $flags)
317
+ {
318
+ // Check if this path is in the url_stat cache
319
+ if (isset(static::$nextStat[$path])) {
320
+ return static::$nextStat[$path];
321
+ }
322
+
323
+ $parts = $this->getParams($path);
324
+
325
+ if (!$parts['Key']) {
326
+ // Stat "directories": buckets, or "s3://"
327
+ if (!$parts['Bucket'] || static::$client->doesBucketExist($parts['Bucket'])) {
328
+ return $this->formatUrlStat($path);
329
+ } else {
330
+ return $this->triggerError("File or directory not found: {$path}", $flags);
331
+ }
332
+ }
333
+
334
+ try {
335
+ try {
336
+ $result = static::$client->headObject($parts)->toArray();
337
+ if (substr($parts['Key'], -1, 1) == '/' && $result['ContentLength'] == 0) {
338
+ // Return as if it is a bucket to account for console bucket objects (e.g., zero-byte object "foo/")
339
+ return $this->formatUrlStat($path);
340
+ } else {
341
+ // Attempt to stat and cache regular object
342
+ return $this->formatUrlStat($result);
343
+ }
344
+ } catch (NoSuchKeyException $e) {
345
+ // Maybe this isn't an actual key, but a prefix. Do a prefix listing of objects to determine.
346
+ $result = static::$client->listObjects(array(
347
+ 'Bucket' => $parts['Bucket'],
348
+ 'Prefix' => rtrim($parts['Key'], '/') . '/',
349
+ 'MaxKeys' => 1
350
+ ));
351
+ if (!$result['Contents'] && !$result['CommonPrefixes']) {
352
+ return $this->triggerError("File or directory not found: {$path}", $flags);
353
+ }
354
+ // This is a directory prefix
355
+ return $this->formatUrlStat($path);
356
+ }
357
+ } catch (\Exception $e) {
358
+ return $this->triggerError($e->getMessage(), $flags);
359
+ }
360
+ }
361
+
362
+ /**
363
+ * Support for mkdir().
364
+ *
365
+ * @param string $path Directory which should be created.
366
+ * @param int $mode Permissions. 700-range permissions map to ACL_PUBLIC. 600-range permissions map to
367
+ * ACL_AUTH_READ. All other permissions map to ACL_PRIVATE. Expects octal form.
368
+ * @param int $options A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE.
369
+ *
370
+ * @return bool
371
+ * @link http://www.php.net/manual/en/streamwrapper.mkdir.php
372
+ */
373
+ public function mkdir($path, $mode, $options)
374
+ {
375
+ $params = $this->getParams($path);
376
+ if (!$params['Bucket']) {
377
+ return false;
378
+ }
379
+
380
+ if (!isset($params['ACL'])) {
381
+ $params['ACL'] = $this->determineAcl($mode);
382
+ }
383
+
384
+ return !isset($params['Key']) || $params['Key'] === '/'
385
+ ? $this->createBucket($path, $params)
386
+ : $this->createPseudoDirectory($path, $params);
387
+ }
388
+
389
+ /**
390
+ * Remove a bucket from Amazon S3
391
+ *
392
+ * @param string $path the directory path
393
+ * @param int $options A bitwise mask of values
394
+ *
395
+ * @return bool true if directory was successfully removed
396
+ * @link http://www.php.net/manual/en/streamwrapper.rmdir.php
397
+ */
398
+ public function rmdir($path, $options)
399
+ {
400
+ $params = $this->getParams($path);
401
+ if (!$params['Bucket']) {
402
+ return $this->triggerError('You cannot delete s3://. Please specify a bucket.');
403
+ }
404
+
405
+ try {
406
+
407
+ if (!$params['Key']) {
408
+ static::$client->deleteBucket(array('Bucket' => $params['Bucket']));
409
+ $this->clearStatInfo($path);
410
+ return true;
411
+ }
412
+
413
+ // Use a key that adds a trailing slash if needed.
414
+ $prefix = rtrim($params['Key'], '/') . '/';
415
+
416
+ $result = static::$client->listObjects(array(
417
+ 'Bucket' => $params['Bucket'],
418
+ 'Prefix' => $prefix,
419
+ 'MaxKeys' => 1
420
+ ));
421
+
422
+ // Check if the bucket contains keys other than the placeholder
423
+ if ($result['Contents']) {
424
+ foreach ($result['Contents'] as $key) {
425
+ if ($key['Key'] == $prefix) {
426
+ continue;
427
+ }
428
+ return $this->triggerError('Psuedo folder is not empty');
429
+ }
430
+ return $this->unlink(rtrim($path, '/') . '/');
431
+ }
432
+
433
+ return $result['CommonPrefixes']
434
+ ? $this->triggerError('Pseudo folder contains nested folders')
435
+ : true;
436
+
437
+ } catch (\Exception $e) {
438
+ return $this->triggerError($e->getMessage());
439
+ }
440
+ }
441
+
442
+ /**
443
+ * Support for opendir().
444
+ *
445
+ * The opendir() method of the Amazon S3 stream wrapper supports a stream
446
+ * context option of "listFilter". listFilter must be a callable that
447
+ * accepts an associative array of object data and returns true if the
448
+ * object should be yielded when iterating the keys in a bucket.
449
+ *
450
+ * @param string $path The path to the directory (e.g. "s3://dir[</prefix>]")
451
+ * @param string $options Whether or not to enforce safe_mode (0x04). Unused.
452
+ *
453
+ * @return bool true on success
454
+ * @see http://www.php.net/manual/en/function.opendir.php
455
+ */
456
+ public function dir_opendir($path, $options)
457
+ {
458
+ // Reset the cache
459
+ $this->clearStatInfo();
460
+ $params = $this->getParams($path);
461
+ $delimiter = $this->getOption('delimiter');
462
+ $filterFn = $this->getOption('listFilter');
463
+
464
+ if ($delimiter === null) {
465
+ $delimiter = '/';
466
+ }
467
+
468
+ if ($params['Key']) {
469
+ $params['Key'] = rtrim($params['Key'], $delimiter) . $delimiter;
470
+ }
471
+
472
+ $this->openedBucket = $params['Bucket'];
473
+ $this->openedBucketPrefix = $params['Key'];
474
+ $operationParams = array('Bucket' => $params['Bucket'], 'Prefix' => $params['Key']);
475
+
476
+ if ($delimiter) {
477
+ $operationParams['Delimiter'] = $delimiter;
478
+ }
479
+
480
+ $objectIterator = static::$client->getIterator('ListObjects', $operationParams, array(
481
+ 'return_prefixes' => true,
482
+ 'sort_results' => true
483
+ ));
484
+
485
+ // Filter our "/" keys added by the console as directories, and ensure
486
+ // that if a filter function is provided that it passes the filter.
487
+ $this->objectIterator = new FilterIterator(
488
+ $objectIterator,
489
+ function ($key) use ($filterFn) {
490
+ // Each yielded results can contain a "Key" or "Prefix"
491
+ return (!$filterFn || call_user_func($filterFn, $key)) &&
492
+ (!isset($key['Key']) || substr($key['Key'], -1, 1) !== '/');
493
+ }
494
+ );
495
+
496
+ $this->objectIterator->next();
497
+
498
+ return true;
499
+ }
500
+
501
+ /**
502
+ * Close the directory listing handles
503
+ *
504
+ * @return bool true on success
505
+ */
506
+ public function dir_closedir()
507
+ {
508
+ $this->objectIterator = null;
509
+
510
+ return true;
511
+ }
512
+
513
+ /**
514
+ * This method is called in response to rewinddir()
515
+ *
516
+ * @return boolean true on success
517
+ */
518
+ public function dir_rewinddir()
519
+ {
520
+ $this->clearStatInfo();
521
+ $this->objectIterator->rewind();
522
+
523
+ return true;
524
+ }
525
+
526
+ /**
527
+ * This method is called in response to readdir()
528
+ *
529
+ * @return string Should return a string representing the next filename, or false if there is no next file.
530
+ *
531
+ * @link http://www.php.net/manual/en/function.readdir.php
532
+ */
533
+ public function dir_readdir()
534
+ {
535
+ // Skip empty result keys
536
+ if (!$this->objectIterator->valid()) {
537
+ return false;
538
+ }
539
+
540
+ $current = $this->objectIterator->current();
541
+ if (isset($current['Prefix'])) {
542
+ // Include "directories". Be sure to strip a trailing "/"
543
+ // on prefixes.
544
+ $prefix = rtrim($current['Prefix'], '/');
545
+ $result = str_replace($this->openedBucketPrefix, '', $prefix);
546
+ $key = "s3://{$this->openedBucket}/{$prefix}";
547
+ $stat = $this->formatUrlStat($prefix);
548
+ } else {
549
+ // Remove the prefix from the result to emulate other
550
+ // stream wrappers.
551
+ $result = str_replace($this->openedBucketPrefix, '', $current['Key']);
552
+ $key = "s3://{$this->openedBucket}/{$current['Key']}";
553
+ $stat = $this->formatUrlStat($current);
554
+ }
555
+
556
+ // Cache the object data for quick url_stat lookups used with
557
+ // RecursiveDirectoryIterator.
558
+ static::$nextStat = array($key => $stat);
559
+ $this->objectIterator->next();
560
+
561
+ return $result;
562
+ }
563
+
564
+ /**
565
+ * Called in response to rename() to rename a file or directory. Currently only supports renaming objects.
566
+ *
567
+ * @param string $path_from the path to the file to rename
568
+ * @param string $path_to the new path to the file
569
+ *
570
+ * @return bool true if file was successfully renamed
571
+ * @link http://www.php.net/manual/en/function.rename.php
572
+ */
573
+ public function rename($path_from, $path_to)
574
+ {
575
+ $partsFrom = $this->getParams($path_from);
576
+ $partsTo = $this->getParams($path_to);
577
+ $this->clearStatInfo($path_from);
578
+ $this->clearStatInfo($path_to);
579
+
580
+ if (!$partsFrom['Key'] || !$partsTo['Key']) {
581
+ return $this->triggerError('The Amazon S3 stream wrapper only supports copying objects');
582
+ }
583
+
584
+ try {
585
+ // Copy the object and allow overriding default parameters if desired, but by default copy metadata
586
+ static::$client->copyObject($this->getOptions() + array(
587
+ 'Bucket' => $partsTo['Bucket'],
588
+ 'Key' => $partsTo['Key'],
589
+ 'CopySource' => '/' . $partsFrom['Bucket'] . '/' . rawurlencode($partsFrom['Key']),
590
+ 'MetadataDirective' => 'COPY'
591
+ ));
592
+ // Delete the original object
593
+ static::$client->deleteObject(array(
594
+ 'Bucket' => $partsFrom['Bucket'],
595
+ 'Key' => $partsFrom['Key']
596
+ ) + $this->getOptions());
597
+ } catch (\Exception $e) {
598
+ return $this->triggerError($e->getMessage());
599
+ }
600
+
601
+ return true;
602
+ }
603
+
604
+ /**
605
+ * Cast the stream to return the underlying file resource
606
+ *
607
+ * @param int $cast_as STREAM_CAST_FOR_SELECT or STREAM_CAST_AS_STREAM
608
+ *
609
+ * @return resource
610
+ */
611
+ public function stream_cast($cast_as)
612
+ {
613
+ return $this->body->getStream();
614
+ }
615
+
616
+ /**
617
+ * Get the stream context options available to the current stream
618
+ *
619
+ * @return array
620
+ */
621
+ protected function getOptions()
622
+ {
623
+ $context = $this->context ?: stream_context_get_default();
624
+ $options = stream_context_get_options($context);
625
+
626
+ return isset($options['s3']) ? $options['s3'] : array();
627
+ }
628
+
629
+ /**
630
+ * Get a specific stream context option
631
+ *
632
+ * @param string $name Name of the option to retrieve
633
+ *
634
+ * @return mixed|null
635
+ */
636
+ protected function getOption($name)
637
+ {
638
+ $options = $this->getOptions();
639
+
640
+ return isset($options[$name]) ? $options[$name] : null;
641
+ }
642
+
643
+ /**
644
+ * Get the bucket and key from the passed path (e.g. s3://bucket/key)
645
+ *
646
+ * @param string $path Path passed to the stream wrapper
647
+ *
648
+ * @return array Hash of 'Bucket', 'Key', and custom params
649
+ */
650
+ protected function getParams($path)
651
+ {
652
+ $parts = explode('/', substr($path, 5), 2);
653
+
654
+ $params = $this->getOptions();
655
+ unset($params['seekable']);
656
+
657
+ return array(
658
+ 'Bucket' => $parts[0],
659
+ 'Key' => isset($parts[1]) ? $parts[1] : null
660
+ ) + $params;
661
+ }
662
+
663
+ /**
664
+ * Serialize and sign a command, returning a request object
665
+ *
666
+ * @param CommandInterface $command Command to sign
667
+ *
668
+ * @return RequestInterface
669
+ */
670
+ protected function getSignedRequest($command)
671
+ {
672
+ $request = $command->prepare();
673
+ $request->dispatch('request.before_send', array('request' => $request));
674
+
675
+ return $request;
676
+ }
677
+
678
+ /**
679
+ * Initialize the stream wrapper for a read only stream
680
+ *
681
+ * @param array $params Operation parameters
682
+ * @param array $errors Any encountered errors to append to
683
+ *
684
+ * @return bool
685
+ */
686
+ protected function openReadStream(array $params, array &$errors)
687
+ {
688
+ // Create the command and serialize the request
689
+ $request = $this->getSignedRequest(static::$client->getCommand('GetObject', $params));
690
+ // Create a stream that uses the EntityBody object
691
+ $factory = $this->getOption('stream_factory') ?: new PhpStreamRequestFactory();
692
+ $this->body = $factory->fromRequest($request, array(), array('stream_class' => 'Guzzle\Http\EntityBody'));
693
+
694
+ // Wrap the body in a caching entity body if seeking is allowed
695
+ if ($this->getOption('seekable')) {
696
+ $this->body = new CachingEntityBody($this->body);
697
+ }
698
+
699
+ return true;
700
+ }
701
+
702
+ /**
703
+ * Initialize the stream wrapper for a write only stream
704
+ *
705
+ * @param array $params Operation parameters
706
+ * @param array $errors Any encountered errors to append to
707
+ *
708
+ * @return bool
709
+ */
710
+ protected function openWriteStream(array $params, array &$errors)
711
+ {
712
+ $this->body = new EntityBody(fopen('php://temp', 'r+'));
713
+ }
714
+
715
+ /**
716
+ * Initialize the stream wrapper for an append stream
717
+ *
718
+ * @param array $params Operation parameters
719
+ * @param array $errors Any encountered errors to append to
720
+ *
721
+ * @return bool
722
+ */
723
+ protected function openAppendStream(array $params, array &$errors)
724
+ {
725
+ try {
726
+ // Get the body of the object
727
+ $this->body = static::$client->getObject($params)->get('Body');
728
+ $this->body->seek(0, SEEK_END);
729
+ } catch (S3Exception $e) {
730
+ // The object does not exist, so use a simple write stream
731
+ $this->openWriteStream($params, $errors);
732
+ }
733
+
734
+ return true;
735
+ }
736
+
737
+ /**
738
+ * Trigger one or more errors
739
+ *
740
+ * @param string|array $errors Errors to trigger
741
+ * @param mixed $flags If set to STREAM_URL_STAT_QUIET, then no error or exception occurs
742
+ *
743
+ * @return bool Returns false
744
+ * @throws RuntimeException if throw_errors is true
745
+ */
746
+ protected function triggerError($errors, $flags = null)
747
+ {
748
+ if ($flags & STREAM_URL_STAT_QUIET) {
749
+ // This is triggered with things like file_exists()
750
+
751
+ if ($flags & STREAM_URL_STAT_LINK) {
752
+ // This is triggered for things like is_link()
753
+ return $this->formatUrlStat(false);
754
+ }
755
+ return false;
756
+ }
757
+
758
+ // This is triggered when doing things like lstat() or stat()
759
+ trigger_error(implode("\n", (array) $errors), E_USER_WARNING);
760
+
761
+ return false;
762
+ }
763
+
764
+ /**
765
+ * Prepare a url_stat result array
766
+ *
767
+ * @param string|array $result Data to add
768
+ *
769
+ * @return array Returns the modified url_stat result
770
+ */
771
+ protected function formatUrlStat($result = null)
772
+ {
773
+ static $statTemplate = array(
774
+ 0 => 0, 'dev' => 0,
775
+ 1 => 0, 'ino' => 0,
776
+ 2 => 0, 'mode' => 0,
777
+ 3 => 0, 'nlink' => 0,
778
+ 4 => 0, 'uid' => 0,
779
+ 5 => 0, 'gid' => 0,
780
+ 6 => -1, 'rdev' => -1,
781
+ 7 => 0, 'size' => 0,
782
+ 8 => 0, 'atime' => 0,
783
+ 9 => 0, 'mtime' => 0,
784
+ 10 => 0, 'ctime' => 0,
785
+ 11 => -1, 'blksize' => -1,
786
+ 12 => -1, 'blocks' => -1,
787
+ );
788
+
789
+ $stat = $statTemplate;
790
+ $type = gettype($result);
791
+
792
+ // Determine what type of data is being cached
793
+ if ($type == 'NULL' || $type == 'string') {
794
+ // Directory with 0777 access - see "man 2 stat".
795
+ $stat['mode'] = $stat[2] = 0040777;
796
+ } elseif ($type == 'array' && isset($result['LastModified'])) {
797
+ // ListObjects or HeadObject result
798
+ $stat['mtime'] = $stat[9] = $stat['ctime'] = $stat[10] = strtotime($result['LastModified']);
799
+ $stat['size'] = $stat[7] = (isset($result['ContentLength']) ? $result['ContentLength'] : $result['Size']);
800
+ // Regular file with 0777 access - see "man 2 stat".
801
+ $stat['mode'] = $stat[2] = 0100777;
802
+ }
803
+
804
+ return $stat;
805
+ }
806
+
807
+ /**
808
+ * Clear the next stat result from the cache
809
+ *
810
+ * @param string $path If a path is specific, clearstatcache() will be called
811
+ */
812
+ protected function clearStatInfo($path = null)
813
+ {
814
+ static::$nextStat = array();
815
+ if ($path) {
816
+ clearstatcache(true, $path);
817
+ }
818
+ }
819
+
820
+ /**
821
+ * Creates a bucket for the given parameters.
822
+ *
823
+ * @param string $path Stream wrapper path
824
+ * @param array $params A result of StreamWrapper::getParams()
825
+ *
826
+ * @return bool Returns true on success or false on failure
827
+ */
828
+ private function createBucket($path, array $params)
829
+ {
830
+ if (static::$client->doesBucketExist($params['Bucket'])) {
831
+ return $this->triggerError("Directory already exists: {$path}");
832
+ }
833
+
834
+ try {
835
+ static::$client->createBucket($params);
836
+ $this->clearStatInfo($path);
837
+ return true;
838
+ } catch (\Exception $e) {
839
+ return $this->triggerError($e->getMessage());
840
+ }
841
+ }
842
+
843
+ /**
844
+ * Creates a pseudo-folder by creating an empty "/" suffixed key
845
+ *
846
+ * @param string $path Stream wrapper path
847
+ * @param array $params A result of StreamWrapper::getParams()
848
+ *
849
+ * @return bool
850
+ */
851
+ private function createPseudoDirectory($path, array $params)
852
+ {
853
+ // Ensure the path ends in "/" and the body is empty.
854
+ $params['Key'] = rtrim($params['Key'], '/') . '/';
855
+ $params['Body'] = '';
856
+
857
+ // Fail if this pseudo directory key already exists
858
+ if (static::$client->doesObjectExist($params['Bucket'], $params['Key'])) {
859
+ return $this->triggerError("Directory already exists: {$path}");
860
+ }
861
+
862
+ try {
863
+ static::$client->putObject($params);
864
+ $this->clearStatInfo($path);
865
+ return true;
866
+ } catch (\Exception $e) {
867
+ return $this->triggerError($e->getMessage());
868
+ }
869
+ }
870
+
871
+ /**
872
+ * Determine the most appropriate ACL based on a file mode.
873
+ *
874
+ * @param int $mode File mode
875
+ *
876
+ * @return string
877
+ */
878
+ private function determineAcl($mode)
879
+ {
880
+ $mode = decoct($mode);
881
+
882
+ if ($mode >= 700 && $mode <= 799) {
883
+ return 'public-read';
884
+ }
885
+
886
+ if ($mode >= 600 && $mode <= 699) {
887
+ return 'authenticated-read';
888
+ }
889
+
890
+ return 'private';
891
+ }
892
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/AbstractSync.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ use Aws\S3\S3Client;
20
+ use Guzzle\Common\AbstractHasDispatcher;
21
+ use Guzzle\Common\Collection;
22
+ use Guzzle\Iterator\ChunkedIterator;
23
+ use Guzzle\Service\Command\CommandInterface;
24
+
25
+ abstract class AbstractSync extends AbstractHasDispatcher
26
+ {
27
+ const BEFORE_TRANSFER = 's3.sync.before_transfer';
28
+ const AFTER_TRANSFER = 's3.sync.after_transfer';
29
+
30
+ /** @var Collection */
31
+ protected $options;
32
+
33
+ /**
34
+ * @param array $options Associative array of options:
35
+ * - client: (S3Client) used to transfer requests
36
+ * - bucket: (string) Amazon S3 bucket
37
+ * - iterator: (\Iterator) Iterator that yields SplFileInfo objects to transfer
38
+ * - source_converter: (FilenameConverterInterface) Converter used to convert filenames
39
+ * - *: Any other options required by subclasses
40
+ */
41
+ public function __construct(array $options)
42
+ {
43
+ $this->options = Collection::fromConfig(
44
+ $options,
45
+ array('concurrency' => 10),
46
+ array('client', 'bucket', 'iterator', 'source_converter')
47
+ );
48
+ $this->init();
49
+ }
50
+
51
+ public static function getAllEvents()
52
+ {
53
+ return array(self::BEFORE_TRANSFER, self::AFTER_TRANSFER);
54
+ }
55
+
56
+ /**
57
+ * Begin transferring files
58
+ */
59
+ public function transfer()
60
+ {
61
+ // Pull out chunks of uploads to upload in parallel
62
+ $iterator = new ChunkedIterator($this->options['iterator'], $this->options['concurrency']);
63
+ foreach ($iterator as $files) {
64
+ $this->transferFiles($files);
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Create a command or special transfer action for the
70
+ *
71
+ * @param \SplFileInfo $file File used to build the transfer
72
+ *
73
+ * @return CommandInterface|callable
74
+ */
75
+ abstract protected function createTransferAction(\SplFileInfo $file);
76
+
77
+ /**
78
+ * Hook to initialize subclasses
79
+ * @codeCoverageIgnore
80
+ */
81
+ protected function init() {}
82
+
83
+ /**
84
+ * Process and transfer a group of files
85
+ *
86
+ * @param array $files Files to transfer
87
+ */
88
+ protected function transferFiles(array $files)
89
+ {
90
+ // Create the base event data object
91
+ $event = array('sync' => $this, 'client' => $this->options['client']);
92
+
93
+ $commands = array();
94
+ foreach ($files as $file) {
95
+ if ($action = $this->createTransferAction($file)) {
96
+ $event = array('command' => $action, 'file' => $file) + $event;
97
+ $this->dispatch(self::BEFORE_TRANSFER, $event);
98
+ if ($action instanceof CommandInterface) {
99
+ $commands[] = $action;
100
+ } elseif (is_callable($action)) {
101
+ $action();
102
+ $this->dispatch(self::AFTER_TRANSFER, $event);
103
+ }
104
+ }
105
+ }
106
+
107
+ $this->transferCommands($commands);
108
+ }
109
+
110
+ /**
111
+ * Transfer an array of commands in parallel
112
+ *
113
+ * @param array $commands Commands to transfer
114
+ */
115
+ protected function transferCommands(array $commands)
116
+ {
117
+ if ($commands) {
118
+ $this->options['client']->execute($commands);
119
+ // Notify listeners that each command finished
120
+ $event = array('sync' => $this, 'client' => $this->options['client']);
121
+ foreach ($commands as $command) {
122
+ $event['command'] = $command;
123
+ $this->dispatch(self::AFTER_TRANSFER, $event);
124
+ }
125
+ }
126
+ }
127
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/AbstractSyncBuilder.php ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Aws\Common\Exception\UnexpectedValueException;
21
+ use Aws\Common\Model\MultipartUpload\TransferInterface;
22
+ use Aws\S3\S3Client;
23
+ use Aws\S3\Iterator\OpendirIterator;
24
+ use Guzzle\Common\Event;
25
+ use Guzzle\Common\HasDispatcherInterface;
26
+ use Guzzle\Iterator\FilterIterator;
27
+ use Guzzle\Service\Command\CommandInterface;
28
+
29
+ abstract class AbstractSyncBuilder
30
+ {
31
+ /** @var \Iterator Iterator that returns SplFileInfo objects to upload */
32
+ protected $sourceIterator;
33
+
34
+ /** @var S3Client Amazon S3 client used to send requests */
35
+ protected $client;
36
+
37
+ /** @var string Bucket used with the transfer */
38
+ protected $bucket;
39
+
40
+ /** @var int Number of files that can be transferred concurrently */
41
+ protected $concurrency = 10;
42
+
43
+ /** @var array Custom parameters to add to each operation sent while transferring */
44
+ protected $params = array();
45
+
46
+ /** @var FilenameConverterInterface */
47
+ protected $sourceConverter;
48
+
49
+ /** @var FilenameConverterInterface */
50
+ protected $targetConverter;
51
+
52
+ /** @var string Prefix at prepend to each Amazon S3 object key */
53
+ protected $keyPrefix = '';
54
+
55
+ /** @var string Directory separator for Amazon S3 keys */
56
+ protected $delimiter = '/';
57
+
58
+ /** @var string Base directory to remove from each file path before converting to an object name or file name */
59
+ protected $baseDir;
60
+
61
+ /** @var bool Whether or not to only transfer modified or new files */
62
+ protected $forcing = false;
63
+
64
+ /** @var bool Whether or not debug output is enable */
65
+ protected $debug;
66
+
67
+ /**
68
+ * @return static
69
+ */
70
+ public static function getInstance()
71
+ {
72
+ return new static();
73
+ }
74
+
75
+ /**
76
+ * Set the bucket to use with the sync
77
+ *
78
+ * @param string $bucket Amazon S3 bucket name
79
+ *
80
+ * @return $this
81
+ */
82
+ public function setBucket($bucket)
83
+ {
84
+ $this->bucket = $bucket;
85
+
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Set the Amazon S3 client object that will send requests
91
+ *
92
+ * @param S3Client $client Amazon S3 client
93
+ *
94
+ * @return $this
95
+ */
96
+ public function setClient(S3Client $client)
97
+ {
98
+ $this->client = $client;
99
+
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Set a custom iterator that returns \SplFileInfo objects for the source data
105
+ *
106
+ * @param \Iterator $iterator
107
+ *
108
+ * @return $this
109
+ */
110
+ public function setSourceIterator(\Iterator $iterator)
111
+ {
112
+ $this->sourceIterator = $iterator;
113
+
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Set a custom object key provider instead of building one internally
119
+ *
120
+ * @param FileNameConverterInterface $converter Filename to object key provider
121
+ *
122
+ * @return $this
123
+ */
124
+ public function setSourceFilenameConverter(FilenameConverterInterface $converter)
125
+ {
126
+ $this->sourceConverter = $converter;
127
+
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Set a custom object key provider instead of building one internally
133
+ *
134
+ * @param FileNameConverterInterface $converter Filename to object key provider
135
+ *
136
+ * @return $this
137
+ */
138
+ public function setTargetFilenameConverter(FilenameConverterInterface $converter)
139
+ {
140
+ $this->targetConverter = $converter;
141
+
142
+ return $this;
143
+ }
144
+
145
+ /**
146
+ * Set the base directory of the files being transferred. The base directory is removed from each file path before
147
+ * converting the file path to an object key or vice versa.
148
+ *
149
+ * @param string $baseDir Base directory, which will be deleted from each uploaded object key
150
+ *
151
+ * @return $this
152
+ */
153
+ public function setBaseDir($baseDir)
154
+ {
155
+ $this->baseDir = $baseDir;
156
+
157
+ return $this;
158
+ }
159
+
160
+ /**
161
+ * Specify a prefix to prepend to each Amazon S3 object key or the prefix where object are stored in a bucket
162
+ *
163
+ * Can be used to upload files to a pseudo sub-folder key or only download files from a pseudo sub-folder
164
+ *
165
+ * @param string $keyPrefix Prefix for each uploaded key
166
+ *
167
+ * @return $this
168
+ */
169
+ public function setKeyPrefix($keyPrefix)
170
+ {
171
+ // Removing leading slash
172
+ $this->keyPrefix = ltrim($keyPrefix, '/');
173
+
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * Specify the delimiter used for the targeted filesystem (default delimiter is "/")
179
+ *
180
+ * @param string $delimiter Delimiter to use to separate paths
181
+ *
182
+ * @return $this
183
+ */
184
+ public function setDelimiter($delimiter)
185
+ {
186
+ $this->delimiter = $delimiter;
187
+
188
+ return $this;
189
+ }
190
+
191
+ /**
192
+ * Specify an array of operation parameters to apply to each operation executed by the sync object
193
+ *
194
+ * @param array $params Associative array of PutObject (upload) GetObject (download) parameters
195
+ *
196
+ * @return $this
197
+ */
198
+ public function setOperationParams(array $params)
199
+ {
200
+ $this->params = $params;
201
+
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Set the number of files that can be transferred concurrently
207
+ *
208
+ * @param int $concurrency Number of concurrent transfers
209
+ *
210
+ * @return $this
211
+ */
212
+ public function setConcurrency($concurrency)
213
+ {
214
+ $this->concurrency = $concurrency;
215
+
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * Set to true to force transfers even if a file already exists and has not changed
221
+ *
222
+ * @param bool $force Set to true to force transfers without checking if it has changed
223
+ *
224
+ * @return $this
225
+ */
226
+ public function force($force = false)
227
+ {
228
+ $this->forcing = (bool) $force;
229
+
230
+ return $this;
231
+ }
232
+
233
+ /**
234
+ * Enable debug mode
235
+ *
236
+ * @param bool|resource $enabledOrResource Set to true or false to enable or disable debug output. Pass an opened
237
+ * fopen resource to write to instead of writing to standard out.
238
+ * @return $this
239
+ */
240
+ public function enableDebugOutput($enabledOrResource = true)
241
+ {
242
+ $this->debug = $enabledOrResource;
243
+
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * Add a filename filter that uses a regular expression to filter out files that you do not wish to transfer.
249
+ *
250
+ * @param string $search Regular expression search (in preg_match format). Any filename that matches this regex
251
+ * will not be transferred.
252
+ * @return $this
253
+ */
254
+ public function addRegexFilter($search)
255
+ {
256
+ $this->assertFileIteratorSet();
257
+ $this->sourceIterator = new FilterIterator($this->sourceIterator, function ($i) use ($search) {
258
+ return !preg_match($search, (string) $i);
259
+ });
260
+ $this->sourceIterator->rewind();
261
+
262
+ return $this;
263
+ }
264
+
265
+ /**
266
+ * Builds a UploadSync or DownloadSync object
267
+ *
268
+ * @return AbstractSync
269
+ */
270
+ public function build()
271
+ {
272
+ $this->validateRequirements();
273
+ $this->sourceConverter = $this->sourceConverter ?: $this->getDefaultSourceConverter();
274
+ $this->targetConverter = $this->targetConverter ?: $this->getDefaultTargetConverter();
275
+
276
+ // Only wrap the source iterator in a changed files iterator if we are not forcing the transfers
277
+ if (!$this->forcing) {
278
+ $this->sourceIterator->rewind();
279
+ $this->sourceIterator = new ChangedFilesIterator(
280
+ new \NoRewindIterator($this->sourceIterator),
281
+ $this->getTargetIterator(),
282
+ $this->sourceConverter,
283
+ $this->targetConverter
284
+ );
285
+ $this->sourceIterator->rewind();
286
+ }
287
+
288
+ $sync = $this->specificBuild();
289
+
290
+ if ($this->params) {
291
+ $this->addCustomParamListener($sync);
292
+ }
293
+
294
+ if ($this->debug) {
295
+ $this->addDebugListener($sync, is_bool($this->debug) ? STDOUT : $this->debug);
296
+ }
297
+
298
+ return $sync;
299
+ }
300
+
301
+ /**
302
+ * Hook to implement in subclasses
303
+ *
304
+ * @return AbstractSync
305
+ */
306
+ abstract protected function specificBuild();
307
+
308
+ /**
309
+ * @return \Iterator
310
+ */
311
+ abstract protected function getTargetIterator();
312
+
313
+ /**
314
+ * @return FilenameConverterInterface
315
+ */
316
+ abstract protected function getDefaultSourceConverter();
317
+
318
+ /**
319
+ * @return FilenameConverterInterface
320
+ */
321
+ abstract protected function getDefaultTargetConverter();
322
+
323
+ /**
324
+ * Add a listener to the sync object to output debug information while transferring
325
+ *
326
+ * @param AbstractSync $sync Sync object to listen to
327
+ * @param resource $resource Where to write debug messages
328
+ */
329
+ abstract protected function addDebugListener(AbstractSync $sync, $resource);
330
+
331
+ /**
332
+ * Validate that the builder has the minimal requirements
333
+ *
334
+ * @throws RuntimeException if the builder is not configured completely
335
+ */
336
+ protected function validateRequirements()
337
+ {
338
+ if (!$this->client) {
339
+ throw new RuntimeException('No client was provided');
340
+ }
341
+ if (!$this->bucket) {
342
+ throw new RuntimeException('No bucket was provided');
343
+ }
344
+ $this->assertFileIteratorSet();
345
+ }
346
+
347
+ /**
348
+ * Ensure that the base file iterator has been provided
349
+ *
350
+ * @throws RuntimeException
351
+ */
352
+ protected function assertFileIteratorSet()
353
+ {
354
+ // Interesting... Need to use isset because: Object of class GlobIterator could not be converted to boolean
355
+ if (!isset($this->sourceIterator)) {
356
+ throw new RuntimeException('A source file iterator must be specified');
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Wraps a generated iterator in a filter iterator that removes directories
362
+ *
363
+ * @param \Iterator $iterator Iterator to wrap
364
+ *
365
+ * @return \Iterator
366
+ * @throws UnexpectedValueException
367
+ */
368
+ protected function filterIterator(\Iterator $iterator)
369
+ {
370
+ $f = new FilterIterator($iterator, function ($i) {
371
+ if (!$i instanceof \SplFileInfo) {
372
+ throw new UnexpectedValueException('All iterators for UploadSync must return SplFileInfo objects');
373
+ }
374
+ return $i->isFile();
375
+ });
376
+
377
+ $f->rewind();
378
+
379
+ return $f;
380
+ }
381
+
382
+ /**
383
+ * Add the custom param listener to a transfer object
384
+ *
385
+ * @param HasDispatcherInterface $sync
386
+ */
387
+ protected function addCustomParamListener(HasDispatcherInterface $sync)
388
+ {
389
+ $params = $this->params;
390
+ $sync->getEventDispatcher()->addListener(
391
+ UploadSync::BEFORE_TRANSFER,
392
+ function (Event $e) use ($params) {
393
+ if ($e['command'] instanceof CommandInterface) {
394
+ $e['command']->overwriteWith($params);
395
+ }
396
+ }
397
+ );
398
+ }
399
+
400
+ /**
401
+ * Create an Amazon S3 file iterator based on the given builder settings
402
+ *
403
+ * @return OpendirIterator
404
+ */
405
+ protected function createS3Iterator()
406
+ {
407
+ // Ensure that the stream wrapper is registered
408
+ $this->client->registerStreamWrapper();
409
+
410
+ // Calculate the opendir() bucket and optional key prefix location
411
+ $dir = "s3://{$this->bucket}";
412
+ if ($this->keyPrefix) {
413
+ $dir .= '/' . ltrim($this->keyPrefix, '/ ');
414
+ }
415
+
416
+ // Use opendir so that we can pass stream context to the iterator
417
+ $dh = opendir($dir, stream_context_create(array(
418
+ 's3' => array(
419
+ 'delimiter' => '',
420
+ 'listFilter' => function ($obj) {
421
+ // Ensure that we do not try to download a glacier object.
422
+ return !isset($obj['StorageClass']) ||
423
+ $obj['StorageClass'] != 'GLACIER';
424
+ }
425
+ )
426
+ )));
427
+
428
+ // Add the trailing slash for the OpendirIterator concatenation
429
+ if (!$this->keyPrefix) {
430
+ $dir .= '/';
431
+ }
432
+
433
+ return $this->filterIterator(new \NoRewindIterator(new OpendirIterator($dh, $dir)));
434
+ }
435
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/ChangedFilesIterator.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ /**
20
+ * Iterator used to filter an internal iterator to only yield files that do not exist in the target iterator or files
21
+ * that have changed
22
+ */
23
+ class ChangedFilesIterator extends \FilterIterator
24
+ {
25
+ /** @var \Iterator */
26
+ protected $sourceIterator;
27
+
28
+ /** @var \Iterator */
29
+ protected $targetIterator;
30
+
31
+ /** @var FilenameConverterInterface */
32
+ protected $sourceConverter;
33
+
34
+ /** @var FilenameConverterInterface */
35
+ protected $targetConverter;
36
+
37
+ /** @var array Previously loaded data */
38
+ protected $cache = array();
39
+
40
+ /**
41
+ * @param \Iterator $sourceIterator Iterator to wrap and filter
42
+ * @param \Iterator $targetIterator Iterator used to compare against the source iterator
43
+ * @param FilenameConverterInterface $sourceConverter Key converter to convert source to target keys
44
+ * @param FilenameConverterInterface $targetConverter Key converter to convert target to source keys
45
+ */
46
+ public function __construct(
47
+ \Iterator $sourceIterator,
48
+ \Iterator $targetIterator,
49
+ FilenameConverterInterface $sourceConverter,
50
+ FilenameConverterInterface $targetConverter
51
+ ) {
52
+ $this->targetIterator = $targetIterator;
53
+ $this->sourceConverter = $sourceConverter;
54
+ $this->targetConverter = $targetConverter;
55
+ parent::__construct($sourceIterator);
56
+ }
57
+
58
+ public function accept()
59
+ {
60
+ $current = $this->current();
61
+ $key = $this->sourceConverter->convert($this->normalize($current));
62
+
63
+ if (!($data = $this->getTargetData($key))) {
64
+ return true;
65
+ }
66
+
67
+ // Ensure the Content-Length matches and it hasn't been modified since the mtime
68
+ return $current->getSize() != $data[0] || $current->getMTime() > $data[1];
69
+ }
70
+
71
+ /**
72
+ * Returns an array of the files from the target iterator that were not found in the source iterator
73
+ *
74
+ * @return array
75
+ */
76
+ public function getUnmatched()
77
+ {
78
+ return array_keys($this->cache);
79
+ }
80
+
81
+ /**
82
+ * Get key information from the target iterator for a particular filename
83
+ *
84
+ * @param string $key Target iterator filename
85
+ *
86
+ * @return array|bool Returns an array of data, or false if the key is not in the iterator
87
+ */
88
+ protected function getTargetData($key)
89
+ {
90
+ $key = $this->cleanKey($key);
91
+
92
+ if (isset($this->cache[$key])) {
93
+ $result = $this->cache[$key];
94
+ unset($this->cache[$key]);
95
+ return $result;
96
+ }
97
+
98
+ $it = $this->targetIterator;
99
+
100
+ while ($it->valid()) {
101
+ $value = $it->current();
102
+ $data = array($value->getSize(), $value->getMTime());
103
+ $filename = $this->targetConverter->convert($this->normalize($value));
104
+ $filename = $this->cleanKey($filename);
105
+
106
+ if ($filename == $key) {
107
+ return $data;
108
+ }
109
+
110
+ $this->cache[$filename] = $data;
111
+ $it->next();
112
+ }
113
+
114
+ return false;
115
+ }
116
+
117
+ private function normalize($current)
118
+ {
119
+ $asString = (string) $current;
120
+
121
+ return strpos($asString, 's3://') === 0
122
+ ? $asString
123
+ : $current->getRealPath();
124
+ }
125
+
126
+ private function cleanKey($key)
127
+ {
128
+ return ltrim($key, '/');
129
+ }
130
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/DownloadSync.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Aws\S3\ResumableDownload;
21
+
22
+ /**
23
+ * Downloads and Amazon S3 bucket to a local directory
24
+ */
25
+ class DownloadSync extends AbstractSync
26
+ {
27
+ protected function createTransferAction(\SplFileInfo $file)
28
+ {
29
+ $sourceFilename = $file->getPathname();
30
+ list($bucket, $key) = explode('/', substr($sourceFilename, 5), 2);
31
+ $filename = $this->options['source_converter']->convert($sourceFilename);
32
+ $this->createDirectory($filename);
33
+
34
+ // Some S3 buckets contains nested files under the same name as a directory
35
+ if (is_dir($filename)) {
36
+ return false;
37
+ }
38
+
39
+ // Allow a previously interrupted download to resume
40
+ if (file_exists($filename) && $this->options['resumable']) {
41
+ return new ResumableDownload($this->options['client'], $bucket, $key, $filename);
42
+ }
43
+
44
+ return $this->options['client']->getCommand('GetObject', array(
45
+ 'Bucket' => $bucket,
46
+ 'Key' => $key,
47
+ 'SaveAs' => $filename
48
+ ));
49
+ }
50
+
51
+ /**
52
+ * @codeCoverageIgnore
53
+ */
54
+ protected function createDirectory($filename)
55
+ {
56
+ $directory = dirname($filename);
57
+ // Some S3 clients create empty files to denote directories. Remove these so that we can create the directory.
58
+ if (is_file($directory) && filesize($directory) == 0) {
59
+ unlink($directory);
60
+ }
61
+ // Create the directory if it does not exist
62
+ if (!is_dir($directory) && !mkdir($directory, 0777, true)) {
63
+ $errors = error_get_last();
64
+ throw new RuntimeException('Could not create directory: ' . $directory . ' - ' . $errors['message']);
65
+ }
66
+ }
67
+
68
+ protected function filterCommands(array $commands)
69
+ {
70
+ // Build a list of all of the directories in each command so that we don't attempt to create an empty dir in
71
+ // the same parallel transfer as attempting to create a file in that dir
72
+ $dirs = array();
73
+ foreach ($commands as $command) {
74
+ $parts = array_values(array_filter(explode('/', $command['SaveAs'])));
75
+ for ($i = 0, $total = count($parts); $i < $total; $i++) {
76
+ $dir = '';
77
+ for ($j = 0; $j < $i; $j++) {
78
+ $dir .= '/' . $parts[$j];
79
+ }
80
+ if ($dir && !in_array($dir, $dirs)) {
81
+ $dirs[] = $dir;
82
+ }
83
+ }
84
+ }
85
+
86
+ return array_filter($commands, function ($command) use ($dirs) {
87
+ return !in_array($command['SaveAs'], $dirs);
88
+ });
89
+ }
90
+
91
+ protected function transferCommands(array $commands)
92
+ {
93
+ parent::transferCommands($this->filterCommands($commands));
94
+ }
95
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/DownloadSyncBuilder.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Aws\S3\ResumableDownload;
21
+ use Guzzle\Common\Event;
22
+ use Guzzle\Http\EntityBodyInterface;
23
+ use Guzzle\Service\Command\CommandInterface;
24
+
25
+ class DownloadSyncBuilder extends AbstractSyncBuilder
26
+ {
27
+ /** @var bool */
28
+ protected $resumable = false;
29
+
30
+ /** @var string */
31
+ protected $directory;
32
+
33
+ /** @var int Number of files that can be transferred concurrently */
34
+ protected $concurrency = 5;
35
+
36
+ /**
37
+ * Set the directory where the objects from be downloaded to
38
+ *
39
+ * @param string $directory Directory
40
+ *
41
+ * @return $this
42
+ */
43
+ public function setDirectory($directory)
44
+ {
45
+ $this->directory = $directory;
46
+
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * Call this function to allow partial downloads to be resumed if the download was previously interrupted
52
+ *
53
+ * @return self
54
+ */
55
+ public function allowResumableDownloads()
56
+ {
57
+ $this->resumable = true;
58
+
59
+ return $this;
60
+ }
61
+
62
+ protected function specificBuild()
63
+ {
64
+ $sync = new DownloadSync(array(
65
+ 'client' => $this->client,
66
+ 'bucket' => $this->bucket,
67
+ 'iterator' => $this->sourceIterator,
68
+ 'source_converter' => $this->sourceConverter,
69
+ 'target_converter' => $this->targetConverter,
70
+ 'concurrency' => $this->concurrency,
71
+ 'resumable' => $this->resumable,
72
+ 'directory' => $this->directory
73
+ ));
74
+
75
+ return $sync;
76
+ }
77
+
78
+ protected function getTargetIterator()
79
+ {
80
+ if (!$this->directory) {
81
+ throw new RuntimeException('A directory is required');
82
+ }
83
+
84
+ if (!is_dir($this->directory) && !mkdir($this->directory, 0777, true)) {
85
+ // @codeCoverageIgnoreStart
86
+ throw new RuntimeException('Unable to create root download directory: ' . $this->directory);
87
+ // @codeCoverageIgnoreEnd
88
+ }
89
+
90
+ return $this->filterIterator(
91
+ new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory))
92
+ );
93
+ }
94
+
95
+ protected function getDefaultSourceConverter()
96
+ {
97
+ return new KeyConverter(
98
+ "s3://{$this->bucket}/{$this->baseDir}",
99
+ $this->directory . DIRECTORY_SEPARATOR, $this->delimiter
100
+ );
101
+ }
102
+
103
+ protected function getDefaultTargetConverter()
104
+ {
105
+ return new KeyConverter("s3://{$this->bucket}/{$this->baseDir}", '', $this->delimiter);
106
+ }
107
+
108
+ protected function assertFileIteratorSet()
109
+ {
110
+ $this->sourceIterator = $this->sourceIterator ?: $this->createS3Iterator();
111
+ }
112
+
113
+ protected function addDebugListener(AbstractSync $sync, $resource)
114
+ {
115
+ $sync->getEventDispatcher()->addListener(UploadSync::BEFORE_TRANSFER, function (Event $e) use ($resource) {
116
+ if ($e['command'] instanceof CommandInterface) {
117
+ $from = $e['command']['Bucket'] . '/' . $e['command']['Key'];
118
+ $to = $e['command']['SaveAs'] instanceof EntityBodyInterface
119
+ ? $e['command']['SaveAs']->getUri()
120
+ : $e['command']['SaveAs'];
121
+ fwrite($resource, "Downloading {$from} -> {$to}\n");
122
+ } elseif ($e['command'] instanceof ResumableDownload) {
123
+ $from = $e['command']->getBucket() . '/' . $e['command']->getKey();
124
+ $to = $e['command']->getFilename();
125
+ fwrite($resource, "Resuming {$from} -> {$to}\n");
126
+ }
127
+ });
128
+ }
129
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/FilenameConverterInterface.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ /**
20
+ * Converts filenames from one system to another (e.g. local to Amazon S3)
21
+ */
22
+ interface FilenameConverterInterface
23
+ {
24
+ /**
25
+ * Convert a filename
26
+ *
27
+ * @param string $filename Name of the file to convert
28
+ *
29
+ * @return string
30
+ */
31
+ public function convert($filename);
32
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/KeyConverter.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ /**
20
+ * Converts filenames from one system to another
21
+ */
22
+ class KeyConverter implements FilenameConverterInterface
23
+ {
24
+ /** @var string Directory separator for Amazon S3 keys */
25
+ protected $delimiter;
26
+
27
+ /** @var string Prefix to prepend to each Amazon S3 object key */
28
+ protected $prefix;
29
+
30
+ /** @var string Base directory to remove from each file path before converting to an object key */
31
+ protected $baseDir;
32
+
33
+ /**
34
+ * @param string $baseDir Base directory to remove from each converted name
35
+ * @param string $prefix Amazon S3 prefix
36
+ * @param string $delimiter Directory separator used with generated names
37
+ */
38
+ public function __construct($baseDir = '', $prefix = '', $delimiter = '/')
39
+ {
40
+ $this->baseDir = (string) $baseDir;
41
+ $this->prefix = $prefix;
42
+ $this->delimiter = $delimiter;
43
+ }
44
+
45
+ public function convert($filename)
46
+ {
47
+ $key = $filename;
48
+
49
+ // Remove base directory from the key (only the first occurrence)
50
+ if ($this->baseDir && (false !== $pos = strpos($filename, $this->baseDir))) {
51
+ $key = substr_replace($key, '', $pos, strlen($this->baseDir));
52
+ }
53
+
54
+ // Replace Windows directory separators to become Unix style, and convert that to the custom dir separator
55
+ $key = str_replace('/', $this->delimiter, str_replace('\\', '/', $key));
56
+
57
+ // Add the key prefix and remove double slashes that are not in the protocol (e.g. prefixed with ":")
58
+ $delim = preg_quote($this->delimiter);
59
+ $key = preg_replace(
60
+ "#(?<!:){$delim}{$delim}#",
61
+ $this->delimiter,
62
+ $this->prefix . $key
63
+ );
64
+
65
+ return $key;
66
+ }
67
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSync.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ use Aws\Common\Exception\RuntimeException;
20
+ use Aws\S3\Model\MultipartUpload\UploadBuilder;
21
+ use Aws\S3\Model\MultipartUpload\AbstractTransfer;
22
+ use Guzzle\Http\EntityBody;
23
+
24
+ /**
25
+ * Uploads a local directory tree to Amazon S3
26
+ */
27
+ class UploadSync extends AbstractSync
28
+ {
29
+ const BEFORE_MULTIPART_BUILD = 's3.sync.before_multipart_build';
30
+
31
+ protected function init()
32
+ {
33
+ if (null == $this->options['multipart_upload_size']) {
34
+ $this->options['multipart_upload_size'] = AbstractTransfer::MIN_PART_SIZE;
35
+ }
36
+ }
37
+
38
+ protected function createTransferAction(\SplFileInfo $file)
39
+ {
40
+ // Open the file for reading
41
+ $filename = $file->getRealPath() ?: $file->getPathName();
42
+
43
+ if (!($resource = fopen($filename, 'r'))) {
44
+ // @codeCoverageIgnoreStart
45
+ throw new RuntimeException('Could not open ' . $file->getPathname() . ' for reading');
46
+ // @codeCoverageIgnoreEnd
47
+ }
48
+
49
+ $key = $this->options['source_converter']->convert($filename);
50
+ $body = EntityBody::factory($resource);
51
+
52
+ // Determine how the ACL should be applied
53
+ if ($acl = $this->options['acl']) {
54
+ $aclType = is_string($this->options['acl']) ? 'ACL' : 'ACP';
55
+ } else {
56
+ $acl = 'private';
57
+ $aclType = 'ACL';
58
+ }
59
+
60
+ // Use a multi-part upload if the file is larger than the cutoff size and is a regular file
61
+ if ($body->getWrapper() == 'plainfile' && $file->getSize() >= $this->options['multipart_upload_size']) {
62
+ $builder = UploadBuilder::newInstance()
63
+ ->setBucket($this->options['bucket'])
64
+ ->setKey($key)
65
+ ->setMinPartSize($this->options['multipart_upload_size'])
66
+ ->setOption($aclType, $acl)
67
+ ->setClient($this->options['client'])
68
+ ->setSource($body)
69
+ ->setConcurrency($this->options['concurrency']);
70
+
71
+ $this->dispatch(
72
+ self::BEFORE_MULTIPART_BUILD,
73
+ array('builder' => $builder, 'file' => $file)
74
+ );
75
+
76
+ return $builder->build();
77
+ }
78
+
79
+ return $this->options['client']->getCommand('PutObject', array(
80
+ 'Bucket' => $this->options['bucket'],
81
+ 'Key' => $key,
82
+ 'Body' => $body,
83
+ $aclType => $acl
84
+ ));
85
+ }
86
+ }
lib/amazon/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License").
6
+ * You may not use this file except in compliance with the License.
7
+ * A copy of the License is located at
8
+ *
9
+ * http://aws.amazon.com/apache2.0
10
+ *
11
+ * or in the "license" file accompanying this file. This file is distributed
12
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
+ * express or implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ namespace Aws\S3\Sync;
18
+
19
+ use \FilesystemIterator as FI;
20
+ use Aws\Common\Model\MultipartUpload\AbstractTransfer;
21
+ use Aws\S3\Model\Acp;
22
+ use Guzzle\Common\HasDispatcherInterface;
23
+ use Guzzle\Common\Event;
24
+ use Guzzle\Service\Command\CommandInterface;
25
+
26
+ class UploadSyncBuilder extends AbstractSyncBuilder
27
+ {
28
+ /** @var string|Acp Access control policy to set on each object */
29
+ protected $acp = 'private';
30
+
31
+ /** @var int */
32
+ protected $multipartUploadSize;
33
+
34
+ /**
35
+ * Set the path that contains files to recursively upload to Amazon S3
36
+ *
37
+ * @param string $path Path that contains files to upload
38
+ *
39
+ * @return $this
40
+ */
41
+ public function uploadFromDirectory($path)
42
+ {
43
+ $this->baseDir = realpath($path);
44
+ $this->sourceIterator = $this->filterIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(
45
+ $path,
46
+ FI::SKIP_DOTS | FI::UNIX_PATHS | FI::FOLLOW_SYMLINKS
47
+ )));
48
+
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * Set a glob expression that will match files to upload to Amazon S3
54
+ *
55
+ * @param string $glob Glob expression
56
+ *
57
+ * @return $this
58
+ * @link http://www.php.net/manual/en/function.glob.php
59
+ */
60
+ public function uploadFromGlob($glob)
61
+ {
62
+ $this->sourceIterator = $this->filterIterator(
63
+ new \GlobIterator($glob, FI::SKIP_DOTS | FI::UNIX_PATHS | FI::FOLLOW_SYMLINKS)
64
+ );
65
+
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Set a canned ACL to apply to each uploaded object
71
+ *
72
+ * @param string $acl Canned ACL for each upload
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setAcl($acl)
77
+ {
78
+ $this->acp = $acl;
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Set an Access Control Policy to apply to each uploaded object
85
+ *
86
+ * @param Acp $acp Access control policy
87
+ *
88
+ * @return $this
89
+ */
90
+ public function setAcp(Acp $acp)
91
+ {
92
+ $this->acp = $acp;
93
+
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * Set the multipart upload size threshold. When the size of a file exceeds this value, the file will be uploaded
99
+ * using a multipart upload.
100
+ *
101
+ * @param int $size Size threshold
102
+ *
103
+ * @return $this
104
+ */
105
+ public function setMultipartUploadSize($size)
106
+ {
107
+ $this->multipartUploadSize = $size;
108
+
109
+ return $this;
110
+ }
111
+
112
+ protected function specificBuild()
113
+ {
114
+ $sync = new UploadSync(array(
115
+ 'client' => $this->client,
116
+ 'bucket' => $this->bucket,
117
+ 'iterator' => $this->sourceIterator,
118
+ 'source_converter' => $this->sourceConverter,
119
+ 'target_converter' => $this->targetConverter,
120
+ 'concurrency' => $this->concurrency,
121
+ 'multipart_upload_size' => $this->multipartUploadSize,
122
+ 'acl' => $this->acp
123
+ ));
124
+
125
+ return $sync;
126
+ }
127
+
128
+ protected function addCustomParamListener(HasDispatcherInterface $sync)
129
+ {
130
+ // Handle the special multi-part upload event
131
+ parent::addCustomParamListener($sync);
132
+ $params = $this->params;
133
+ $sync->getEventDispatcher()->addListener(
134
+ UploadSync::BEFORE_MULTIPART_BUILD,
135
+ function (Event $e) use ($params) {
136
+ foreach ($params as $k => $v) {
137
+ $e['builder']->setOption($k, $v);
138
+ }
139
+ }
140
+ );
141
+ }
142
+
143
+ protected function getTargetIterator()
144
+ {
145
+ return $this->createS3Iterator();
146
+ }
147
+
148
+ protected function getDefaultSourceConverter()
149
+ {
150
+ return new KeyConverter($this->baseDir, $this->keyPrefix . $this->delimiter, $this->delimiter);
151
+ }
152
+
153
+ protected function getDefaultTargetConverter()
154
+ {
155
+ return new KeyConverter('s3://' . $this->bucket . '/', '', DIRECTORY_SEPARATOR);
156
+ }
157
+
158
+ protected function addDebugListener(AbstractSync $sync, $resource)
159
+ {
160
+ $sync->getEventDispatcher()->addListener(UploadSync::BEFORE_TRANSFER, function (Event $e) use ($resource) {
161
+
162
+ $c = $e['command'];
163
+
164
+ if ($c instanceof CommandInterface) {
165
+ $uri = $c['Body']->getUri();
166
+ $size = $c['Body']->getSize();
167
+ fwrite($resource, "Uploading {$uri} -> {$c['Key']} ({$size} bytes)\n");
168
+ return;
169
+ }
170
+
171
+ // Multipart upload
172
+ $body = $c->getSource();
173
+ $totalSize = $body->getSize();
174
+ $progress = 0;
175
+ fwrite($resource, "Beginning multipart upload: " . $body->getUri() . ' -> ');
176
+ fwrite($resource, $c->getState()->getFromId('Key') . " ({$totalSize} bytes)\n");
177
+
178
+ $c->getEventDispatcher()->addListener(
179
+ AbstractTransfer::BEFORE_PART_UPLOAD,
180
+ function ($e) use (&$progress, $totalSize, $resource) {
181
+ $command = $e['command'];
182
+ $size = $command['Body']->getContentLength();
183
+ $percentage = number_format(($progress / $totalSize) * 100, 2);
184
+ fwrite($resource, "- Part {$command['PartNumber']} ({$size} bytes, {$percentage}%)\n");
185
+ $progress += $size;
186
+ }
187
+ );
188
+ });
189
+ }
190
+ }
lib/amazon/composer/ClassLoader.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0 class loader
17
+ *
18
+ * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
19
+ *
20
+ * $loader = new \Composer\Autoload\ClassLoader();
21
+ *
22
+ * // register classes with namespaces
23
+ * $loader->add('Symfony\Component', __DIR__.'/component');
24
+ * $loader->add('Symfony', __DIR__.'/framework');
25
+ *
26
+ * // activate the autoloader
27
+ * $loader->register();
28
+ *
29
+ * // to enable searching the include path (eg. for PEAR packages)
30
+ * $loader->setUseIncludePath(true);
31
+ *
32
+ * In this example, if you try to use a class in the Symfony\Component
33
+ * namespace or one of its children (Symfony\Component\Console for instance),
34
+ * the autoloader will first look for the class under the component/
35
+ * directory, and it will then fallback to the framework/ directory if not
36
+ * found before giving up.
37
+ *
38
+ * This class is loosely based on the Symfony UniversalClassLoader.
39
+ *
40
+ * @author Fabien Potencier <fabien@symfony.com>
41
+ * @author Jordi Boggiano <j.boggiano@seld.be>
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+
57
+ private $classMapAuthoritative = false;
58
+
59
+ public function getPrefixes()
60
+ {
61
+ if (!empty($this->prefixesPsr0)) {
62
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
63
+ }
64
+
65
+ return array();
66
+ }
67
+
68
+ public function getPrefixesPsr4()
69
+ {
70
+ return $this->prefixDirsPsr4;
71
+ }
72
+
73
+ public function getFallbackDirs()
74
+ {
75
+ return $this->fallbackDirsPsr0;
76
+ }
77
+
78
+ public function getFallbackDirsPsr4()
79
+ {
80
+ return $this->fallbackDirsPsr4;
81
+ }
82
+
83
+ public function getClassMap()
84
+ {
85
+ return $this->classMap;
86
+ }
87
+
88
+ /**
89
+ * @param array $classMap Class to filename map
90
+ */
91
+ public function addClassMap(array $classMap)
92
+ {
93
+ if ($this->classMap) {
94
+ $this->classMap = array_merge($this->classMap, $classMap);
95
+ } else {
96
+ $this->classMap = $classMap;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Registers a set of PSR-0 directories for a given prefix, either
102
+ * appending or prepending to the ones previously set for this prefix.
103
+ *
104
+ * @param string $prefix The prefix
105
+ * @param array|string $paths The PSR-0 root directories
106
+ * @param bool $prepend Whether to prepend the directories
107
+ */
108
+ public function add($prefix, $paths, $prepend = false)
109
+ {
110
+ if (!$prefix) {
111
+ if ($prepend) {
112
+ $this->fallbackDirsPsr0 = array_merge(
113
+ (array) $paths,
114
+ $this->fallbackDirsPsr0
115
+ );
116
+ } else {
117
+ $this->fallbackDirsPsr0 = array_merge(
118
+ $this->fallbackDirsPsr0,
119
+ (array) $paths
120
+ );
121
+ }
122
+
123
+ return;
124
+ }
125
+
126
+ $first = $prefix[0];
127
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
128
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+
130
+ return;
131
+ }
132
+ if ($prepend) {
133
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
134
+ (array) $paths,
135
+ $this->prefixesPsr0[$first][$prefix]
136
+ );
137
+ } else {
138
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
139
+ $this->prefixesPsr0[$first][$prefix],
140
+ (array) $paths
141
+ );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Registers a set of PSR-4 directories for a given namespace, either
147
+ * appending or prepending to the ones previously set for this namespace.
148
+ *
149
+ * @param string $prefix The prefix/namespace, with trailing '\\'
150
+ * @param array|string $paths The PSR-0 base directories
151
+ * @param bool $prepend Whether to prepend the directories
152
+ *
153
+ * @throws \InvalidArgumentException
154
+ */
155
+ public function addPsr4($prefix, $paths, $prepend = false)
156
+ {
157
+ if (!$prefix) {
158
+ // Register directories for the root namespace.
159
+ if ($prepend) {
160
+ $this->fallbackDirsPsr4 = array_merge(
161
+ (array) $paths,
162
+ $this->fallbackDirsPsr4
163
+ );
164
+ } else {
165
+ $this->fallbackDirsPsr4 = array_merge(
166
+ $this->fallbackDirsPsr4,
167
+ (array) $paths
168
+ );
169
+ }
170
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
171
+ // Register directories for a new namespace.
172
+ $length = strlen($prefix);
173
+ if ('\\' !== $prefix[$length - 1]) {
174
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175
+ }
176
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+ } elseif ($prepend) {
179
+ // Prepend directories for an already registered namespace.
180
+ $this->prefixDirsPsr4[$prefix] = array_merge(
181
+ (array) $paths,
182
+ $this->prefixDirsPsr4[$prefix]
183
+ );
184
+ } else {
185
+ // Append directories for an already registered namespace.
186
+ $this->prefixDirsPsr4[$prefix] = array_merge(
187
+ $this->prefixDirsPsr4[$prefix],
188
+ (array) $paths
189
+ );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Registers a set of PSR-0 directories for a given prefix,
195
+ * replacing any others previously set for this prefix.
196
+ *
197
+ * @param string $prefix The prefix
198
+ * @param array|string $paths The PSR-0 base directories
199
+ */
200
+ public function set($prefix, $paths)
201
+ {
202
+ if (!$prefix) {
203
+ $this->fallbackDirsPsr0 = (array) $paths;
204
+ } else {
205
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Registers a set of PSR-4 directories for a given namespace,
211
+ * replacing any others previously set for this namespace.
212
+ *
213
+ * @param string $prefix The prefix/namespace, with trailing '\\'
214
+ * @param array|string $paths The PSR-4 base directories
215
+ *
216
+ * @throws \InvalidArgumentException
217
+ */
218
+ public function setPsr4($prefix, $paths)
219
+ {
220
+ if (!$prefix) {
221
+ $this->fallbackDirsPsr4 = (array) $paths;
222
+ } else {
223
+ $length = strlen($prefix);
224
+ if ('\\' !== $prefix[$length - 1]) {
225
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
226
+ }
227
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
228
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Turns on searching the include path for class files.
234
+ *
235
+ * @param bool $useIncludePath
236
+ */
237
+ public function setUseIncludePath($useIncludePath)
238
+ {
239
+ $this->useIncludePath = $useIncludePath;
240
+ }
241
+
242
+ /**
243
+ * Can be used to check if the autoloader uses the include path to check
244
+ * for classes.
245
+ *
246
+ * @return bool
247
+ */
248
+ public function getUseIncludePath()
249
+ {
250
+ return $this->useIncludePath;
251
+ }
252
+
253
+ /**
254
+ * Turns off searching the prefix and fallback directories for classes
255
+ * that have not been registered with the class map.
256
+ *
257
+ * @param bool $classMapAuthoritative
258
+ */
259
+ public function setClassMapAuthoritative($classMapAuthoritative)
260
+ {
261
+ $this->classMapAuthoritative = $classMapAuthoritative;
262
+ }
263
+
264
+ /**
265
+ * Should class lookup fail if not found in the current class map?
266
+ *
267
+ * @return bool
268
+ */
269
+ public function isClassMapAuthoritative()
270
+ {
271
+ return $this->classMapAuthoritative;
272
+ }
273
+
274
+ /**
275
+ * Registers this instance as an autoloader.
276
+ *
277
+ * @param bool $prepend Whether to prepend the autoloader or not
278
+ */
279
+ public function register($prepend = false)
280
+ {
281
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
282
+ }
283
+
284
+ /**
285
+ * Unregisters this instance as an autoloader.
286
+ */
287
+ public function unregister()
288
+ {
289
+ spl_autoload_unregister(array($this, 'loadClass'));
290
+ }
291
+
292
+ /**
293
+ * Loads the given class or interface.
294
+ *
295
+ * @param string $class The name of the class
296
+ * @return bool|null True if loaded, null otherwise
297
+ */
298
+ public function loadClass($class)
299
+ {
300
+ if ($file = $this->findFile($class)) {
301
+ includeFile($file);
302
+
303
+ return true;
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Finds the path to the file where the class is defined.
309
+ *
310
+ * @param string $class The name of the class
311
+ *
312
+ * @return string|false The path if found, false otherwise
313
+ */
314
+ public function findFile($class)
315
+ {
316
+ // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317
+ if ('\\' == $class[0]) {
318
+ $class = substr($class, 1);
319
+ }
320
+
321
+ // class map lookup
322
+ if (isset($this->classMap[$class])) {
323
+ return $this->classMap[$class];
324
+ }
325
+ if ($this->classMapAuthoritative) {
326
+ return false;
327
+ }
328
+
329
+ $file = $this->findFileWithExtension($class, '.php');
330
+
331
+ // Search for Hack files if we are running on HHVM
332
+ if ($file === null && defined('HHVM_VERSION')) {
333
+ $file = $this->findFileWithExtension($class, '.hh');
334
+ }
335
+
336
+ if ($file === null) {
337
+ // Remember that this class does not exist.
338
+ return $this->classMap[$class] = false;
339
+ }
340
+
341
+ return $file;
342
+ }
343
+
344
+ private function findFileWithExtension($class, $ext)
345
+ {
346
+ // PSR-4 lookup
347
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
348
+
349
+ $first = $class[0];
350
+ if (isset($this->prefixLengthsPsr4[$first])) {
351
+ foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352
+ if (0 === strpos($class, $prefix)) {
353
+ foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354
+ if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
355
+ return $file;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+ // PSR-4 fallback dirs
363
+ foreach ($this->fallbackDirsPsr4 as $dir) {
364
+ if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
365
+ return $file;
366
+ }
367
+ }
368
+
369
+ // PSR-0 lookup
370
+ if (false !== $pos = strrpos($class, '\\')) {
371
+ // namespaced class name
372
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
373
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
374
+ } else {
375
+ // PEAR-like class name
376
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
377
+ }
378
+
379
+ if (isset($this->prefixesPsr0[$first])) {
380
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
381
+ if (0 === strpos($class, $prefix)) {
382
+ foreach ($dirs as $dir) {
383
+ if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
384
+ return $file;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ // PSR-0 fallback dirs
392
+ foreach ($this->fallbackDirsPsr0 as $dir) {
393
+ if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
394
+ return $file;
395
+ }
396
+ }
397
+
398
+ // PSR-0 include paths.
399
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400
+ return $file;
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Scope isolated include.
407
+ *
408
+ * Prevents access to $this/self from included files.
409
+ */
410
+ function includeFile($file)
411
+ {
412
+ include $file;
413
+ }
lib/amazon/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
lib/amazon/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
10
+ 'Guzzle\\Tests' => array($vendorDir . '/guzzle/guzzle/tests'),
11
+ 'Guzzle' => array($vendorDir . '/guzzle/guzzle/src'),
12
+ 'Aws' => array($vendorDir . '/aws/aws-sdk-php/src'),
13
+ );
lib/amazon/composer/autoload_psr4.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
lib/amazon/composer/autoload_real.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInitc0e9593f4594291c0bfbb43cf84f3f53
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInitc0e9593f4594291c0bfbb43cf84f3f53', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitc0e9593f4594291c0bfbb43cf84f3f53', 'loadClassLoader'));
25
+
26
+ $map = require __DIR__ . '/autoload_namespaces.php';
27
+ foreach ($map as $namespace => $path) {
28
+ $loader->set($namespace, $path);
29
+ }
30
+
31
+ $map = require __DIR__ . '/autoload_psr4.php';
32
+ foreach ($map as $namespace => $path) {
33
+ $loader->setPsr4($namespace, $path);
34
+ }
35
+
36
+ $classMap = require __DIR__ . '/autoload_classmap.php';
37
+ if ($classMap) {
38
+ $loader->addClassMap($classMap);
39
+ }
40
+
41
+ $loader->register(true);
42
+
43
+ return $loader;
44
+ }
45
+ }
46
+
47
+ function composerRequirec0e9593f4594291c0bfbb43cf84f3f53($file)
48
+ {
49
+ require $file;
50
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/AbstractCacheAdapter.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ /**
6
+ * Abstract cache adapter
7
+ */
8
+ abstract class AbstractCacheAdapter implements CacheAdapterInterface
9
+ {
10
+ protected $cache;
11
+
12
+ /**
13
+ * Get the object owned by the adapter
14
+ *
15
+ * @return mixed
16
+ */
17
+ public function getCacheObject()
18
+ {
19
+ return $this->cache;
20
+ }
21
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/CacheAdapterFactory.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ use Doctrine\Common\Cache\Cache;
6
+ use Guzzle\Common\Version;
7
+ use Guzzle\Common\Exception\InvalidArgumentException;
8
+ use Guzzle\Common\Exception\RuntimeException;
9
+ use Guzzle\Common\FromConfigInterface;
10
+ use Zend\Cache\Storage\StorageInterface;
11
+
12
+ /**
13
+ * Generates cache adapters from any number of known cache implementations
14
+ */
15
+ class CacheAdapterFactory implements FromConfigInterface
16
+ {
17
+ /**
18
+ * Create a Guzzle cache adapter based on an array of options
19
+ *
20
+ * @param mixed $cache Cache value
21
+ *
22
+ * @return CacheAdapterInterface
23
+ * @throws InvalidArgumentException
24
+ */
25
+ public static function fromCache($cache)
26
+ {
27
+ if (!is_object($cache)) {
28
+ throw new InvalidArgumentException('Cache must be one of the known cache objects');
29
+ }
30
+
31
+ if ($cache instanceof CacheAdapterInterface) {
32
+ return $cache;
33
+ } elseif ($cache instanceof Cache) {
34
+ return new DoctrineCacheAdapter($cache);
35
+ } elseif ($cache instanceof StorageInterface) {
36
+ return new Zf2CacheAdapter($cache);
37
+ } else {
38
+ throw new InvalidArgumentException('Unknown cache type: ' . get_class($cache));
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Create a Guzzle cache adapter based on an array of options
44
+ *
45
+ * @param array $config Array of configuration options
46
+ *
47
+ * @return CacheAdapterInterface
48
+ * @throws InvalidArgumentException
49
+ * @deprecated This will be removed in a future version
50
+ * @codeCoverageIgnore
51
+ */
52
+ public static function factory($config = array())
53
+ {
54
+ Version::warn(__METHOD__ . ' is deprecated');
55
+ if (!is_array($config)) {
56
+ throw new InvalidArgumentException('$config must be an array');
57
+ }
58
+
59
+ if (!isset($config['cache.adapter']) && !isset($config['cache.provider'])) {
60
+ $config['cache.adapter'] = 'Guzzle\Cache\NullCacheAdapter';
61
+ $config['cache.provider'] = null;
62
+ } else {
63
+ // Validate that the options are valid
64
+ foreach (array('cache.adapter', 'cache.provider') as $required) {
65
+ if (!isset($config[$required])) {
66
+ throw new InvalidArgumentException("{$required} is a required CacheAdapterFactory option");
67
+ }
68
+ if (is_string($config[$required])) {
69
+ // Convert dot notation to namespaces
70
+ $config[$required] = str_replace('.', '\\', $config[$required]);
71
+ if (!class_exists($config[$required])) {
72
+ throw new InvalidArgumentException("{$config[$required]} is not a valid class for {$required}");
73
+ }
74
+ }
75
+ }
76
+ // Instantiate the cache provider
77
+ if (is_string($config['cache.provider'])) {
78
+ $args = isset($config['cache.provider.args']) ? $config['cache.provider.args'] : null;
79
+ $config['cache.provider'] = self::createObject($config['cache.provider'], $args);
80
+ }
81
+ }
82
+
83
+ // Instantiate the cache adapter using the provider and options
84
+ if (is_string($config['cache.adapter'])) {
85
+ $args = isset($config['cache.adapter.args']) ? $config['cache.adapter.args'] : array();
86
+ array_unshift($args, $config['cache.provider']);
87
+ $config['cache.adapter'] = self::createObject($config['cache.adapter'], $args);
88
+ }
89
+
90
+ return $config['cache.adapter'];
91
+ }
92
+
93
+ /**
94
+ * Create a class using an array of constructor arguments
95
+ *
96
+ * @param string $className Class name
97
+ * @param array $args Arguments for the class constructor
98
+ *
99
+ * @return mixed
100
+ * @throws RuntimeException
101
+ * @deprecated
102
+ * @codeCoverageIgnore
103
+ */
104
+ private static function createObject($className, array $args = null)
105
+ {
106
+ try {
107
+ if (!$args) {
108
+ return new $className;
109
+ } else {
110
+ $c = new \ReflectionClass($className);
111
+ return $c->newInstanceArgs($args);
112
+ }
113
+ } catch (\Exception $e) {
114
+ throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
115
+ }
116
+ }
117
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/CacheAdapterInterface.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ /**
6
+ * Interface for cache adapters.
7
+ *
8
+ * Cache adapters allow Guzzle to utilize various frameworks for caching HTTP responses.
9
+ *
10
+ * @link http://www.doctrine-project.org/ Inspired by Doctrine 2
11
+ */
12
+ interface CacheAdapterInterface
13
+ {
14
+ /**
15
+ * Test if an entry exists in the cache.
16
+ *
17
+ * @param string $id cache id The cache id of the entry to check for.
18
+ * @param array $options Array of cache adapter options
19
+ *
20
+ * @return bool Returns TRUE if a cache entry exists for the given cache id, FALSE otherwise.
21
+ */
22
+ public function contains($id, array $options = null);
23
+
24
+ /**
25
+ * Deletes a cache entry.
26
+ *
27
+ * @param string $id cache id
28
+ * @param array $options Array of cache adapter options
29
+ *
30
+ * @return bool TRUE on success, FALSE on failure
31
+ */
32
+ public function delete($id, array $options = null);
33
+
34
+ /**
35
+ * Fetches an entry from the cache.
36
+ *
37
+ * @param string $id cache id The id of the cache entry to fetch.
38
+ * @param array $options Array of cache adapter options
39
+ *
40
+ * @return string The cached data or FALSE, if no cache entry exists for the given id.
41
+ */
42
+ public function fetch($id, array $options = null);
43
+
44
+ /**
45
+ * Puts data into the cache.
46
+ *
47
+ * @param string $id The cache id
48
+ * @param string $data The cache entry/data
49
+ * @param int|bool $lifeTime The lifetime. If != false, sets a specific lifetime for this cache entry
50
+ * @param array $options Array of cache adapter options
51
+ *
52
+ * @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
53
+ */
54
+ public function save($id, $data, $lifeTime = false, array $options = null);
55
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/ClosureCacheAdapter.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ /**
6
+ * Cache adapter that defers to closures for implementation
7
+ */
8
+ class ClosureCacheAdapter implements CacheAdapterInterface
9
+ {
10
+ /**
11
+ * @var array Mapping of method names to callables
12
+ */
13
+ protected $callables;
14
+
15
+ /**
16
+ * The callables array is an array mapping the actions of the cache adapter to callables.
17
+ * - contains: Callable that accepts an $id and $options argument
18
+ * - delete: Callable that accepts an $id and $options argument
19
+ * - fetch: Callable that accepts an $id and $options argument
20
+ * - save: Callable that accepts an $id, $data, $lifeTime, and $options argument
21
+ *
22
+ * @param array $callables array of action names to callable
23
+ *
24
+ * @throws \InvalidArgumentException if the callable is not callable
25
+ */
26
+ public function __construct(array $callables)
27
+ {
28
+ // Validate each key to ensure it exists and is callable
29
+ foreach (array('contains', 'delete', 'fetch', 'save') as $key) {
30
+ if (!array_key_exists($key, $callables) || !is_callable($callables[$key])) {
31
+ throw new \InvalidArgumentException("callables must contain a callable {$key} key");
32
+ }
33
+ }
34
+
35
+ $this->callables = $callables;
36
+ }
37
+
38
+ public function contains($id, array $options = null)
39
+ {
40
+ return call_user_func($this->callables['contains'], $id, $options);
41
+ }
42
+
43
+ public function delete($id, array $options = null)
44
+ {
45
+ return call_user_func($this->callables['delete'], $id, $options);
46
+ }
47
+
48
+ public function fetch($id, array $options = null)
49
+ {
50
+ return call_user_func($this->callables['fetch'], $id, $options);
51
+ }
52
+
53
+ public function save($id, $data, $lifeTime = false, array $options = null)
54
+ {
55
+ return call_user_func($this->callables['save'], $id, $data, $lifeTime, $options);
56
+ }
57
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/DoctrineCacheAdapter.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ use Doctrine\Common\Cache\Cache;
6
+
7
+ /**
8
+ * Doctrine 2 cache adapter
9
+ *
10
+ * @link http://www.doctrine-project.org/
11
+ */
12
+ class DoctrineCacheAdapter extends AbstractCacheAdapter
13
+ {
14
+ /**
15
+ * @param Cache $cache Doctrine cache object
16
+ */
17
+ public function __construct(Cache $cache)
18
+ {
19
+ $this->cache = $cache;
20
+ }
21
+
22
+ public function contains($id, array $options = null)
23
+ {
24
+ return $this->cache->contains($id);
25
+ }
26
+
27
+ public function delete($id, array $options = null)
28
+ {
29
+ return $this->cache->delete($id);
30
+ }
31
+
32
+ public function fetch($id, array $options = null)
33
+ {
34
+ return $this->cache->fetch($id);
35
+ }
36
+
37
+ public function save($id, $data, $lifeTime = false, array $options = null)
38
+ {
39
+ return $this->cache->save($id, $data, $lifeTime !== false ? $lifeTime : 0);
40
+ }
41
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/NullCacheAdapter.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ /**
6
+ * Null cache adapter
7
+ */
8
+ class NullCacheAdapter extends AbstractCacheAdapter
9
+ {
10
+ public function __construct() {}
11
+
12
+ public function contains($id, array $options = null)
13
+ {
14
+ return false;
15
+ }
16
+
17
+ public function delete($id, array $options = null)
18
+ {
19
+ return true;
20
+ }
21
+
22
+ public function fetch($id, array $options = null)
23
+ {
24
+ return false;
25
+ }
26
+
27
+ public function save($id, $data, $lifeTime = false, array $options = null)
28
+ {
29
+ return true;
30
+ }
31
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/Zf1CacheAdapter.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ use Guzzle\Common\Version;
6
+
7
+ /**
8
+ * Zend Framework 1 cache adapter
9
+ *
10
+ * @link http://framework.zend.com/manual/en/zend.cache.html
11
+ * @deprecated
12
+ * @codeCoverageIgnore
13
+ */
14
+ class Zf1CacheAdapter extends AbstractCacheAdapter
15
+ {
16
+ /**
17
+ * @param \Zend_Cache_Backend $cache Cache object to wrap
18
+ */
19
+ public function __construct(\Zend_Cache_Backend $cache)
20
+ {
21
+ Version::warn(__CLASS__ . ' is deprecated. Upgrade to ZF2 or use PsrCacheAdapter');
22
+ $this->cache = $cache;
23
+ }
24
+
25
+ public function contains($id, array $options = null)
26
+ {
27
+ return $this->cache->test($id);
28
+ }
29
+
30
+ public function delete($id, array $options = null)
31
+ {
32
+ return $this->cache->remove($id);
33
+ }
34
+
35
+ public function fetch($id, array $options = null)
36
+ {
37
+ return $this->cache->load($id);
38
+ }
39
+
40
+ public function save($id, $data, $lifeTime = false, array $options = null)
41
+ {
42
+ return $this->cache->save($data, $id, array(), $lifeTime);
43
+ }
44
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Cache/Zf2CacheAdapter.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Cache;
4
+
5
+ use Zend\Cache\Storage\StorageInterface;
6
+
7
+ /**
8
+ * Zend Framework 2 cache adapter
9
+ *
10
+ * @link http://packages.zendframework.com/docs/latest/manual/en/zend.cache.html
11
+ */
12
+ class Zf2CacheAdapter extends AbstractCacheAdapter
13
+ {
14
+ /**
15
+ * @param StorageInterface $cache Zend Framework 2 cache adapter
16
+ */
17
+ public function __construct(StorageInterface $cache)
18
+ {
19
+ $this->cache = $cache;
20
+ }
21
+
22
+ public function contains($id, array $options = null)
23
+ {
24
+ return $this->cache->hasItem($id);
25
+ }
26
+
27
+ public function delete($id, array $options = null)
28
+ {
29
+ return $this->cache->removeItem($id);
30
+ }
31
+
32
+ public function fetch($id, array $options = null)
33
+ {
34
+ return $this->cache->getItem($id);
35
+ }
36
+
37
+ public function save($id, $data, $lifeTime = false, array $options = null)
38
+ {
39
+ return $this->cache->setItem($id, $data);
40
+ }
41
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/AbstractHasDispatcher.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common;
4
+
5
+ use Symfony\Component\EventDispatcher\EventDispatcher;
6
+ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
7
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
+
9
+ /**
10
+ * Class that holds an event dispatcher
11
+ */
12
+ class AbstractHasDispatcher implements HasDispatcherInterface
13
+ {
14
+ /** @var EventDispatcherInterface */
15
+ protected $eventDispatcher;
16
+
17
+ public static function getAllEvents()
18
+ {
19
+ return array();
20
+ }
21
+
22
+ public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
23
+ {
24
+ $this->eventDispatcher = $eventDispatcher;
25
+
26
+ return $this;
27
+ }
28
+
29
+ public function getEventDispatcher()
30
+ {
31
+ if (!$this->eventDispatcher) {
32
+ $this->eventDispatcher = new EventDispatcher();
33
+ }
34
+
35
+ return $this->eventDispatcher;
36
+ }
37
+
38
+ public function dispatch($eventName, array $context = array())
39
+ {
40
+ return $this->getEventDispatcher()->dispatch($eventName, new Event($context));
41
+ }
42
+
43
+ public function addSubscriber(EventSubscriberInterface $subscriber)
44
+ {
45
+ $this->getEventDispatcher()->addSubscriber($subscriber);
46
+
47
+ return $this;
48
+ }
49
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Collection.php ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common;
4
+
5
+ use Guzzle\Common\Exception\InvalidArgumentException;
6
+ use Guzzle\Common\Exception\RuntimeException;
7
+
8
+ /**
9
+ * Key value pair collection object
10
+ */
11
+ class Collection implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInterface
12
+ {
13
+ /** @var array Data associated with the object. */
14
+ protected $data;
15
+
16
+ /**
17
+ * @param array $data Associative array of data to set
18
+ */
19
+ public function __construct(array $data = array())
20
+ {
21
+ $this->data = $data;
22
+ }
23
+
24
+ /**
25
+ * Create a new collection from an array, validate the keys, and add default values where missing
26
+ *
27
+ * @param array $config Configuration values to apply.
28
+ * @param array $defaults Default parameters
29
+ * @param array $required Required parameter names
30
+ *
31
+ * @return self
32
+ * @throws InvalidArgumentException if a parameter is missing
33
+ */
34
+ public static function fromConfig(array $config = array(), array $defaults = array(), array $required = array())
35
+ {
36
+ $data = $config + $defaults;
37
+
38
+ if ($missing = array_diff($required, array_keys($data))) {
39
+ throw new InvalidArgumentException('Config is missing the following keys: ' . implode(', ', $missing));
40
+ }
41
+
42
+ return new self($data);
43
+ }
44
+
45
+ public function count()
46
+ {
47
+ return count($this->data);
48
+ }
49
+
50
+ public function getIterator()
51
+ {
52
+ return new \ArrayIterator($this->data);
53
+ }
54
+
55
+ public function toArray()
56
+ {
57
+ return $this->data;
58
+ }
59
+
60
+ /**
61
+ * Removes all key value pairs
62
+ *
63
+ * @return Collection
64
+ */
65
+ public function clear()
66
+ {
67
+ $this->data = array();
68
+
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Get all or a subset of matching key value pairs
74
+ *
75
+ * @param array $keys Pass an array of keys to retrieve only a subset of key value pairs
76
+ *
77
+ * @return array Returns an array of all matching key value pairs
78
+ */
79
+ public function getAll(array $keys = null)
80
+ {
81
+ return $keys ? array_intersect_key($this->data, array_flip($keys)) : $this->data;
82
+ }
83
+
84
+ /**
85
+ * Get a specific key value.
86
+ *
87
+ * @param string $key Key to retrieve.
88
+ *
89
+ * @return mixed|null Value of the key or NULL
90
+ */
91
+ public function get($key)
92
+ {
93
+ return isset($this->data[$key]) ? $this->data[$key] : null;
94
+ }
95
+
96
+ /**
97
+ * Set a key value pair
98
+ *
99
+ * @param string $key Key to set
100
+ * @param mixed $value Value to set
101
+ *
102
+ * @return Collection Returns a reference to the object
103
+ */
104
+ public function set($key, $value)
105
+ {
106
+ $this->data[$key] = $value;
107
+
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * Add a value to a key. If a key of the same name has already been added, the key value will be converted into an
113
+ * array and the new value will be pushed to the end of the array.
114
+ *
115
+ * @param string $key Key to add
116
+ * @param mixed $value Value to add to the key
117
+ *
118
+ * @return Collection Returns a reference to the object.
119
+ */
120
+ public function add($key, $value)
121
+ {
122
+ if (!array_key_exists($key, $this->data)) {
123
+ $this->data[$key] = $value;
124
+ } elseif (is_array($this->data[$key])) {
125
+ $this->data[$key][] = $value;
126
+ } else {
127
+ $this->data[$key] = array($this->data[$key], $value);
128
+ }
129
+
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Remove a specific key value pair
135
+ *
136
+ * @param string $key A key to remove
137
+ *
138
+ * @return Collection
139
+ */
140
+ public function remove($key)
141
+ {
142
+ unset($this->data[$key]);
143
+
144
+ return $this;
145
+ }
146
+
147
+ /**
148
+ * Get all keys in the collection
149
+ *
150
+ * @return array
151
+ */
152
+ public function getKeys()
153
+ {
154
+ return array_keys($this->data);
155
+ }
156
+
157
+ /**
158
+ * Returns whether or not the specified key is present.
159
+ *
160
+ * @param string $key The key for which to check the existence.
161
+ *
162
+ * @return bool
163
+ */
164
+ public function hasKey($key)
165
+ {
166
+ return array_key_exists($key, $this->data);
167
+ }
168
+
169
+ /**
170
+ * Case insensitive search the keys in the collection
171
+ *
172
+ * @param string $key Key to search for
173
+ *
174
+ * @return bool|string Returns false if not found, otherwise returns the key
175
+ */
176
+ public function keySearch($key)
177
+ {
178
+ foreach (array_keys($this->data) as $k) {
179
+ if (!strcasecmp($k, $key)) {
180
+ return $k;
181
+ }
182
+ }
183
+
184
+ return false;
185
+ }
186
+
187
+ /**
188
+ * Checks if any keys contains a certain value
189
+ *
190
+ * @param string $value Value to search for
191
+ *
192
+ * @return mixed Returns the key if the value was found FALSE if the value was not found.
193
+ */
194
+ public function hasValue($value)
195
+ {
196
+ return array_search($value, $this->data);
197
+ }
198
+
199
+ /**
200
+ * Replace the data of the object with the value of an array
201
+ *
202
+ * @param array $data Associative array of data
203
+ *
204
+ * @return Collection Returns a reference to the object
205
+ */
206
+ public function replace(array $data)
207
+ {
208
+ $this->data = $data;
209
+
210
+ return $this;
211
+ }
212
+
213
+ /**
214
+ * Add and merge in a Collection or array of key value pair data.
215
+ *
216
+ * @param Collection|array $data Associative array of key value pair data
217
+ *
218
+ * @return Collection Returns a reference to the object.
219
+ */
220
+ public function merge($data)
221
+ {
222
+ foreach ($data as $key => $value) {
223
+ $this->add($key, $value);
224
+ }
225
+
226
+ return $this;
227
+ }
228
+
229
+ /**
230
+ * Over write key value pairs in this collection with all of the data from an array or collection.
231
+ *
232
+ * @param array|\Traversable $data Values to override over this config
233
+ *
234
+ * @return self
235
+ */
236
+ public function overwriteWith($data)
237
+ {
238
+ if (is_array($data)) {
239
+ $this->data = $data + $this->data;
240
+ } elseif ($data instanceof Collection) {
241
+ $this->data = $data->toArray() + $this->data;
242
+ } else {
243
+ foreach ($data as $key => $value) {
244
+ $this->data[$key] = $value;
245
+ }
246
+ }
247
+
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * Returns a Collection containing all the elements of the collection after applying the callback function to each
253
+ * one. The Closure should accept three parameters: (string) $key, (string) $value, (array) $context and return a
254
+ * modified value
255
+ *
256
+ * @param \Closure $closure Closure to apply
257
+ * @param array $context Context to pass to the closure
258
+ * @param bool $static Set to TRUE to use the same class as the return rather than returning a Collection
259
+ *
260
+ * @return Collection
261
+ */
262
+ public function map(\Closure $closure, array $context = array(), $static = true)
263
+ {
264
+ $collection = $static ? new static() : new self();
265
+ foreach ($this as $key => $value) {
266
+ $collection->add($key, $closure($key, $value, $context));
267
+ }
268
+
269
+ return $collection;
270
+ }
271
+
272
+ /**
273
+ * Iterates over each key value pair in the collection passing them to the Closure. If the Closure function returns
274
+ * true, the current value from input is returned into the result Collection. The Closure must accept three
275
+ * parameters: (string) $key, (string) $value and return Boolean TRUE or FALSE for each value.
276
+ *
277
+ * @param \Closure $closure Closure evaluation function
278
+ * @param bool $static Set to TRUE to use the same class as the return rather than returning a Collection
279
+ *
280
+ * @return Collection
281
+ */
282
+ public function filter(\Closure $closure, $static = true)
283
+ {
284
+ $collection = ($static) ? new static() : new self();
285
+ foreach ($this->data as $key => $value) {
286
+ if ($closure($key, $value)) {
287
+ $collection->add($key, $value);
288
+ }
289
+ }
290
+
291
+ return $collection;
292
+ }
293
+
294
+ public function offsetExists($offset)
295
+ {
296
+ return isset($this->data[$offset]);
297
+ }
298
+
299
+ public function offsetGet($offset)
300
+ {
301
+ return isset($this->data[$offset]) ? $this->data[$offset] : null;
302
+ }
303
+
304
+ public function offsetSet($offset, $value)
305
+ {
306
+ $this->data[$offset] = $value;
307
+ }
308
+
309
+ public function offsetUnset($offset)
310
+ {
311
+ unset($this->data[$offset]);
312
+ }
313
+
314
+ /**
315
+ * Set a value into a nested array key. Keys will be created as needed to set the value.
316
+ *
317
+ * @param string $path Path to set
318
+ * @param mixed $value Value to set at the key
319
+ *
320
+ * @return self
321
+ * @throws RuntimeException when trying to setPath using a nested path that travels through a scalar value
322
+ */
323
+ public function setPath($path, $value)
324
+ {
325
+ $current =& $this->data;
326
+ $queue = explode('/', $path);
327
+ while (null !== ($key = array_shift($queue))) {
328
+ if (!is_array($current)) {
329
+ throw new RuntimeException("Trying to setPath {$path}, but {$key} is set and is not an array");
330
+ } elseif (!$queue) {
331
+ $current[$key] = $value;
332
+ } elseif (isset($current[$key])) {
333
+ $current =& $current[$key];
334
+ } else {
335
+ $current[$key] = array();
336
+ $current =& $current[$key];
337
+ }
338
+ }
339
+
340
+ return $this;
341
+ }
342
+
343
+ /**
344
+ * Gets a value from the collection using an array path (e.g. foo/baz/bar would retrieve bar from two nested arrays)
345
+ * Allows for wildcard searches which recursively combine matches up to the level at which the wildcard occurs. This
346
+ * can be useful for accepting any key of a sub-array and combining matching keys from each diverging path.
347
+ *
348
+ * @param string $path Path to traverse and retrieve a value from
349
+ * @param string $separator Character used to add depth to the search
350
+ * @param mixed $data Optional data to descend into (used when wildcards are encountered)
351
+ *
352
+ * @return mixed|null
353
+ */
354
+ public function getPath($path, $separator = '/', $data = null)
355
+ {
356
+ if ($data === null) {
357
+ $data =& $this->data;
358
+ }
359
+
360
+ $path = is_array($path) ? $path : explode($separator, $path);
361
+ while (null !== ($part = array_shift($path))) {
362
+ if (!is_array($data)) {
363
+ return null;
364
+ } elseif (isset($data[$part])) {
365
+ $data =& $data[$part];
366
+ } elseif ($part != '*') {
367
+ return null;
368
+ } else {
369
+ // Perform a wildcard search by diverging and merging paths
370
+ $result = array();
371
+ foreach ($data as $value) {
372
+ if (!$path) {
373
+ $result = array_merge_recursive($result, (array) $value);
374
+ } elseif (null !== ($test = $this->getPath($path, $separator, $value))) {
375
+ $result = array_merge_recursive($result, (array) $test);
376
+ }
377
+ }
378
+ return $result;
379
+ }
380
+ }
381
+
382
+ return $data;
383
+ }
384
+
385
+ /**
386
+ * Inject configuration settings into an input string
387
+ *
388
+ * @param string $input Input to inject
389
+ *
390
+ * @return string
391
+ * @deprecated
392
+ */
393
+ public function inject($input)
394
+ {
395
+ Version::warn(__METHOD__ . ' is deprecated');
396
+ $replace = array();
397
+ foreach ($this->data as $key => $val) {
398
+ $replace['{' . $key . '}'] = $val;
399
+ }
400
+
401
+ return strtr($input, $replace);
402
+ }
403
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Event.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common;
4
+
5
+ use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
6
+
7
+ /**
8
+ * Default event for Guzzle notifications
9
+ */
10
+ class Event extends SymfonyEvent implements ToArrayInterface, \ArrayAccess, \IteratorAggregate
11
+ {
12
+ /** @var array */
13
+ private $context;
14
+
15
+ /**
16
+ * @param array $context Contextual information
17
+ */
18
+ public function __construct(array $context = array())
19
+ {
20
+ $this->context = $context;
21
+ }
22
+
23
+ public function getIterator()
24
+ {
25
+ return new \ArrayIterator($this->context);
26
+ }
27
+
28
+ public function offsetGet($offset)
29
+ {
30
+ return isset($this->context[$offset]) ? $this->context[$offset] : null;
31
+ }
32
+
33
+ public function offsetSet($offset, $value)
34
+ {
35
+ $this->context[$offset] = $value;
36
+ }
37
+
38
+ public function offsetExists($offset)
39
+ {
40
+ return isset($this->context[$offset]);
41
+ }
42
+
43
+ public function offsetUnset($offset)
44
+ {
45
+ unset($this->context[$offset]);
46
+ }
47
+
48
+ public function toArray()
49
+ {
50
+ return $this->context;
51
+ }
52
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/BadMethodCallException.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common\Exception;
4
+
5
+ class BadMethodCallException extends \BadMethodCallException implements GuzzleException {}
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/ExceptionCollection.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common\Exception;
4
+
5
+ /**
6
+ * Collection of exceptions
7
+ */
8
+ class ExceptionCollection extends \Exception implements GuzzleException, \IteratorAggregate, \Countable
9
+ {
10
+ /** @var array Array of Exceptions */
11
+ protected $exceptions = array();
12
+
13
+ /** @var string Succinct exception message not including sub-exceptions */
14
+ private $shortMessage;
15
+
16
+ public function __construct($message = '', $code = 0, \Exception $previous = null)
17
+ {
18
+ parent::__construct($message, $code, $previous);
19
+ $this->shortMessage = $message;
20
+ }
21
+
22
+ /**
23
+ * Set all of the exceptions
24
+ *
25
+ * @param array $exceptions Array of exceptions
26
+ *
27
+ * @return self
28
+ */
29
+ public function setExceptions(array $exceptions)
30
+ {
31
+ $this->exceptions = array();
32
+ foreach ($exceptions as $exception) {
33
+ $this->add($exception);
34
+ }
35
+
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Add exceptions to the collection
41
+ *
42
+ * @param ExceptionCollection|\Exception $e Exception to add
43
+ *
44
+ * @return ExceptionCollection;
45
+ */
46
+ public function add($e)
47
+ {
48
+ $this->exceptions[] = $e;
49
+ if ($this->message) {
50
+ $this->message .= "\n";
51
+ }
52
+
53
+ $this->message .= $this->getExceptionMessage($e, 0);
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Get the total number of request exceptions
60
+ *
61
+ * @return int
62
+ */
63
+ public function count()
64
+ {
65
+ return count($this->exceptions);
66
+ }
67
+
68
+ /**
69
+ * Allows array-like iteration over the request exceptions
70
+ *
71
+ * @return \ArrayIterator
72
+ */
73
+ public function getIterator()
74
+ {
75
+ return new \ArrayIterator($this->exceptions);
76
+ }
77
+
78
+ /**
79
+ * Get the first exception in the collection
80
+ *
81
+ * @return \Exception
82
+ */
83
+ public function getFirst()
84
+ {
85
+ return $this->exceptions ? $this->exceptions[0] : null;
86
+ }
87
+
88
+ private function getExceptionMessage(\Exception $e, $depth = 0)
89
+ {
90
+ static $sp = ' ';
91
+ $prefix = $depth ? str_repeat($sp, $depth) : '';
92
+ $message = "{$prefix}(" . get_class($e) . ') ' . $e->getFile() . ' line ' . $e->getLine() . "\n";
93
+
94
+ if ($e instanceof self) {
95
+ if ($e->shortMessage) {
96
+ $message .= "\n{$prefix}{$sp}" . str_replace("\n", "\n{$prefix}{$sp}", $e->shortMessage) . "\n";
97
+ }
98
+ foreach ($e as $ee) {
99
+ $message .= "\n" . $this->getExceptionMessage($ee, $depth + 1);
100
+ }
101
+ } else {
102
+ $message .= "\n{$prefix}{$sp}" . str_replace("\n", "\n{$prefix}{$sp}", $e->getMessage()) . "\n";
103
+ $message .= "\n{$prefix}{$sp}" . str_replace("\n", "\n{$prefix}{$sp}", $e->getTraceAsString()) . "\n";
104
+ }
105
+
106
+ return str_replace(getcwd(), '.', $message);
107
+ }
108
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/GuzzleException.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common\Exception;
4
+
5
+ /**
6
+ * Guzzle exception
7
+ */
8
+ interface GuzzleException {}
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/InvalidArgumentException.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common\Exception;
4
+
5
+ class InvalidArgumentException extends \InvalidArgumentException implements GuzzleException {}
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/RuntimeException.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common\Exception;
4
+
5
+ class RuntimeException extends \RuntimeException implements GuzzleException {}
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Exception/UnexpectedValueException.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common\Exception;
4
+
5
+ class UnexpectedValueException extends \UnexpectedValueException implements GuzzleException {}
lib/amazon/guzzle/guzzle/src/Guzzle/Common/FromConfigInterface.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common;
4
+
5
+ /**
6
+ * Interfaces that adds a factory method which is used to instantiate a class from an array of configuration options.
7
+ */
8
+ interface FromConfigInterface
9
+ {
10
+ /**
11
+ * Static factory method used to turn an array or collection of configuration data into an instantiated object.
12
+ *
13
+ * @param array|Collection $config Configuration data
14
+ *
15
+ * @return FromConfigInterface
16
+ */
17
+ public static function factory($config = array());
18
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/HasDispatcherInterface.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common;
4
+
5
+ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
6
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7
+
8
+ /**
9
+ * Holds an event dispatcher
10
+ */
11
+ interface HasDispatcherInterface
12
+ {
13
+ /**
14
+ * Get a list of all of the events emitted from the class
15
+ *
16
+ * @return array
17
+ */
18
+ public static function getAllEvents();
19
+
20
+ /**
21
+ * Set the EventDispatcher of the request
22
+ *
23
+ * @param EventDispatcherInterface $eventDispatcher
24
+ *
25
+ * @return self
26
+ */
27
+ public function setEventDispatcher(EventDispatcherInterface $eventDispatcher);
28
+
29
+ /**
30
+ * Get the EventDispatcher of the request
31
+ *
32
+ * @return EventDispatcherInterface
33
+ */
34
+ public function getEventDispatcher();
35
+
36
+ /**
37
+ * Helper to dispatch Guzzle events and set the event name on the event
38
+ *
39
+ * @param string $eventName Name of the event to dispatch
40
+ * @param array $context Context of the event
41
+ *
42
+ * @return Event Returns the created event object
43
+ */
44
+ public function dispatch($eventName, array $context = array());
45
+
46
+ /**
47
+ * Add an event subscriber to the dispatcher
48
+ *
49
+ * @param EventSubscriberInterface $subscriber Event subscriber
50
+ *
51
+ * @return self
52
+ */
53
+ public function addSubscriber(EventSubscriberInterface $subscriber);
54
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/ToArrayInterface.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common;
4
+
5
+ /**
6
+ * An object that can be represented as an array
7
+ */
8
+ interface ToArrayInterface
9
+ {
10
+ /**
11
+ * Get the array representation of an object
12
+ *
13
+ * @return array
14
+ */
15
+ public function toArray();
16
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Common/Version.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Common;
4
+
5
+ /**
6
+ * Guzzle version information
7
+ */
8
+ class Version
9
+ {
10
+ const VERSION = '3.9.3';
11
+
12
+ /**
13
+ * @var bool Set this value to true to enable warnings for deprecated functionality use. This should be on in your
14
+ * unit tests, but probably not in production.
15
+ */
16
+ public static $emitWarnings = false;
17
+
18
+ /**
19
+ * Emit a deprecation warning
20
+ *
21
+ * @param string $message Warning message
22
+ */
23
+ public static function warn($message)
24
+ {
25
+ if (self::$emitWarnings) {
26
+ trigger_error('Deprecation warning: ' . $message, E_USER_DEPRECATED);
27
+ }
28
+ }
29
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Http/AbstractEntityBodyDecorator.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Http;
4
+
5
+ use Guzzle\Stream\Stream;
6
+
7
+ /**
8
+ * Abstract decorator used to wrap entity bodies
9
+ */
10
+ class AbstractEntityBodyDecorator implements EntityBodyInterface
11
+ {
12
+ /** @var EntityBodyInterface Decorated entity body */
13
+ protected $body;
14
+
15
+ /**
16
+ * @param EntityBodyInterface $body Entity body to decorate
17
+ */
18
+ public function __construct(EntityBodyInterface $body)
19
+ {
20
+ $this->body = $body;
21
+ }
22
+
23
+ public function __toString()
24
+ {
25
+ return (string) $this->body;
26
+ }
27
+
28
+ /**
29
+ * Allow decorators to implement custom methods
30
+ *
31
+ * @param string $method Missing method name
32
+ * @param array $args Method arguments
33
+ *
34
+ * @return mixed
35
+ */
36
+ public function __call($method, array $args)
37
+ {
38
+ return call_user_func_array(array($this->body, $method), $args);
39
+ }
40
+
41
+ public function close()
42
+ {
43
+ return $this->body->close();
44
+ }
45
+
46
+ public function setRewindFunction($callable)
47
+ {
48
+ $this->body->setRewindFunction($callable);
49
+
50
+ return $this;
51
+ }
52
+
53
+ public function rewind()
54
+ {
55
+ return $this->body->rewind();
56
+ }
57
+
58
+ public function compress($filter = 'zlib.deflate')
59
+ {
60
+ return $this->body->compress($filter);
61
+ }
62
+
63
+ public function uncompress($filter = 'zlib.inflate')
64
+ {
65
+ return $this->body->uncompress($filter);
66
+ }
67
+
68
+ public function getContentLength()
69
+ {
70
+ return $this->getSize();
71
+ }
72
+
73
+ public function getContentType()
74
+ {
75
+ return $this->body->getContentType();
76
+ }
77
+
78
+ public function getContentMd5($rawOutput = false, $base64Encode = false)
79
+ {
80
+ $hash = Stream::getHash($this, 'md5', $rawOutput);
81
+
82
+ return $hash && $base64Encode ? base64_encode($hash) : $hash;
83
+ }
84
+
85
+ public function getContentEncoding()
86
+ {
87
+ return $this->body->getContentEncoding();
88
+ }
89
+
90
+ public function getMetaData($key = null)
91
+ {
92
+ return $this->body->getMetaData($key);
93
+ }
94
+
95
+ public function getStream()
96
+ {
97
+ return $this->body->getStream();
98
+ }
99
+
100
+ public function setStream($stream, $size = 0)
101
+ {
102
+ $this->body->setStream($stream, $size);
103
+
104
+ return $this;
105
+ }
106
+
107
+ public function detachStream()
108
+ {
109
+ $this->body->detachStream();
110
+
111
+ return $this;
112
+ }
113
+
114
+ public function getWrapper()
115
+ {
116
+ return $this->body->getWrapper();
117
+ }
118
+
119
+ public function getWrapperData()
120
+ {
121
+ return $this->body->getWrapperData();
122
+ }
123
+
124
+ public function getStreamType()
125
+ {
126
+ return $this->body->getStreamType();
127
+ }
128
+
129
+ public function getUri()
130
+ {
131
+ return $this->body->getUri();
132
+ }
133
+
134
+ public function getSize()
135
+ {
136
+ return $this->body->getSize();
137
+ }
138
+
139
+ public function isReadable()
140
+ {
141
+ return $this->body->isReadable();
142
+ }
143
+
144
+ public function isRepeatable()
145
+ {
146
+ return $this->isSeekable() && $this->isReadable();
147
+ }
148
+
149
+ public function isWritable()
150
+ {
151
+ return $this->body->isWritable();
152
+ }
153
+
154
+ public function isConsumed()
155
+ {
156
+ return $this->body->isConsumed();
157
+ }
158
+
159
+ /**
160
+ * Alias of isConsumed()
161
+ * {@inheritdoc}
162
+ */
163
+ public function feof()
164
+ {
165
+ return $this->isConsumed();
166
+ }
167
+
168
+ public function isLocal()
169
+ {
170
+ return $this->body->isLocal();
171
+ }
172
+
173
+ public function isSeekable()
174
+ {
175
+ return $this->body->isSeekable();
176
+ }
177
+
178
+ public function setSize($size)
179
+ {
180
+ $this->body->setSize($size);
181
+
182
+ return $this;
183
+ }
184
+
185
+ public function seek($offset, $whence = SEEK_SET)
186
+ {
187
+ return $this->body->seek($offset, $whence);
188
+ }
189
+
190
+ public function read($length)
191
+ {
192
+ return $this->body->read($length);
193
+ }
194
+
195
+ public function write($string)
196
+ {
197
+ return $this->body->write($string);
198
+ }
199
+
200
+ public function readLine($maxLength = null)
201
+ {
202
+ return $this->body->readLine($maxLength);
203
+ }
204
+
205
+ public function ftell()
206
+ {
207
+ return $this->body->ftell();
208
+ }
209
+
210
+ public function getCustomData($key)
211
+ {
212
+ return $this->body->getCustomData($key);
213
+ }
214
+
215
+ public function setCustomData($key, $value)
216
+ {
217
+ $this->body->setCustomData($key, $value);
218
+
219
+ return $this;
220
+ }
221
+ }
lib/amazon/guzzle/guzzle/src/Guzzle/Http/CachingEntityBody.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Guzzle\Http;
4
+
5
+ use Guzzle\Common\Exception\RuntimeException;
6
+
7
+ /**
8
+ * EntityBody decorator that can cache previously read bytes from a sequentially read tstream
9
+ */
10
+ class CachingEntityBody extends AbstractEntityBodyDecorator
11
+ {
12
+ /** @var EntityBody Remote stream used to actually pull data onto the buffer */
13
+ protected $remoteStream;
14
+
15
+ /** @var int The number of bytes to skip reading due to a write on the temporary buffer */
16
+ protected $skipReadBytes = 0;
17
+
18
+ /**
19
+ * We will treat the buffer object as the body of the entity body
20
+ * {@inheritdoc}
21
+ */
22
+ public function __cons