1

In my code i have tried to upload file from gallery. For that i have used camera plugin and tried to allow only less than 50MB files. Is there any way to restrict the file size while browse from gallery. Below is my code.

this.camera.getPicture({
  quality: 50,
  destinationType: this.camera.DestinationType.FILE_URI, // <== try THIS
  sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
  mediaType: this.camera.MediaType.VIDEO,      
}).then((imageData) => {
}, (err) => {
  console.log(err);
});
Mathankumar
  • 105
  • 1
  • 11
  • The imageData is a base64 string. You could figure out how many bytes it is and error if it is greater than 50 million. Here is something that gets the number of bytes for a base64 string (https://stackoverflow.com/questions/13378815/base64-length-calculation) – Matt Kuhns Jun 01 '18 at 17:15
  • Thanks @MattKuhns. – Mathankumar Jun 04 '18 at 11:54

0 Answers0