• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (PHP SDK)
  4. Object Download
  5. Rewriting Response Headers

Rewriting Response Headers

When downloading an object, you can rewrite some HTTP/HTTPS response headers. The following table lists rewritable response headers.

Parameter

Description

ResponseContentType

Rewrites Content-Type in HTTP/HTTPS responses.

ResponseContentLanguage

Rewrites Content-Language in HTTP/HTTPS responses.

ResponseExpires

Rewrites Expires in HTTP/HTTPS responses.

ResponseCacheControl

Rewrites Cache-Control in HTTP/HTTPS responses.

ResponseContentDisposition

Rewrites Content-Disposition in HTTP/HTTPS responses.

ResponseContentEncoding

Rewrites Content-Encoding in HTTP/HTTPS responses.

Sample code:
// Import the third-party open source libraries.
require 'vendor/autoload.php';
// Import the SDK code library.
require 'obs-autoloader.php';
// Declare the namespace.
use Obs\S3\ObsClient;
// Create an instance of ObsClient.
$obsClient = new ObsClient ( [
       'key' => '*** Provide your Access Key ***',
       'secret' => '*** Provide your Secret Key ***',
       'endpoint' => 'https://yourdomainname'
] );

$resp = $obsClient -> getObject([
       'Bucket' => 'bucketname',
       'Key' => 'objectkey',
       'ResponseContentType' => 'image/jpeg'
]);

printf("RequestId:%s\n", $resp['RequestId']);
    # Obtain the rewritten response headers.
printf("ContentType:%s\n", $resp['ContentType']);