Last active
December 6, 2016 04:44
-
-
Save tosin2013/2d300eaefea2652afb93e0a633bda7f2 to your computer and use it in GitHub Desktop.
working in progress upload ionic to dreamfactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.testFileUpload = function () { | |
// Function code goes here | |
// Destination URL | |
var url = "your_endpoint"; | |
//File for Upload | |
var targetPath = cordova.file.externalRootDirectory + "Final-Fantasy-XV-Noctis-Red-Eyes.png"; | |
//var targetPath = "http://media.mademan.com/chickipedia/uploaded_photos/a/a5/Janelle_Monae-young-hot-babe-chicki-smoking-hot-soft-lovely_thumb_585x795.jpg"; | |
var trustHosts = true; | |
var win = function (r) { | |
console.log("Code = " + r.responseCode); | |
console.log("Response = " + r.response); | |
console.log("Sent = " + r.bytesSent); | |
} | |
var fail = function (error) { | |
alert("An error has occurred: Code = " + error.code); | |
console.log("upload error source " + error.source); | |
console.log("upload error target " + error.target); | |
} | |
var options = new FileUploadOptions(); | |
options.fileKey="file"; | |
// options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); | |
options.fileName="Final-Fantasy-XV-Noctis-Red-Eyes.png"; | |
options.mimeType="image/jpeg"; | |
var params = new Object(); | |
params.value1 = "test"; | |
params.value2 = "param"; | |
options.params = params; | |
options.chunkedMode = false; | |
var ft = new FileTransfer(); | |
ft.upload(targetPath, url+"/"+"Final-Fantasy-XV-Noctis-Red-Eyes.png?app_name=working_login?api_key="+myConfig.apiKey + | |
'&session_token=' + JSON.parse(localStorage.getItem("myAppSession")).session_token, win, fail, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment