0
votes

I wonder, can i upload files to OwnCloud by some post or put request?

My goal - user uploads files to one server1, after submitting form his data handles and sends to another server2 with Owncloud installed on, then returns path to file in owncloud back. So record in server1 will have some filename property points to owncloud storage.

(Note: I am not talking about WebDAV).

Any other capabilities?

1

1 Answers

0
votes

The Own Cloud API exposes an endpoint which makes this possible (both for POST and PUT):

post(string  $uri, array  $options = array()) : \OCP\Http\Client\IResponse

and

put(string  $uri, array  $options = array()) : \OCP\Http\Client\IResponse

Parameters

string $uri array $options Array such as 'body' => [ 'field' => 'abc', 'other_field' => '123', 'file_name' => fopen('/path/to/file', 'r'), ], 'headers' => [ 'foo' => 'bar', ], 'cookies' => [' 'foo' => 'bar', ], 'allow_redirects' => [ 'max' => 10, // allow at most 10 redirects. 'strict' => true, // use "strict" RFC compliant redirects. 'referer' => true, // add a Referer header 'protocols' => ['https'] // only allow https URLs ], 'save_to' => '/path/to/file', // save to a file or a stream 'verify' => true, // bool or string to CA file 'debug' => true,

see https://doc.owncloud.org/api/classes/OCP.Http.Client.IClient.html for the relevant section in the API docs