private function generate($options)
 {
     $bucket = $options[OSSOptions::BUCKET];
     $key = $options[OSSOptions::KEY];
     $method = $options[OSSOptions::METHOD];
     $expires = $options[OSSOptions::EXPIRES];
     $expires = (string) $expires->getTimeStamp();
     $builder = OSSRequestBuilder::factory()->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($bucket)->setKey($key)->setMethod($method)->addHeader(HttpHeaders::DATE, $expires);
     if (isset($options[OSSOptions::CONTENT_TYPE])) {
         $builder->addHeader(OSSHeaders::CONTENT_TYPE, $options[OSSOptions::CONTENT_TYPE]);
     }
     if (isset($options[OSSOptions::USER_METADATA])) {
         foreach ($options[OSSOptions::USER_METADATA] as $metakey => $value) {
             $builder->addHeader(OSSHeaders::OSS_USER_META_PREFIX . $metakey, $value);
         }
     }
     // Overrides
     $builder->addOverrides($options);
     $request = $builder->build();
     $canonicalString = SignUtils::buildCanonicalString($request, $bucket, $key);
     $signature = ServiceSignature::factory()->computeSignature($options[OSSOptions::ACCESS_KEY_SECRET], $canonicalString);
     $request->addParameter('OSSAccessKeyId', $options[OSSOptions::ACCESS_KEY_ID]);
     $request->addParameter('Signature', $signature);
     $request->addParameter('Expires', $expires);
     return $request->getFullUrl();
 }
Ejemplo n.º 2
0
 protected function getRequest($options)
 {
     $builder = OSSRequestBuilder::factory();
     if (isset($options[OSSOptions::MODIFIED_SINCE_CONSTRAINT])) {
         $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_MODIFIED_SINCE, DateUtils::formatDate($options[OSSOptions::MODIFIED_SINCE_CONSTRAINT]));
     }
     if (isset($options[OSSOptions::UNMODIFIED_SINCE_CONSTRAINT])) {
         $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_UNMODIFIED_SINCE, DateUtils::formatDate($options[OSSOptions::UNMODIFIED_SINCE_CONSTRAINT]));
     }
     if (isset($options[OSSOptions::MATCHING_ETAG_CONSTRAINTS])) {
         $constraints = $options[OSSOptions::MATCHING_ETAG_CONSTRAINTS];
         $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_MATCH, join(', ', $constraints));
     }
     if (isset($options[OSSOptions::NO_MATCHING_ETAG_CONSTRAINTS])) {
         $constraints = $options[OSSOptions::NO_MATCHING_ETAG_CONSTRAINTS];
         $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_NONE_MATCH, join(', ', $constraints));
     }
     $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE, "/" . $options[OSSOptions::SOURCE_BUCKET] . "/" . $options[OSSOptions::SOURCE_KEY]);
     if (OSSUtils::containsMetaOptions($options)) {
         $builder->addObjectMetadataHeaders($options);
         $builder->addHeader(OSSHeaders::COPY_OBJECT_METADATA_DIRECTIVE, 'REPLACE');
     } else {
         $builder->addHeader(OSSHeaders::COPY_OBJECT_METADATA_DIRECTIVE, 'COPY');
     }
     return $builder->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::DEST_BUCKET])->setKey($options[OSSOptions::DEST_KEY])->setMethod(HttpMethods::PUT)->build();
 }
Ejemplo n.º 3
0
 protected function getRequest($options)
 {
     $builder = OSSRequestBuilder::factory();
     if (isset($options[OSSOptions::CONTENT_LENGTH])) {
         $builder->setContentLength((string) intval($options[OSSOptions::CONTENT_LENGTH]));
     }
     return $builder->addObjectMetadataHeaders($options)->setEndpoint($options[OSSOptions::ENDPOINT])->setMethod(HttpMethods::PUT)->setBucket($options[OSSOptions::BUCKET])->setKey($options[OSSOptions::KEY])->setContent($options[OSSOptions::CONTENT])->build();
 }
