0

I have a FILE_URI(which is a path to the file), How do I use this to upload the file in parse? my parse data "db" currently has a column named "image" and is a file type field. How do I handle this? I have attempted to create a parse file then setting it and saving it but no dice. thanks.

$scope.fileURL // FILE_URI  "file:///var/mobile/Containers/data/application/"

var parseFile = new Parse.File("img.png", $scope.fileURL);

var image = new Parse.Object("image");
image.set("image", parseFile);
image.save();

1 Answers1

0

Parse stores image in base64-encoded string, I suggest you to convert image into base64-encoded string first and then save on parse.

There is a urlTobase64 function here: How to convert image into base64 string using javascript

convertImgToBase64URL('http://bit.ly/18g0VNp', function(base64Img){
    var Parsefile = new Parse.File("img.png", {base64: base64Img});
});

Parse File documentation: https://parse.com/docs/js/guide#files-creating-a-parse-file

Community
  • 1
  • 1
YiLao
  • 21
  • 3