Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
iOS Image Upload Type in Firebase #236
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jan 2, 2017
1 parent 01a5fc3 commit 323cb07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 11 additions & 3 deletions firebase.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,11 +1306,19 @@ firebase.uploadFile = function (arg) {
});

if (arg.localFile) {
if (typeof(arg.localFile) != "object") {
if (typeof(arg.localFile) !== "object") {
reject("localFile argument must be a File object; use file-system module to create one");
return;
}

// using 'putFile' (not 'putBytes') so Firebase can infer the mimetype
var localFileUrl = android.net.Uri.fromFile(new java.io.File(arg.localFile.path));
var uploadFileTask = storageReference.putFile(localFileUrl)
.addOnFailureListener(onFailureListener)
.addOnSuccessListener(onSuccessListener)
.addOnProgressListener(onProgressListener);

/*
var error;
var contents = arg.localFile.readSync(function(e) { error = e; });
Expand All @@ -1323,6 +1331,7 @@ firebase.uploadFile = function (arg) {
.addOnFailureListener(onFailureListener)
.addOnSuccessListener(onSuccessListener)
.addOnProgressListener(onProgressListener);
*/

} else if (arg.localFullPath) {

Expand All @@ -1331,7 +1340,6 @@ firebase.uploadFile = function (arg) {
return;
}

// TODO there's prolly a more efficient way to get the file obj.. .android perhaps?
var localFileUrl = android.net.Uri.fromFile(new java.io.File(arg.localFullPath));
var uploadFileTask = storageReference.putFile(localFileUrl)
.addOnFailureListener(onFailureListener)
Expand Down Expand Up @@ -1376,7 +1384,7 @@ firebase.downloadFile = function (arg) {
var localFilePath;

if (arg.localFile) {
if (typeof(arg.localFile) != "object") {
if (typeof(arg.localFile) !== "object") {
reject("localFile argument must be a File object; use file-system module to create one");
return;
}
Expand Down
10 changes: 8 additions & 2 deletions firebase.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,11 +1404,16 @@ firebase.uploadFile = function (arg) {
var fIRStorageUploadTask = null;

if (arg.localFile) {
if (typeof(arg.localFile) != "object") {
if (typeof(arg.localFile) !== "object") {
reject("localFile argument must be a File object; use file-system module to create one");
return;
}

// using 'putFile' (not 'putData') so Firebase can infer the mimetype
var localFileUrl = NSURL.fileURLWithPath(arg.localFile.path);
fIRStorageUploadTask = fIRStorageReference.putFileMetadataCompletion(localFileUrl, null, onCompletion);

/*
var error;
var contents = arg.localFile.readSync(function(e) { error = e; });
Expand All @@ -1418,6 +1423,7 @@ firebase.uploadFile = function (arg) {
}
fIRStorageUploadTask = fIRStorageReference.putDataMetadataCompletion(contents, null, onCompletion);
*/

} else if (arg.localFullPath) {
var localFileUrl = NSURL.fileURLWithPath(arg.localFullPath);
Expand Down Expand Up @@ -1470,7 +1476,7 @@ firebase.downloadFile = function (arg) {
var localFilePath;

if (arg.localFile) {
if (typeof(arg.localFile) != "object") {
if (typeof(arg.localFile) !== "object") {
reject("localFile argument must be a File object; use file-system module to create one");
return;
}
Expand Down

0 comments on commit 323cb07

Please sign in to comment.