nativescript-plugin-firebase
Advanced tools
Comparing version 10.3.2 to 10.3.3
import { File } from "tns-core-modules/file-system"; | ||
import { ListResult } from "../../storage/storage"; | ||
import { ListResult, UploadMetadata } from "../../storage/storage"; | ||
export declare module storage { | ||
@@ -8,2 +8,5 @@ interface UploadTaskSnapshot { | ||
} | ||
interface Metadata { | ||
string: string; | ||
} | ||
class Reference { | ||
@@ -18,4 +21,5 @@ private path; | ||
getDownloadURL(): Promise<string>; | ||
getMetadata(): Promise<string>; | ||
listAll(): Promise<ListResult>; | ||
put(data: File | string, metadata?: any): Promise<UploadTaskSnapshot>; | ||
put(data: File | string, metadata?: UploadMetadata): Promise<UploadTaskSnapshot>; | ||
download(downloadToPath: string): Promise<any>; | ||
@@ -22,0 +26,0 @@ } |
@@ -31,2 +31,7 @@ "use strict"; | ||
}; | ||
Reference.prototype.getMetadata = function () { | ||
return firebaseStorage.getDownloadUrl({ | ||
remoteFullPath: this.path | ||
}); | ||
}; | ||
Reference.prototype.listAll = function () { | ||
@@ -44,3 +49,4 @@ return firebaseStorage.listAll({ | ||
remoteFullPath: _this.path, | ||
onProgress: function (progress) { return console.log("Upload progress: " + progress.percentageCompleted + "% completed"); } | ||
onProgress: function (progress) { return console.log("Upload progress: " + progress.percentageCompleted + "% completed"); }, | ||
metadata: metadata | ||
}).then(function (result) { | ||
@@ -47,0 +53,0 @@ _this.getDownloadURL() |
{ | ||
"name": "nativescript-plugin-firebase", | ||
"version": "10.3.2", | ||
"version": "10.3.3", | ||
"description": "Fire. Base. Firebase!", | ||
@@ -5,0 +5,0 @@ "main": "firebase", |
@@ -93,2 +93,27 @@ "use strict"; | ||
}); | ||
var metadata = null; | ||
if (arg.metadata) { | ||
var metadataBuilder = new com.google.firebase.storage.StorageMetadata.Builder(); | ||
if (arg.metadata.cacheControl) { | ||
metadataBuilder.setCacheControl(arg.metadata.cacheControl); | ||
} | ||
if (arg.metadata.contentDisposition) { | ||
metadataBuilder.setContentDisposition(arg.metadata.contentDisposition); | ||
} | ||
if (arg.metadata.contentEncoding) { | ||
metadataBuilder.setContentEncoding(arg.metadata.contentEncoding); | ||
} | ||
if (arg.metadata.contentLanguage) { | ||
metadataBuilder.setContentLanguage(arg.metadata.contentLanguage); | ||
} | ||
if (arg.metadata.contentType) { | ||
metadataBuilder.setContentType(arg.metadata.contentType); | ||
} | ||
if (arg.metadata.customMetadata) { | ||
for (var p in arg.metadata.customMetadata) { | ||
metadataBuilder.setCustomMetadata(p, arg.metadata.customMetadata[p]); | ||
} | ||
} | ||
metadata = metadataBuilder.build(); | ||
} | ||
if (arg.localFile) { | ||
@@ -100,3 +125,3 @@ if (typeof (arg.localFile) !== "object") { | ||
var localFileUrl = android.net.Uri.fromFile(new java.io.File(arg.localFile.path)); | ||
storageReference.putFile(localFileUrl) | ||
storageReference.putFile(localFileUrl, metadata) | ||
.addOnFailureListener(onFailureListener) | ||
@@ -112,3 +137,3 @@ .addOnSuccessListener(onSuccessListener) | ||
var localFileUrl = android.net.Uri.fromFile(new java.io.File(arg.localFullPath)); | ||
storageReference.putFile(localFileUrl) | ||
storageReference.putFile(localFileUrl, metadata) | ||
.addOnFailureListener(onFailureListener) | ||
@@ -115,0 +140,0 @@ .addOnSuccessListener(onSuccessListener) |
@@ -6,2 +6,15 @@ export interface ProgressStatus { | ||
interface SettableMetadata { | ||
cacheControl?: string | null; | ||
contentDisposition?: string | null; | ||
contentEncoding?: string | null; | ||
contentLanguage?: string | null; | ||
contentType?: string | null; | ||
customMetadata?: { [key: string]: string; }; | ||
} | ||
interface UploadMetadata extends SettableMetadata { | ||
// md5Hash?: string | null; | ||
} | ||
/** | ||
@@ -41,3 +54,8 @@ * Use either the 'localFile' or 'localFullPath' param to upload a file. | ||
*/ | ||
onProgress: (data: ProgressStatus) => void; | ||
onProgress?: (data: ProgressStatus) => void; | ||
/** | ||
* | ||
*/ | ||
metadata?: UploadMetadata; | ||
} | ||
@@ -44,0 +62,0 @@ |
@@ -78,2 +78,18 @@ "use strict"; | ||
var fIRStorageUploadTask = null; | ||
var metadata = null; | ||
if (arg.metadata) { | ||
metadata = FIRStorageMetadata.new(); | ||
metadata.cacheControl = arg.metadata.cacheControl; | ||
metadata.contentDisposition = arg.metadata.contentDisposition; | ||
metadata.contentEncoding = arg.metadata.contentEncoding; | ||
metadata.contentLanguage = arg.metadata.contentLanguage; | ||
metadata.contentType = arg.metadata.contentType; | ||
if (arg.metadata.customMetadata) { | ||
var customMetadata = NSMutableDictionary.new(); | ||
for (var p in arg.metadata.customMetadata) { | ||
customMetadata.setObjectForKey(arg.metadata.customMetadata[p], p); | ||
} | ||
metadata.customMetadata = customMetadata; | ||
} | ||
} | ||
if (arg.localFile) { | ||
@@ -84,6 +100,6 @@ if (typeof (arg.localFile) !== "object") { | ||
} | ||
fIRStorageUploadTask = fIRStorageReference.putFileMetadataCompletion(NSURL.fileURLWithPath(arg.localFile.path), null, onCompletion); | ||
fIRStorageUploadTask = fIRStorageReference.putFileMetadataCompletion(NSURL.fileURLWithPath(arg.localFile.path), metadata, onCompletion); | ||
} | ||
else if (arg.localFullPath) { | ||
fIRStorageUploadTask = fIRStorageReference.putFileMetadataCompletion(NSURL.fileURLWithPath(arg.localFullPath), null, onCompletion); | ||
fIRStorageUploadTask = fIRStorageReference.putFileMetadataCompletion(NSURL.fileURLWithPath(arg.localFullPath), metadata, onCompletion); | ||
} | ||
@@ -90,0 +106,0 @@ else { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4055669
18036