Posts

Showing posts from July, 2020

How can I use a MediaRecorder object in an Angular application?

Image
MediaRecorder is javascript element comes with native javascript, if your angular application does not show MediaRecorder then you can try any step from below Step1. Install type using this command this will install type for MediaRecorder but at compile time it will show error     npm   install  - D  @ types / dom - mediacapture - record before compile use this syntax to get rid from above error;     declare   var   MediaRecorder :  any ; If you get error after declaring   declare   var   MediaRecorder :  any ; that is "global is not defined" , then add this line to polyfills.js file ( window   as   any ). global  =  window ; Icon credit http://www.myiconfinder.com/icon/commands-media-record-recording-sound-music-voice-song-media-player-button-buttons-android-default-color-music-iphone/726 Angular

How to stream object from AWS S3 to browser using node and angular

Image
1. Create an api get request to node application.   eg:    Get '/api/get-file/:id' 2. Install packages aws-sdk , or express npm i express aws-sdk , leave it if pre- installed. 3. Follow the below code snippet  Aws S3 service provide getObject and createReadStream method. Pass the Params to s3.getObject then use createReadStream. use pipe method in createReadStream and pass the response (res) object to pipe method so it will pipe your stream to response. You can also use file write Stream location to save Stream in file.   var   app  =  require ( 'express' )();   var   aws   =  require ( 'aws-sdk' );   aws . config . update ({  region :   'us-east-1'  });   var   s3  =  new   aws . S3 ({ apiVersion :   '2006-03-01' });   const   BUCKET  =  '<your bucket name>' ;       app . get ( '/api/ge...