Я пытаюсь загрузить изображение на мой FTP, что я сделал до сих пор, я успешно применит образ и у меня есть расположение изображения вКак загрузить изображение на FTP без mulitpart только на FTP-клиент
file:///storage/sdcard0/Android/data/com.ionicframework.ftptranfer949961/cache/1467013143014.png
я должен послать .png файл изображения на мой FTP
var app = angular.module('starter', ['ionic','ngCordova'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
app.service('MyService',function(){
var imgPath = [];
//var imgName = [];
this.getImgPath = function(){
return imgPath;
}
this.setImgPath = function(path){
console.log(path);
imgPath = path ;
/*this.getImgName = function(){
return imgName;
}
this.setImgName = function(pass){
console.log(pass);
imgName = pass;
}*/
}
});
//https://github.com/xfally/cordova-plugin-ftp
app.controller('mycontroller',function($scope,$cordovaCamera,$cordovaFileTransfer,MyService,$log,$timeout,$window){
$scope.takePicture = function(){
var options = {
quality : 75,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit : false,
encodingType: Camera.EncodingType.PNG,
mediaType: Camera.MediaType.PICTURE,
targetWidth: 250,
targetHeight: 250,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true
};
$cordovaCamera.getPicture(options).then(function(imageURI) {
console.log('invokeing cordovaCamera');
$scope.image = imageURI;
// imageURI.substr(imageURI.lastIndexOf('/')+1);
console.log(imageURI.substr(imageURI.lastIndexOf('/')+1));
MyService.setImgPath(imageURI);
console.log($scope.image);
console.log(imageURI);
$scope.upload();
}, function(err) {
// An error occured. Show a message to the user
console.log(err);
});
};
$scope.upload =function(){
var ping = MyService.getImgPath().substr(MyService.getImgPath().lastIndexOf('/')+1);
console.log(ping);
// Test code (for angularjs)
// Tip: Usually init/create $window.cordova.plugin.ftp will take some time, so set a `timeout()` to make sure it's ready.
// But surely, the best and safest way is to listen `deviceready` event for cordova, or `$ionicPlatform.ready()` for ionic.
// You can find more info in official docs of cordova or ionic.
$timeout(function() {
if ($window.cordova.plugin.ftp) {
$log.log("xtest: ftp: found");
// 1. connect to one ftp server, then you can do any actions/cmds
$window.cordova.plugin.ftp.connect("308.3d8.myftpupload.com", "wepopusers", "[email protected]", function() {
$log.log("xtest: ftp: connect ok");
// 2. list one dir, note that just can be dir, not file
$window.cordova.plugin.ftp.ls("/gopi", function(fileList) {
$log.log("xtest: ftp: list ok");
if (fileList && fileList.length > 0) {
$log.log("xtest: ftp: The last file'name is " + fileList[fileList.length - 1].name);
$log.log("xtest: ftp: The last file'type is " + fileList[fileList.length - 1].type);
$log.log("xtest: ftp: The last file'link is " + fileList[fileList.length - 1].link);
$log.log("xtest: ftp: The last file'size is " + fileList[fileList.length - 1].size);
$log.log("xtest: ftp: The last file'modifiedDate is " + fileList[fileList.length - 1].modifiedDate);
// 4. upload local file to remote, you can rename at the same time. arg1: local file, arg2: remote file.
// make sure you can access and read the local file.
$window.cordova.plugin.ftp.upload("/" + ping, "/gopi/" + ping, function(percent) {
console.log(percent);
if (percent == 1) {
$log.log("xtest: ftp: upload finish");
} else {
$log.log("xtest: ftp: upload percent=" + percent*100 + "%");
}
}, function(error) {
$log.log("xtest: ftp: upload error=" + error);
});
}
}, function(error) {
$log.log("xtest: ftp: list error: " + error);
});
});
} else {
$log.log("xtest: ftp: not found!");
}
}, 2000);
};
});
вы можете увидеть в этой строке
$ window.cordova.plugin.ftp.upload ("/ пинг", "/ гопи/пинг", функция (в процентах)
/пинг в этом у меня есть имя изображения 1467013143014.png
, но я получаю сообщение об ошибке, как
XTEST: FTP: ошибка загрузки = java.io.FileNotFoundException:/пинг
Для получения более подробной информации посмотрите этот git-hub cordova-ftp.
я успешно загрузил один файл с именем default.prop к моему FTP, но я не знаю, как он будет загружен на мой фтп другой, то любая вещь, что я дал мой FTP я не могу загрузить его
У меня есть даже горячий код, мой путь к изображению в области загрузки, но не могу загрузить изображение.
, как я могу получить доступ к файлу моего образа и загрузить на мой FTP