Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to get DataObject from Guzzle response? #545

Closed
shanebonham opened this issue Feb 25, 2015 · 2 comments · Fixed by #546
Closed

Possible to get DataObject from Guzzle response? #545

shanebonham opened this issue Feb 25, 2015 · 2 comments · Fixed by #546
Milestone

Comments

@shanebonham
Copy link

Hi there,

OpenCloud\ObjectStore\Resource\Container::uploadObjects() returns an array of Guzzle responses (in contrast to uploadObject() which returns a DataObject).

Is it possible to get the DataObject from a Guzzle response? I need to upload a batch of files, but then store each file's public URL.

@ycombinator ycombinator self-assigned this Feb 25, 2015
@ycombinator
Copy link
Contributor

Unfortunately there is no way to do this directly with the SDK. However, the following snippet of code should get you what you need, assuming you had the line $responses = $container->uploadObjects($objects) in your code:

foreach ($responses as $index => $response) {
    $dataObject = $container->dataObject()
        ->setName($objects[$index]['name']);
    echo $dataObject->getPublicUrl();
}

UPDATE: I have submitted a pull request (#546) to allow uploadObjects to return an array of DataObjects. Until that is reviewed and merged, please use the workaround described above.

@shanebonham
Copy link
Author

Thank you, that is very helpful!

ycombinator added a commit that referenced this issue Mar 2, 2015
Return array of DataObjects if such is requested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants