1

I am using signature_pad for my MEAN application.

Question: How do I save this to the mongoDB using toDataURL()?

The URL implies the signature image is saved to a server. I’m assuming it is saved to my local server. Is that accurate? When I send this image to the db, how do I send the actual image and not just a string (URL address)? Do I http get the url returned from toDataURL() and then send the returned image to the mongodb?

jinan
  • 173
  • 9

2 Answers2

0

Signature pad created the image on the fly using a JSON object that describes the relationship of the (x,y) points in on the "pad." You'd need to save the png first and then store it unless he added a "save image" kind of method to his API :). You could also just save the data and then use signature pad to render it when needed!

As for which database it's being stored in, this depends on how your mongo client is configured..check out the configuration if you have access to it and if you didn't configure it check the defaults.

MiiinimalLogic
  • 770
  • 5
  • 11
0

In the signature_pad library, toDataUrl() will return a base64 encoding of your signature pad. Looks something like "data:image/png;base64,iVBORw0KGgoAAAA...".

You can store this encoded format into your database. Later, the encoded string can be rendered as is in html or converted into a jpg or other format.

The encoded string is somewhat large. You should be considerate of the impact it will have on your database size.