Search Posts

Category: base64

converting image source into file and append the file in rest api

I have an image source , i need to convert it into png file and append it to backend and send. upload is successfull ,but when we retrieve the stored file from backend , it has invalid file format error. I think it was not converted to base64 and because of this we have this issue. I am using $base64 dependency to covert my source. source = “data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAgAElEQVR4Xjy9Z6xlaXYdts6999ycc3o5p6pXVV3V1Xl6unt62CI5nCFFw6RoyIZtSDIMWTb8wyBk2DBgyYZ/CIT+SJRJGDJNWrboiRRnunu6OR0qp5fq5XRzzjkcY+03ozcoVNebV/eee8639157rbV3Kf/kj35XazbbsFrtqJSa2Ns9Qj5XQa8LOOw+mE0O1Kt9WCxOVCtN5HMlmMx==” $scope.uploadFile = function(source){ var imageBase64 = $base64.encode(source); […]

Blob to Base64 in javascript

I have successfully converted my base64 (DATA_URI) image into blob but not able to revert it back. My base64 to blob code look like below for more info look this link. b64toBlob(b64Data, contentType, sliceSize) { contentType = contentType || ”; sliceSize = sliceSize || 512; var byteCharacters = atob(b64Data); var byteArrays = []; for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) { var slice = byteCharacters.slice(offset, offset + sliceSize); var byteNumbers = […]

Download a CSV file in Javascript (or Symfony) from a Base64

I’m using a method to download a CSV file from a Base64. var dlnk = document.getElementById(“myDownloadButton”); dlnk.href = ‘data:application/octet-stream;base64,’ + myBase64; dlnk.click(); It worked until I realized that when the base64 is too long, I have a problem. It will open a white page and it won’t download my CSV file. I think it’s because my base64 is too long. Do you have an alternative in JavaScript or in Symfony 3? Thank you Source: AngularJS

How to upload file.mp3 to firebase storage in ionic?

I am creating an audio recording function in my ionic app. I am using media plugin: $ ionic cordova plugin add cordova-plugin-media $ npm install –save @ionic-native/media I can record the audio and play it successfully like this: constructor(private media: Media,private base64: Base64) { this.file = this.media.create(‘file.mp3’); } record_audio(){ this.file.startRecord(); } to uplaod to firebase I cannot directly upload the file.mp3, looks like I need to convert it to Blob or base64 first so I […]