private function format(Shape $shape, $value)
 {
     switch ($shape['type']) {
         case 'structure':
             $data = [];
             foreach ($value as $k => $v) {
                 if ($v !== null && $shape->hasMember($k)) {
                     $data[$shape['locationName'] ?: $k] = $this->format($shape->getMember($k), $v);
                 }
             }
             return $data;
         case 'list':
             $items = $shape->getMember();
             foreach ($value as &$v) {
                 $v = $this->format($items, $v);
             }
             return $value;
         case 'map':
             if (empty($value)) {
                 return new \stdClass();
             }
             $values = $shape->getValue();
             foreach ($value as &$v) {
                 $v = $this->format($values, $v);
             }
             return $value;
         case 'blob':
             return base64_encode($value);
         case 'timestamp':
             return TimestampShape::format($value, 'unixTimestamp');
         default:
             return $value;
     }
 }
 /**
  * Constructs the PostObject.
  *
  * The options array accepts the following keys:
  * @link http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
  *
  * @param S3ClientInterface $client     Client used with the POST object
  * @param string            $bucket     Bucket to use
  * @param array             $formInputs Associative array of form input
  *                                      fields.
  * @param array             $options    Policy condition options
  * @param mixed             $expiration Upload expiration time value. By
  *                                      default: 1 hour vaild peroid.
  */
 public function __construct(S3ClientInterface $client, $bucket, array $formInputs, array $options = [], $expiration = '+1 hours')
 {
     $this->client = $client;
     $this->bucket = $bucket;
     // setup form attributes
     $this->formAttributes = ['action' => $this->generateUri(), 'method' => 'POST', 'enctype' => 'multipart/form-data'];
     // setup basic policy
     $policy = ['expiration' => TimestampShape::format($expiration, 'iso8601'), 'conditions' => $options];
     // setup basic formInputs
     $this->formInputs = $formInputs + ['key' => '${filename}'];
     // finalize policy and signature
     $credentials = $this->client->getCredentials()->wait();
     $this->formInputs += $this->getPolicyAndSignature($credentials, $policy);
 }
Beispiel #3
0
 private function add_timestamp(TimestampShape $shape, $name, $value, \XMLWriter $xml)
 {
     $this->startElement($shape, $name, $xml);
     $xml->writeRaw(TimestampShape::format($value, 'iso8601'));
     $xml->endElement();
 }
 private function applyHeader($name, Shape $member, $value, array &$opts)
 {
     if ($member->getType() == 'timestamp') {
         $value = TimestampShape::format($value, 'rfc822');
     }
     $opts['headers'][$member['locationName'] ?: $name] = $value;
 }
 private function applyHeader(RequestInterface $request, $name, Shape $member, $value)
 {
     if ($member->getType() == 'timestamp') {
         $value = TimestampShape::format($value, 'rfc822');
     }
     $request->setHeader($member['locationName'] ?: $name, $value);
 }
 protected function format_timestamp(TimestampShape $shape, $value, $prefix, array &$query)
 {
     $query[$prefix] = TimestampShape::format($value, 'iso8601');
 }