:+: Code Summary :+:

  1. Storage에 업로드 [ firebase.storage.UploadTask ]
    // File or Blob, assume the file is called rivers.jpg
    var file = ...
    
    // Upload the file to the path 'images/rivers.jpg'
    // We can use the 'name' property on the File API to get our file name
    var uploadTask = storageRef.child('images/' + file.name).put(file);
    
    // Register three observers:
    // 1. 'state_changed' observer, called any time the state changes
    // 2. Error observer, called on failure
    // 3. Completion observer, called on successful completion
    uploadTask.on('state_changed', function(snapshot){
      // Observe state change events such as progress, pause, and resume
      // See below for more detail
    }, function(error) {
      // Handle unsuccessful uploads
    }, function() {
      // Handle successful uploads on complete
      // For instance, get the download URL: https://firebasestorage.googleapis.com/...
      var downloadURL = uploadTask.snapshot.downloadURL;
    });
    
  2. Storage에서 다운로드 (http 주소 얻기) [ firebase.storage.Reference.getDownloadURL() ]
    firebase.storage().child('images/stars.jpg').getDownloadURL().then(function(url) {
      // Get the download URL for 'images/stars.jpg'
      // This can be inserted into an  tag
      // This can also be downloaded directly
    }).catch(function(error) {
      // Handle any errors
    });
    
  3. Storage에서 삭제 [ firebase.storage.Reference.delete() ]
    // Create a reference to the file to delete
    var desertRef = storageRef.child('images/desert.jpg');
    
    // Delete the file
    desertRef.delete().then(function() {
      // File deleted successfully
    }).catch(function(error) {
      // Uh-oh, an error occurred!
    });
    

:+: Study Slide :+:

A. 파일 첨부 메모장

  1. 파일 메모 Step1 (firebase SDK 링크)
  2. 파일 메모 Step2 (DB에 기록하기)
  3. 파일 메모 Step3 (DB에서 읽어오기)
  4. 파일 메모 Step4 (File 객체 가져오기)
  5. 파일 메모 Step5 (파일 업로드)
  6. 파일 메모 Step6 (파일 다운로드)
  7. 파일 메모 Step7 (파일 삭제 및 완성)