Thursday, 8 June 2017

Node.js get filename from URL

I have a URL that contains a file. I am grabbing the buffer of the file with the following code below. How do I get the filename and extension from the buffer "data" below? Example fileURL (puppy picture with a filename and extension of "dog.png").

          const https = require('https');

          https.get(fileURL, function(response) {
             var data = [];


             response.on('data', function(chunk) {
                data.push(chunk);
             }).on('end', function(){
             });

          });



via Jim M

No comments:

Post a Comment