Mat*_*zzi 5 php ubuntu-one ubuntu-one-api
当我尝试使用Ubuntu One API和 PHP创建包含某些内容的新文件(或覆盖现有文件的内容)时遇到了一些问题。
我可以使用以下方法轻松创建和清空文件或文件夹:
PUT /api/file_storage/v1/~/path/to/volume/path/to/node
但我不明白如何使用此规范:
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.)
Run Code Online (Sandbox Code Playgroud)
我不发布整个代码,而只发布不起作用的行:
$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);
Run Code Online (Sandbox Code Playgroud)
我不明白如何构建语法。你能帮助我吗?
最后我找到了解决方案!
有两个问题:
现在,文件内容的 url 不是 api 的 url,而是https://files.one.ubuntu.com
在文件路径之前,您应该放置“内容/文件路径”
像这样的东西
oauth->fetch('https://files.one.ubuntu.com/content/~/Ubuntu%20One/prova.php');
| 归档时间: |
|
| 查看次数: |
1885 次 |
| 最近记录: |