5 ftp angularjs cordova ionic-framework
我正在尝试将图像上传到我的FTP.
到目前为止我所获得的是这个plnkr
我的cordova文件传输看起来像
$scope.upload =function(){
var options = {
fileKey: "file",
fileName: "gopi",
chunkedMode: false,
mimeType: "image/jpeg",
params : {'user_token':'Chandru@123', 'user_email':'wepopusers'} // directory represents remote directory, fileName represents final remote file name
};
console.log(options);
$cordovaFileTransfer.upload('ftp://308.3d8.myftpupload.com/', MyService.getImgPath(), options)
.then(function(result) {
// Success!
console.log(result);
console.log("SUCCESS: " + JSON.stringify(result.response));
alert('ftp success');
}, function(err) {
// Error
console.log(err);
alert('ftp fail');
console.log("ERROR: " + JSON.stringify(err));
}, function (progress) {
// constant progress updates
console.log(progress);
});
};
Run Code Online (Sandbox Code Playgroud)
我对cordova文件的错误函数的响应如下
FileTransferError {code:2,source:"file:///storage/sdcard0/Android/data/com.ionicframework.camera108827/cache/1462186990291.jpg",target:" ftp://308.3d8.myftpupload.com/ " ,http_status:null,body:null ...} body:nullcode:2exception:nullhttp_status:nullsource:"file:///storage/sdcard0/Android/data/com.ionicframework.camera108827/cache/1462186990291.jpg"target:" ftp ://308.3d8.myftpupload.com/ " proto:Object
我有按钮TakePicture,它将拍摄照片并显示给用户,我还有一个使用cordovafiletransfer $ scope.upload上传的功能.
我的ftp主机是ftp://308.3d8.myftpupload.com/用户名和密码是在我的编码中给出的我有一个名为gopi的文件夹名称,我的图像应该存储.
我拍摄的图像的路径是在imageURI参数中,所以我使用服务来设置路径.
步骤我很困惑
1)我无法理解cordova文件传输插件中的var选项对象.
2)我在远程调试时没有得到任何错误,但我只在我的cordova文件传输中调用我的错误功能.
如何使用IONIC将拍摄的图像更新为FTP
UPDATE
感谢gandhi的回答https://github.com/xfally/cordova-plugin-ftp一些我如何设法连接到没有multipart的ftp.
但是在这方面面临着错误
$ window.cordova.plugin.ftp.upload("/ ping","/ gopi/ping",function(percent){
我不知道第一个论点和第二个论点是什么.
$ window.cordova.plugin.ftp.upload("/ default.prop","/ gopi/default.prop",function(percent){
以上行成功完全发布到我的ftp但我无法发布存储在我的ping变量中的图像.
您的第一个问题的答案可以在文件传输插件的官方文档中找到。摘录如下,
options: Optional parameters (Object). Valid keys:
fileKey: The name of the form element. Defaults to file. (DOMString)
fileName: The file name to use when saving the file on the server. Defaults to image.jpg. (DOMString)
httpMethod: The HTTP method to use - either PUT or POST. Defaults to POST. (DOMString)
mimeType: The mime type of the data to upload. Defaults to image/jpeg. (DOMString)
params: A set of optional key/value pairs to pass in the HTTP request. (Object, key/value - DOMString)
chunkedMode: Whether to upload the data in chunked streaming mode. Defaults to true. (Boolean)
headers: A map of header name/header values. Use an array to specify more than one value. On iOS, FireOS, and Android, if a header named Content-Type is present, multipart form data will NOT be used. (Object)
Run Code Online (Sandbox Code Playgroud)
查看此链接以获取更多信息。
对于第二个问题,请尝试在错误回调函数中获取错误代码并尝试缩小问题范围。
更新:我猜想使用文件传输插件无法进行 ftp 上传。插件定义本身指出"The FileTransfer object provides a way to upload files using an HTTP multi-part POST or PUT request, and to download files"
您可能需要查看ftp 客户端的ftp 上传。
| 归档时间: |
|
| 查看次数: |
961 次 |
| 最近记录: |