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
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"resolveJsonModule": true, | |
"esModuleInterop": true | |
} | |
} |
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
{ | |
"count": 42, | |
"users": [ | |
{"name": "John", "age": 35}, | |
{"name": "Ann", "age": 32}, | |
{"name": "George", "age": 24}, | |
{"name": "Mary", "age": 27}, | |
{"name": "Vivian", "age": 21} | |
], | |
"env": "debug" |
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
import config from "./config.json"; | |
console.log(config.count); // 42 | |
console.log(config.env); // "debug" |
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
const APPSPOT_BUCKET_URL = "gs://firebase-storage-demo.appspot.com"; | |
firebase.init({ | |
storageBucket: APPSPOT_BUCKET_URL | |
// any other options | |
}).then(() => { | |
console.log("Firebase init!"); | |
}) |
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
service firebase.storage { | |
match /b/{bucket}/o { | |
match /{allPaths=**} { | |
// Allow access by all users | |
allow read, write; | |
} | |
} | |
} |
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
import { storage } from "nativescript-plugin-firebase"; | |
import { File, knownFolders, path } from "tns-core-modules/file-system"; | |
import { APPSPOT_BUCKET_URL } from "./shared/link"; // e.g. gs://firebase-storage-demo.appspot.com | |
uploadFile() { | |
const appPath = knownFolders.currentApp().path; | |
// The path to the file we want to upload (this one is in `app/images` and is called `happy-homer-meme.png`) | |
const logoPath = appPath + "/images/happy-homer-meme.png"; | |
// Upload the file with the options below: |
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
downloadFile() { | |
let downloadPath: string; | |
let logoPath: string; | |
let fileName: string = "happy-homer-meme.png"; | |
if (isAndroid) { | |
// use tns-platform-declarations to access the native Android & iOS APIs | |
downloadPath = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).toString(); | |
} else if (isIOS) { | |
downloadPath = knownFolders.documents().path; |
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
getDownloadUrl() { | |
storage.getDownloadUrl({ | |
// optional, can also be passed during init() as 'storageBucket' param so we can cache it | |
bucket: APPSPOT_BUCKET_URL, | |
// the full path of an existing file in your Firebase storage | |
remoteFullPath: 'uploads/images/happy-homer-meme.png' | |
}).then(downloadURL => { | |
console.log("Download URL: " + downloadURL); | |
}).catch(error => { | |
console.log("Error: " + error); |
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
deleteFile() { | |
storage.deleteFile({ | |
// optional, can also be passed during init() as 'storageBucket' param so we can cache it | |
bucket: APPSPOT_BUCKET_URL, | |
// the full path of an existing file in your Firebase storage | |
remoteFullPath: 'uploads/images/firebase-storage.png' | |
}).then(() => { | |
console.log("File deleted from Firebase Storage."); | |
}).catch(error => { | |
console.log("File deletion Error: " + error); |
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
tns run --hmr |
OlderNewer