Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I seperate the file name from the base64 string that is stored in model? #6

Open
GenyaB opened this issue Sep 27, 2017 · 1 comment

Comments

@GenyaB
Copy link

GenyaB commented Sep 27, 2017

e.g. This is what is being returned:
file:foxglovestrawberry.jpeg;data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wCEABAMBg8GBREPDg[...]

This is what I want:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wCEABAMBg8GBREPDg[...]

@Dervisevic
Copy link
Contributor

This can be done with standard JS and regexp

const baseString = "file:foxglovestrawberry.jpeg;data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wCEABAMBg8GBREPDg";
baseString.split(/;(.*)/)[0]; // "file:foxglovestrawberry.jpeg"
baseString.split(/;(.*)/)[1]; // "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wCEABAMBg8GBREPDg"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants