Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70448

How to encrypt a video file before download it in ionic 3?

$
0
0

@Tourukmakto wrote:

I have develop a videos downloadable app.but downloaded videos only open via my app(Like youtube).so i am decide to encrypt video file before it download. i get video url from api its like http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4. i have to encrypt BigBuckBunny.mp4 file and store to internal storage.im using cryto-js for encrytion.

downloadVideo(url){
    let link = url;
    let path = '';
    let dir_name = 'training_videos';
    let file_name = this.GetFilename(url)+'.mp4';

    let encryted_file=CryptoJS.AES.encrypt(file_name, '123')

    const fileTransfer = this.transfer.create();
  let result = this.file.createDir(this.file.externalRootDirectory+'/ayc/training_videos/', dir_name, true);
result.then((resp) => {
  path = resp.toURL();
  console.log(path);

  fileTransfer.onProgress((progressEvent) => {
    // alert(progressEvent);
  var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
  this.progress = perc;
  // alert(this.progress);
  });

  fileTransfer.download(link, path + encryted_file).then((entry) => {
   alert('download complete: ' + entry.toURL());
  }, (error) => {
    console.log(error)
  });
}, (err) => {
  alert('error on creating path : ' + err);
});
  }

//get file name from url
GetFilename(url)
{
   if (url)
   {
      var m = url.toString().match(/.*\/(.+?)\./);
      if (m && m.length > 1)
      {
         return m[1];
      }
   }
   return "";
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>