base64 encode image host url or server file path

user1775888

When I encode image data to a base64 string I use the server file path to get the image data with fs.readFile(). I have question: does this mean other people can decode the base64 string then get the server path from the encoded data as below?

...
fs.readFile(destinationFilePath, function(error, data){
  fulfill(data.toString('base64'));
});

I don't want to leak my server path to so I also tried encode the host url like below code, I'm not sure this correct way to use base64? and I don't get any error but also I got no response - did I miss something?

var base64EncodeData = function(destinationFilePath) {
  return new Promise(function (fulfill, reject){
      var request = require('request').defaults({ encoding: null });
      request.get(destinationFilePath, function (error, response, body) {
        if (!error && response.statusCode == 200) {
          data = "data:" + response.headers["content-type"] + ";base64," + new Buffer(body).toString('base64');
          console.log(data);
          fulfill(data);
        }
      });
  });
};
David

No you don't leak your server path by base64 encoding images. The base64 you are generating only includes a base64 representation of the binary image data. Indeed by base64 encoding them you remove any use of a path when you display them within a HTML page for example:

<img alt="base64 image" src="data:image/png;base64,isdRw0KGgot5AAANdSsDIA..." />

The src attribute contains a flag that data is being provided data: the file mimetype image/png; the encoding base64, and the encoded image data isdRw0KGgot5AAANdSsDIA....

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Encode image from URL in Base64 in Java

From Dev

Uploading A Base64 encode Image to php server

From Dev

Base64 Encode Image and Save it later to a file

From Dev

Base64 Encode Image and Save it later to a file

From Dev

Encode image file to base 64

From Dev

How to encode an image resource to base64?

From Dev

Encode a ImageMagick image with Base64

From Dev

Angular 2 encode image to base64

From Dev

How to cache base64 encode image

From Dev

How to encode an image resource to base64?

From Dev

Encode an image as a base64 string in MATLAB

From Dev

Vba Excel. Resize image when loaded from file and then encode it base64

From Dev

Base64 encode file and OutOfMemory error

From Dev

Encode zip file to Base64

From Dev

Base64 encode file by chunks

From Dev

PHP base64 encode a pdf file

From Dev

Carrierwave encode file to base64 as process

From Dev

Encode file as base64 and send to API

From Dev

Given a URL, how to encode a file's contents as base64 with Python / Django?

From Dev

i Have the local path of image in xcode and i want it to covert the image into base64 and send it to the php file

From Dev

What is the best way to send image file to server: as base64 or image file?

From Dev

angularJS make binary data image from base64 and send as image file to server

From Dev

Cordova/Ionic app uploading base64 image to S3 via server signed url

From Dev

phonegap: Couldn't encode image to base64 on android 2.3

From Java

How to base64 encode image in linux bash / shell

From Dev

Summernote - Image url instead of Base64

From Dev

Download the image by url , or convert it with base64

From Dev

perl base64 encode with url safe characters

From Dev

how to upload image in base64 on server

Related Related

  1. 1

    Encode image from URL in Base64 in Java

  2. 2

    Uploading A Base64 encode Image to php server

  3. 3

    Base64 Encode Image and Save it later to a file

  4. 4

    Base64 Encode Image and Save it later to a file

  5. 5

    Encode image file to base 64

  6. 6

    How to encode an image resource to base64?

  7. 7

    Encode a ImageMagick image with Base64

  8. 8

    Angular 2 encode image to base64

  9. 9

    How to cache base64 encode image

  10. 10

    How to encode an image resource to base64?

  11. 11

    Encode an image as a base64 string in MATLAB

  12. 12

    Vba Excel. Resize image when loaded from file and then encode it base64

  13. 13

    Base64 encode file and OutOfMemory error

  14. 14

    Encode zip file to Base64

  15. 15

    Base64 encode file by chunks

  16. 16

    PHP base64 encode a pdf file

  17. 17

    Carrierwave encode file to base64 as process

  18. 18

    Encode file as base64 and send to API

  19. 19

    Given a URL, how to encode a file's contents as base64 with Python / Django?

  20. 20

    i Have the local path of image in xcode and i want it to covert the image into base64 and send it to the php file

  21. 21

    What is the best way to send image file to server: as base64 or image file?

  22. 22

    angularJS make binary data image from base64 and send as image file to server

  23. 23

    Cordova/Ionic app uploading base64 image to S3 via server signed url

  24. 24

    phonegap: Couldn't encode image to base64 on android 2.3

  25. 25

    How to base64 encode image in linux bash / shell

  26. 26

    Summernote - Image url instead of Base64

  27. 27

    Download the image by url , or convert it with base64

  28. 28

    perl base64 encode with url safe characters

  29. 29

    how to upload image in base64 on server

HotTag

Archive