Home > Mobile >  AWS-SDK: Executing GetObject() gets an Empty Stream
AWS-SDK: Executing GetObject() gets an Empty Stream

Time:01-30

My main objective is to get the info on a specific object.

$client = $adapter->getClient();
$objectInfo = $client->getObject(
    [
        'Bucket' => 'bucket-name',
        'Key'    => "key-name",
    ]
);

dd($objectInfo->toArray()["Body"]);

When running, i got as a result :

GuzzleHttp\Psr7\Stream {
  -stream: stream resource {
    wrapper_type: "PHP"
    stream_type: "TEMP"
    mode: "w b"
    unread_bytes: 0
    seekable: true
    uri: "php://temp"
    options: []
  }
  -size: null
  -seekable: true
  -readable: true
  -writable: true
  -uri: "php://temp"
  -customMetadata: []
}

Any idea to resolve it would be thankful.

CodePudding user response:

I think you should try to call getContents() method from the object. for more inputs please refer the below page https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-stream-wrapper.html

https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Psr7.Stream.html#_getContents

$objectInfo['Body']->getContents();

  •  Tags:  
  • Related