Created
          August 21, 2023 13:51 
        
      - 
      
- 
        Save yungwarlock/5c95fd97cb8a6fb273507f66eb497870 to your computer and use it in GitHub Desktop. 
    Uploading a file using file stream to firebase storage
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | // async function uploadCourseThumbnail(path: string) { | |
| // const fileID = createID(); | |
| // const file = storage.file(`${fileID}.png`); | |
| // file.makePublic(); | |
| // return new Promise((resolve, reject) => { | |
| // const publicUrl = file.publicUrl(); | |
| // fs.createReadStream(path) | |
| // .pipe(file.createWriteStream({ | |
| // metadata: { | |
| // contentType: "image/png", | |
| // } | |
| // })) | |
| // .on("error", (err) => { | |
| // reject(err); | |
| // }) | |
| // .on("close", () => { | |
| // resolve(publicUrl); | |
| // }); | |
| // }); | |
| // } | |
| // async function getVideoMetadata(videoPath: string): Promise<ffmpeg.FfprobeData> { | |
| // return new Promise((resolve, reject) => { | |
| // ffmpeg.ffprobe(videoPath, (err, metadata) => { | |
| // if (err) { | |
| // return reject(err); | |
| // } | |
| // resolve(metadata); | |
| // }); | |
| // }); | |
| // } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment