Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
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

 Answers
4

Finally i've found the solution!



There were two problems:




  1. Now as now the url for files content is not the url of the api but https://files.one.ubuntu.com


  2. before the file path you should place "content/file path"




Something like this




oauth->fetch('https://files.one.ubuntu.com/content/~/Ubuntu%20One/prova.php');



[#44059] Thursday, May 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
truwom

Total Points: 101
Total Questions: 99
Total Answers: 100

Location: Ivory Coast
Member since Tue, Sep 15, 2020
4 Years ago
truwom questions
;