我正在尝试设置一个Web应用程序,其中许多客户端可以通过Node.js http服务器连接,然后上载/下载文件,然后将显示在不同的显示中。我正在考虑将这些文件存储在可以集成到我的应用程序的免费云服务中。哦,我也在这个项目中使用socket.IO。
Dropbox提供了一些API来执行此操作:https://www.dropbox.com/developers但我正在寻找像ownCloud这样的免费解决方案,我可以拥有更多的存储空间并拥有自己的私有服务器。
有谁知道这是否可以做到?或者可以提供有关我问题的替代解决方案的任何提示?我真的很感激任何帮助,因为我对这一切都很陌生。
答案 0 :(得分:10)
@Javier Gonzalez,要上传文件......
糟糕的选择:
curl -X PUT "http://yourserver.com/owncloud/remote.php/webdav/file.zip" -F myfile=@"/Users/Javi/Downloads/file.zip"
对于,上传的文件将包含http标题。
更好的选择:
curl -X PUT "http://yourserver.com/owncloud/remote.php/webdav/file.zip" --data-binary @"/Users/Javi/Downloads/file.zip"
或者只使用curl -T文件名网址上传
答案 1 :(得分:7)
您必须在http://yourowncloudserver.com/owncloud/remote.php/webdav/
与WebDav界面进行通信要上传文件,您必须向文件的命运发出PUT请求,例如: http://yourowncloudserver.com/owncloud/remote.php/webdav/file.zip
将输入流添加到请求以读取文件。
这是CURL命令:
curl -X PUT -u username:password "http://yourserver.com/owncloud/remote.php/webdav/file.zip" -F myfile=@"/Users/Javi/Downloads/file.zip"
您还可以检查Objective C上的代码以检查我们使用的参数: ownCloud iOS Library
NSMutableURLRequest *request = [self requestWithMethod:@"PUT" path:remoteDestination parameters:nil];
[request setTimeoutInterval:k_timeout_upload];
[request setValue:[NSString stringWithFormat:@"%lld", [UtilsFramework getSizeInBytesByPath:localSource]] forHTTPHeaderField:@"Content-Length"];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setHTTPShouldHandleCookies:NO];
//[request setHTTPBody:[NSData dataWithContentsOfFile:localSource]];
__weak __block OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request success:success failure:failure];
[operation setInputStream:[NSInputStream inputStreamWithFileAtPath:localSource]];
答案 2 :(得分:1)
最简单的方法是使用owncloud的webdav界面
答案 3 :(得分:1)
作为现有答案的补充,我使用以下函数作为别名:
cloud() {
curl -X PUT -u "<username>:<password>" "https://<hostname>/remote.php/webdav/${2:-$1}" --data-binary @"./$1"
}
只需替换<username>
,<password>
和<hostname>
并将其放入.bash_aliases中,您就可以上传文件:
cloud filename
cloud path filename
答案 4 :(得分:0)
使用curl for windows和owncloud 8.我发现传输文件的唯一方法是使用此命令
curl -u user:password --upload-file "c:\path to file\srcfile" "https://ocserver/owncloud/remote.php/webdav/tgtfile"
希望这有帮助
答案 5 :(得分:0)
上传文件您必须对文件的命运发出 PUT 请求,例如:http://yourOwnCloudServer/remote.php/webdav/text.txt
这是CURL命令:
curl -X PUT -u username:password "http://yourOwnCloudServer/remote.php/webdav/text.txt" -F myfile=@"/Users/gokul/Desktop/text.txt"
您还可以将--data-binary
用于媒体文件。
"http://yourOwnCloudServer/remote.php/webdav/image.jpg" --data-binary @"/Users/gokul/Desktop/image.jpg"