[Solved]Pydio Cells REST API Adding Files

I can only find adding blank files using the REST API,
how do I add a file from … lets say my desktop to a Pydio Cell?
[realized I have to use S3 API or alternative to move or copy files to the cell]

I guess you are looking for the cells-client :slight_smile: https://github.com/pydio/cells-client

Hey Dustin, I’m also trying to add files through the REST API. I have already succeeded in creating cells and empty folders too. I don’t see any S3 API in the API docs. Can you explain how you used the S3 API please? Thank you!

You don’t see S3 API in the docs? :slight_smile:

and for an example with Postman (end of the page)


Thanks charles!

I looked at the Packagist aws/aws-sdk-php and this appears to be limited to connecting to AWS only. There are libraries that seem to allow connection to other servers, and many of these seem to be deprecated.

Can you recommend an S3 client library for PHP?

aws stuff is generally very well coded and maintained
have a look at our old php code, we used that lib for connecting to any S3-compatible storage

Hi @charles

That example has helped a lot. I’ve been able to connect to Pydio Cells and create an S3Client object and even issue what appears to be a successful “getObject” request. However, what I get back is a result object that contains a “Body” element containing an “GuzzleHttp\Psr7\Stream Object”

I don’t have any experience with these. the AWS documentation seems to imply I should have a stream wrapper, though it doesn’t give clear guidance on how to do so. Their “getting started” section seems to imply I can just read the “Body” and yet that is returning the above stream object, not simply text or blob. It appears to me that I will need to read the contents as a stream, and I have no idea how to do that here.

I went over the access.s3 code in your github repo trying to figure this out and did not come to any solid conclusions about how you are actually accessing the file content.

I would be very grateful if you can provide any guidance on using the returned result object to actually get the file content.



Arf, i’v been quietly forgotting my PHP skills for a while now :slight_smile:

I think you may have to write something similar to :

// open a file for writing (or a target stream)
$destStream = fopen($filename, "w");
// get body as a stream
$body = $response->getBody();

// Copy-ing the body to the destination file
while (!$body->eof()) {
    $part = $body->read(4096);
    $readBytes = strlen($part);
    fwrite($destStream, $part, $readBytes);

// Close the target file

I wish I could forget my PHP skills, are you hiring? :wink:

FYI, that works great, just one tweak, there is no result->getBody(), it’s simply result[‘Body’] to get the stream. I didn’t realize GuzzleHttp streams were directly accessible that’s where I got hung up, thanks for helping me out!