Php 文件上传Egnyte API
我正在尝试通过Egnyte API将文件上载到帐户。CURL命令表示:Php 文件上传Egnyte API,php,rest,egnyte,Php,Rest,Egnyte,我正在尝试通过Egnyte API将文件上载到帐户。CURL命令表示: curl -v --request POST\ -H "Authorization: Bearer 2v8q2bc6uvxtgghwmwvnvcp4"\ --upload-file\ ~/Desktop/test.txt https://acme.egnyte.com/pubapi/v1/fs-content/Shared/Documents/test.txt 有人能告诉我如何通过PHP发布并获得CURL调用返回
curl -v --request POST\
-H "Authorization: Bearer 2v8q2bc6uvxtgghwmwvnvcp4"\
--upload-file\
~/Desktop/test.txt https://acme.egnyte.com/pubapi/v1/fs-content/Shared/Documents/test.txt
有人能告诉我如何通过PHP发布并获得CURL调用返回的JSON响应吗?Egnyte提供了示例代码,展示了如何使用PHP和CURL上传文件: 具体看一下匿名php上传器示例中的EgnyteClient.php文件 您发布的curl请求是来自网站的示例,旨在从命令行运行。要在域上使用它,请确保执行以下操作:
- 将令牌2v8q2bc6uvxtgghwmwvnvcp4更改为从中获得的令牌
- 将对示例“acme”域的引用更新到您的Egnyte域李>
- 更改您正在上载的文件的路径以及您希望在Egnyte中上载文件的路径
- 我终于解决了这个问题。很抱歉发布解决方案。以下是我创建的用于将文件上载到服务器的功能:
require('functions/egnyte/lib/curl.php');
require('functions/egnyte/lib/curl_response.php');
require('functions/egnyte/EgnyteClient.php');
function doUpload() {
$domain = 'yourdomain';
$folder = '/Shared/our folder name/';
$oauthToken = 'your oauth token';
$fileBinaryContents = file_get_contents($_FILES['filedata']['tmp_name']);
$fileName = $_FILES['filedata']['name'];
// instantiate an Egnyte Client with the domain and oAuth token for the user with which the upload will be performed
$egnyte = new EgnyteClient($domain, $oauthToken);
// perform the upload and get the response from the server
$response = $egnyte->uploadFile($folder, $fileName, $fileBinaryContents);
}
如果有人遇到任何问题,请务必让我知道。我可以帮忙
供参考:
您还可以联系:
查找cURL手册页中使用的参数,并与PHP手册中cURL扩展的选项描述进行比较。即使脚本上写着“成功”,文件也不会列在egnyte网站的文件夹中。我检查了文件夹名称和广告位置在脚本中是否正确,我也在检查egnyte网站上的相同文件夹。我需要这是wordpress最终。我如何获得文件夹列表???@Nick M/@Dima Tisnek,我如何使用java实现从本地机器到egnyte的文件上传?