Ejemplo n.º 4
0
 protected function getRequest($options)
 {
     $builder = OSSRequestBuilder::factory();
     $builder->addParameter('uploadId', $options[OSSOptions::UPLOAD_ID]);
     if (isset($options[OSSOptions::MAX_PARTS])) {
         $builder->addParameter('max-parts', (string) $options[OSSOptions::MAX_PARTS]);
     }
     if (isset($options[OSSOptions::PART_NUMBER_MARKER])) {
         $builder->addParameter('part-number-marker', (string) intval($options[OSSOptions::PART_NUMBER_MARKER]));
     }
     return $builder->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setKey($options[OSSOptions::KEY])->setMethod(HttpMethods::GET)->build();
 }
Ejemplo n.º 5
0
 protected function getRequest($options)
 {
     $builder = OSSRequestBuilder::factory();
     if (isset($options[OSSOptions::PREFIX])) {
         $builder->addParameter('prefix', $options[OSSOptions::PREFIX]);
     }
     if (isset($options[OSSOptions::MARKER])) {
         $builder->addParameter('marker', $options[OSSOptions::MARKER]);
     }
     if (isset($options[OSSOptions::DELIMITER])) {
         $builder->addParameter('delimiter', $options[OSSOptions::DELIMITER]);
     }
     if (isset($options[OSSOptions::MAX_KEYS])) {
         $builder->addParameter('max-keys', (string) intval($options[OSSOptions::MAX_KEYS]));
     }
     return $builder->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setMethod(HttpMethods::GET)->build();
 }
Ejemplo n.º 6
0
 protected function getRequest($options)
 {
     if ($options[OSSOptions::META_ONLY] === true) {
         unset($options[OSSOptions::RANGE]);
         unset($options[OSSOptions::SAVE_AS]);
         unset($options[OSSOptions::RESPONSE_CONTENT_LANGUAGE]);
         unset($options[OSSOptions::RESPONSE_CONTENT_DISPOSITION]);
         unset($options[OSSOptions::RESPONSE_CACHE_CONTROL]);
         unset($options[OSSOptions::RESPONSE_CONTENT_TYPE]);
         unset($options[OSSOptions::RESPONSE_CONTENT_ENDCODING]);
         unset($options[OSSOptions::RESPONSE_EXPIRES]);
     }
     $builder = OSSRequestBuilder::factory();
     if (isset($options[OSSOptions::RANGE])) {
         $range = $options[OSSOptions::RANGE];
         $rangeValue = 'bytes=';
         if ($range[0] == -1) {
             $rangeValue .= '-' . $range[1];
         } else {
             if ($range[1] == -1) {
                 $rangeValue .= $range[0] . '-';
             } else {
                 $rangeValue .= $range[0] . '-' . $range[1];
             }
         }
         $builder->addHeader(OSSHeaders::RANGE, $rangeValue);
     }
     if (isset($options[OSSOptions::MODIFIED_SINCE_CONSTRAINT])) {
         $builder->addHeader(OSSHeaders::GET_OBJECT_IF_MODIFIED_SINCE, DateUtils::formatDate($options[OSSOptions::MODIFIED_SINCE_CONSTRAINT]));
     }
     if (isset($options[OSSOptions::UNMODIFIED_SINCE_CONSTRAINT])) {
         $builder->addHeader(OSSHeaders::GET_OBJECT_IF_UNMODIFIED_SINCE, DateUtils::formatDate($options[OSSOptions::UNMODIFIED_SINCE_CONSTRAINT]));
     }
     if (isset($options[OSSOptions::MATCHING_ETAG_CONSTRAINTS])) {
         $constraints = $options[OSSOptions::MATCHING_ETAG_CONSTRAINTS];
         $builder->addHeader(OSSHeaders::GET_OBJECT_IF_MATCH, join(', ', $constraints));
     }
     if (isset($options[OSSOptions::NO_MATCHING_ETAG_CONSTRAINTS])) {
         $constraints = $options[OSSOptions::NO_MATCHING_ETAG_CONSTRAINTS];
         $builder->addHeader(OSSHeaders::GET_OBJECT_IF_NONE_MATCH, join(', ', $constraints));
     }
     if (isset($options[OSSOptions::SAVE_AS])) {
         $builder->setResponseBody($options[OSSOptions::SAVE_AS]);
     }
     return $builder->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setKey($options[OSSOptions::KEY])->setMethod($options[OSSOptions::META_ONLY] ? HttpMethods::HEAD : HttpMethods::GET)->addOverrides($options)->build();
 }
 protected function getRequest($options)
 {
     $builder = OSSRequestBuilder::factory();
     $builder->addParameter(OSSUtils::SUBRESOURCE_UPLOADS, null);
     if (isset($options[OSSOptions::DELIMITER])) {
         $builder->addParameter('delimiter', $options[OSSOptions::DELIMITER]);
     }
     if (isset($options[OSSOptions::KEY_MARKER])) {
         $builder->addParameter('key-marker', $options[OSSOptions::KEY_MARKER]);
     }
     if (isset($options[OSSOptions::MAX_UPLOADS])) {
         $builder->addParameter('max-uploads', (string) intval($options[OSSOptions::MAX_UPLOADS]));
     }
     if (isset($options[OSSOptions::PREFIX])) {
         $builder->addParameter('prefix', $options[OSSOptions::PREFIX]);
     }
     if (isset($options[OSSOptions::UPLOAD_ID_MARKER])) {
         $builder->addParameter('upload-id-marker', $options[OSSOptions::UPLOAD_ID_MARKER]);
     }
     return $builder->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setMethod(HttpMethods::GET)->build();
 }
 protected function getRequest($options)
 {
     return OSSRequestBuilder::factory()->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setKey($options[OSSOptions::KEY])->addParameter('uploadId', $options[OSSOptions::UPLOAD_ID])->setMethod(HttpMethods::POST)->setContent($this->buildXmlBody($options[OSSOptions::PART_ETAGS]))->build();
 }
