如何使用ngcordova文件传输的插件来传输拍摄的图像,以我的ftp [英] how to transfer the taken image using ngcordova file transfer plugin to my ftp

查看:140
本文介绍了如何使用ngcordova文件传输的插件来传输拍摄的图像,以我的ftp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上传图片到我的FTP。

I am trying to upload image to my FTP.

我所achived到目前为止,在这 plnkr

what i have achived so far is in this plnkr

我科尔多瓦传输文件看起来像

my cordova file transfer looks like

$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);
        });

    };

我对科尔多瓦文件我的误差函数的响应看起来像

My response of my error function for cordova file looks like

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

I have button TakePicture which will take the pic and show to the user and also I have a function to upload using cordovafiletransfer $scope.upload .

我的FTP主机是 ftp://308.3d8.myftpupload.com/ 用户名和密码在我的编码给出这个我称之为一个文件夹名称的牧牛在我的形象应该存储。

my ftp host is ftp://308.3d8.myftpupload.com/ username and password is given in my coding in this i have a folder name called gopi where my image should store.

我拍摄的图像的路径是imageURI参数,所以我使用的服务设置路径。

my path of the image taken is in imageURI parameter so i used services to set the path.

步骤,我在混乱

1),我无法理解在 VAR选项对象在科尔多瓦文件传输的插件。

1) I am not able to understand the var options object in cordova file transfer plugin.

2)我没有得到,而远程调试任何埃罗,但我只是援引我的科尔多瓦文件传送我的错误funtion。

2) I am not getting any erro while remote debugging but i am only invoking my error funtion in my cordova file transfer.

推荐答案

回答你的第一个问题是文件传输的插件的官方文档。该摘录如下,

The answer to your first question is available in the official documentation of file transfer plugin. The excerpt is as follow,

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)

看看这个链接获得更多信息。

有关你的第二个问题,试图得到错误code错误回调函数,并试图缩小问题。

For your second question, try getting the error code in the error callback function and try to narrow down the problem.

这篇关于如何使用ngcordova文件传输的插件来传输拍摄的图像,以我的ftp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