ujjwalguptaofficial / JsStore

Simplifying IndexedDB with SQL like syntax and promises
http://jsstore.net/
MIT License
858 stars 110 forks source link

Saving Images #7

Closed akellorich closed 6 years ago

akellorich commented 7 years ago

Hello, I have a base64 string want to save in the db, have tried using the object datatype but gives an error incorrect datatype provided for the column, when I use string datatype the base64 string is trimmed hence cannot be converted to back to an image. How do I go about this

Thanks

ujjwalguptaofficial commented 7 years ago

Hi Can you post the code, so that I can see what is happening. You can also give some url, where I can see code like jsfiddle etc.

akellorich commented 7 years ago

Hi uUjjwal, what is the datatype for storing a long base64 string like this: data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEAYABgAAD/7gAOQWRvYmUAZAAAAAAB/+EN/kV4aWYAAE1NACoAAAAIAAgBMgACAAAAFAAAAG4BOwACAAAACwAAAIJHRgADAAAAAQAFAABHSQADAAAAAQBYAACCmAACAAAAFgAAAI2cnQABAAAAFgAAAADqHAAHAAAHogAAAACHaQAEAAAAAQAAAKMAAAENMjAwOTowMzoxMiAxMzo0ODozMgBUb20gQWxwaGluAE1pY3Jvc29mdCBDb3Jwb3JhdGlvbgAABZADAAIAAAAUAAAA5ZAEAAIAAAAUAAAA+ZKRAAIAAAADNzcAAJKSAAIAAAADNzcAAOocAAcAAAe0AAAAAAAAAAAyMDA4OjAyOjExIDExOjMyOjUxADIwMDg6MDI6MTEgMTE6MzI6NTEAAAUBAwADAAAAAQAGAAABGgAFAAAAAQAAAU8BGwAFAAAAAQAAAVcCAQAEAAAAAQAAAV8CAgAEAAAAAQAADJcAAAAAAAAASAAAAAEAAABIAAAAAf/Y/+AAEEpGSUYAAQEAAAEAAQAA/9sAQwAQCwwODAoQDg0OEhEQExgoGhgWFhgxIyUdKDozPTw5Mzg3QEhcTkBEV0U3OFBtUVdfYmdoZz5NcXlwZHhcZWdj/9sAQwEREhIYFRgvGhovY0I4QmNjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2Nj/8AAEQgAeACgAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYm[…]

Actually it's longer than that

akellorich commented 7 years ago

Or rather how can I emulate BLOB datatype in JsStore

ujjwalguptaofficial commented 7 years ago

Yes it will be better to save file as a blob. I have not added the blob type, so don't specify the data type for now. It should work and you will be able to save the file as a blob.

I will add the blob DataType. Let me know if your code is working or not.

akellorich commented 7 years ago

So what do I put as the datatype for the column?

Thanks

ujjwalguptaofficial commented 7 years ago

DataType is optional, so you can remove it. When you mention datatype - it validates the data for the datatype when you insert or update.

udaychy commented 6 years ago

Checkout these two links: Storing image as blob and Storing image as string

Hopefully this will help you

ujjwalguptaofficial commented 6 years ago

closing - hope the above answer is helpful for you.

ujjwalguptaofficial commented 6 years ago

if you are using blob to store images then datatype will be 'object'.