How to use the firebase.storage function in firebase

To help you get started, we’ve selected a few firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github myFace-KYC / Identity_Verification / src / pages / submit / submit.ts View on Github external
getPassportUrl(){
    console.log('Entered Passport Call');
    var storageRef = storage().ref();
    var starsRef = storageRef.child('passport/'+ this.userId);
    // Get the download URL
    starsRef.getDownloadURL().then((result) =>  {

      console.log("Passport",result);
      this.passport_url = result;
      
    }).catch(function(error) {
      // Handle any errors
    });
  }
github TechnionYearlyProject / Cognitivity / code / client / src / app / services / uploads / upload.service.ts View on Github external
uploadFile(upload: Upload, callback) {
    //firebase.initializeApp(environment.firebase,'Cognitivity1');
    const storageRef = firebase.storage().ref();
    const uploadTask = storageRef.child(`${this.basePath}/${upload.file.name}`)
      .put(upload.file);

    uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED,
      // three observers
      // 1.) state_changed observer
      (snapshot) => {
        // upload in progress
        upload.progress = (uploadTask.snapshot.bytesTransferred / uploadTask.snapshot.totalBytes) * 100;
      },
      // 2.) error observer
      (error) => {
        // upload failed
        console.log(error);
      },
      // 3.) success observer
github Rajan / lesspod / client / vue / src / components / Settings.vue View on Github external
function firebaseUpload(file, logoType, user, onSuccessCallback) {
  const storagePath = `${user.id}/images/${logoType}.jpg`;
  firebase
    .storage()
    .ref(storagePath)
    .put(file)
    .then(snapshot => {
      console.log("image upload success");
      return snapshot.ref.getDownloadURL();
    })
    .then(downloadURL => {
      // you can assign keys for square logo and horizontal logo with downloadURL value here
      // or just provide a callback
      onSuccessCallback(downloadURL);
      // when 'save settings'  is pressed line 314 uploads the key and value (imageurl)
    })
    .catch(error => {
      console.error(error);
      alert(error.message);
github sikidamjanovic / cowrite / src / Components / Profile / DisplayPicUploader.js View on Github external
fileUploadHandler = (file) => {
        var user = firebase.auth().currentUser;
        var userName = user.displayName
        var storageRef = firebase.storage().ref(userName + '/profilePicture/' + file)
        var uploadTask = storageRef.put(file)
        uploadTask.on('state_changed', function(snapshot){
            switch (snapshot.state) {
                case firebase.storage.TaskState.PAUSED: // or 'paused'
                    break;
                case firebase.storage.TaskState.RUNNING: // or 'running'
                    break;
                default: console.log('.')
            }
        }, function(error) {
            message.error('Upload error: ', error)
        }, function() {
            // Handle successful uploads on complete
            uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) {
                user.updateProfile({
                    photoURL: downloadURL
github red-gold / react-social-network / src / data / firebaseClient / index.ts View on Github external
authDomain: process.env.AUTH_DOMAIN,
    databaseURL: process.env.DATABASE_URL,
    projectId: process.env.PROJECT_ID,
    storageBucket: process.env.STORAGE_BUCKET,
    messagingSenderId: process.env.MESSAGING_SENDER_ID
  }

  firebase.initializeApp(config)
} catch (error) {
  console.log('=========Firebase initializer==============')
  console.log(error)
  console.log('====================================')
}

// - Storage reference
export let storageRef = firebase.storage().ref()

// - Database authorize
export let firebaseAuth = firebase.auth
export let firebaseRef = firebase.database().ref()

// - Firebase default
export default firebase
github rexlow / Devent / src / containers / tabContainers / Profile / EditCreatedEvent.js View on Github external
const uploadImage = (uri, mime = 'application/octet-stream') => {
  const storage = firebase.storage(); //declare storage here just for this instance
  return new Promise((resolve, reject) => {
    const uploadUri = Platform.OS === 'ios' ? uri.replace('file://', '') : uri
    const sessionId = new Date().getTime()
    let uploadBlob = null
    const imageRef = storage.ref('images').child(`${sessionId}`)

    fs.readFile(uploadUri, 'base64')
      .then((data) => {
        return Blob.build(data, { type: `${mime};BASE64` })
      })
      .then((blob) => {
        uploadBlob = blob
        return imageRef.put(blob, { contentType: mime })
      })
      .then(() => {
        uploadBlob.close()
github nosisky / Hello-Books / client / components / admin / includes / AdminSideBar.jsx View on Github external
marginTop: -16
			},
			menuIcon: {
				color: '#fff',
				fontSize: 40
			},
			button: {
				backgroundColor: 'rgb(37, 76, 71)',
				color: '#fff',
				float: 'right'
			}
		};
		return (
			<div>
				
				<div>
					<ul id="slide-out">
						<div style="{style.side}">
							<div style="{style.row}">
								<span>
									<h4>
										<i>library_books</i>
										
											Admin
										
									</h4>
								</span>
								<li>
								<p></p></li></div></div></ul></div></div>
github codediodeio / angular-firestarter / src / app / uploads / shared / upload.service.ts View on Github external
private deleteFileStorage(name: string) {
    const storageRef = firebase.storage().ref();
    storageRef.child(`${this.basePath}/${name}`).delete()
  }
}
github EvanBacon / firebase-instagram / utils / uploadPhoto.js View on Github external
return new Promise(async (res, rej) => {
    const response = await fetch(uri);
    const blob = await response.blob();

    const ref = firebase.storage().ref(uploadUri);
    const unsubscribe = ref.put(blob).on(
      'state_changed',
      state => {},
      err => {
        unsubscribe();
        rej(err);
      },
      async () => {
        unsubscribe();
        const url = await ref.getDownloadURL();
        res(url);
      },
    );
  });
}
github fauzihalabe / ionic-3-pizza-app / src / providers / image-upload.ts View on Github external
constructor() {
    this.myPhotosRef = firebase.storage().ref("Images/");
  }