Exemple #1
0
 /**
  * @param array|Collection   $parameters Collection of parameters to set on the command
  * @param OperationInterface $operation Command definition from description
  */
 public function __construct($parameters = array(), OperationInterface $operation = null)
 {
     parent::__construct($parameters);
     $this->operation = $operation ?: $this->createOperation();
     foreach ($this->operation->getParams() as $name => $arg) {
         $currentValue = $this[$name];
         $configValue = $arg->getValue($currentValue);
         // If default or static values are set, then this should always be updated on the config object
         if ($currentValue !== $configValue) {
             $this[$name] = $configValue;
         }
     }
     $headers = $this[self::HEADERS_OPTION];
     if (!$headers instanceof Collection) {
         $this[self::HEADERS_OPTION] = new Collection((array) $headers);
     }
     // You can set a command.on_complete option in your parameters to set an onComplete callback
     if ($onComplete = $this['command.on_complete']) {
         unset($this['command.on_complete']);
         $this->setOnComplete($onComplete);
     }
     // Set the hidden additional parameters
     if (!$this[self::HIDDEN_PARAMS]) {
         $this[self::HIDDEN_PARAMS] = array(self::HEADERS_OPTION, self::RESPONSE_PROCESSING, self::HIDDEN_PARAMS, self::REQUEST_OPTIONS);
     }
     $this->init();
 }
Exemple #2
0
 /**
  * Constructs the PostObject
  *
  * The options array accepts the following keys:
  *
  * - acl:                          The access control setting to apply to the uploaded file. Accepts any of the
  *                                 CannedAcl constants
  * - Cache-Control:                The Cache-Control HTTP header value to apply to the uploaded file
  * - Content-Disposition:          The Content-Disposition HTTP header value to apply to the uploaded file
  * - Content-Encoding:             The Content-Encoding HTTP header value to apply to the uploaded file
  * - Content-Type:                 The Content-Type HTTP header value to apply to the uploaded file. The default
  *                                 value is `application/octet-stream`
  * - Expires:                      The Expires HTTP header value to apply to the uploaded file
  * - key:                          The location where the file should be uploaded to. The default value is
  *                                 `^${filename}` which will use the name of the uploaded file
  * - policy:                       A raw policy in JSON format. By default, the PostObject creates one for you
  * - policy_callback:              A callback used to modify the policy before encoding and signing it. The
  *                                 method signature for the callback should accept an array of the policy data as
  *                                 the 1st argument, (optionally) the PostObject as the 2nd argument, and return
  *                                 the policy data with the desired modifications.
  * - success_action_redirect:      The URI for Amazon S3 to redirect to upon successful upload
  * - success_action_status:        The status code for Amazon S3 to return upon successful upload
  * - ttd:                          The expiration time for the generated upload form data
  * - x-amz-meta-*:                 Any custom meta tag that should be set to the object
  * - x-amz-server-side-encryption: The server-side encryption mechanism to use
  * - x-amz-storage-class:          The storage setting to apply to the object
  * - x-amz-server-side​-encryption​-customer-algorithm: The SSE-C algorithm
  * - x-amz-server-side​-encryption​-customer-key:       The SSE-C customer secret key
  * - x-amz-server-side​-encryption​-customer-key-MD5:   The MD5 hash of the SSE-C customer secret key
  *
  * For the Cache-Control, Content-Disposition, Content-Encoding,
  * Content-Type, Expires, and key options, to use a "starts-with" comparison
  * instead of an equals comparison, prefix the value with a ^ (carat)
  * character
  *
  * @param S3Client $client
  * @param $bucket
  * @param array $options
  */
 public function __construct(S3Client $client, $bucket, array $options = array())
 {
     $this->setClient($client);
     $this->setBucket($bucket);
     parent::__construct($options);
 }