Ejemplo n.º 9
0
 protected function getRequest($options)
 {
     return OSSRequestBuilder::factory()->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setMethod(HttpMethods::DELETE)->build();
 }
Ejemplo n.º 10
0
 protected function getRequest($options)
 {
     return OSSRequestBuilder::factory()->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setKey($options[OSSOptions::KEY])->setMethod(HttpMethods::PUT)->addParameter('partNumber', (string) intval($options[OSSOptions::PART_NUMBER]))->addParameter('uploadId', $options[OSSOptions::UPLOAD_ID])->setContent($options[OSSOptions::CONTENT])->addHeader(OSSHeaders::CONTENT_LENGTH, (string) intval($options[OSSOptions::PART_SIZE]))->build();
 }
 protected function getRequest($options)
 {
     return OSSRequestBuilder::factory()->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->setKey($options[OSSOptions::KEY])->addParameter('uploadId', $options[OSSOptions::UPLOAD_ID])->setMethod(HttpMethods::DELETE)->build();
 }
Ejemplo n.º 12
0
 protected function getRequest($options)
 {
     return OSSRequestBuilder::factory()->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::BUCKET])->addParameter('acl', null)->setMethod(HttpMethods::GET)->build();
 }
 protected function getRequest($options)
 {
     return OSSRequestBuilder::factory()->addObjectMetadataHeaders($options)->setEndpoint($options[OSSOptions::ENDPOINT])->setMethod(HttpMethods::POST)->setBucket($options[OSSOptions::BUCKET])->setKey($options[OSSOptions::KEY])->addParameter(OSSUtils::SUBRESOURCE_UPLOADS, null)->setContent('')->build();
 }