2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 2032
/ 2 Years ago, tue, may 3, 2022, 3:41:17
I'm having some problems when i try to create a new file with some content (or overwrite the content of an existing one) using Ubuntu One API and PHP.
I can easily create and empty file or folder using:
PUT /api/file_storage/v1/~/path/to/volume/path/to/node
but i don't understand ho to use this specification:
PUT /api/file_storage/v1/ + <directory.content_path> + '/' + filename.ext, or /api/file_storage/v1/ + <file.content_path>
PUT a new file, with content, in one action, or overwrite content of an existing file.
The body of the PUT request is the content of the file.
Note that you cannot PUT a new file with content and alter its attributes at the same time.
Note also that content_paths may not be rooted under the API root, and may change without warning, so they must be read from the API and not hardcoded.
(Note caveat above about CONTENT_ROOT being temporarily different.)
I don't post the whole code but only the line which doesn't work:
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$filecontentent = "content of the txt file";
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
I don't understand how to structure the syntax. Can you help me?
More From » ubuntu-one