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

I can get a base64 code for a image, how i can upload this image by base64 code #3832

Closed
rorry121 opened this issue May 19, 2017 · 3 comments

Comments

@rorry121
Copy link

addfiles(imagebase64):Observable {
let url = "http://XXXXX:1337/parse/files/111.jpg"
let addHeader = new Headers();
addHeader.append("X-Parse-Application-Id","XXXXX")
addHeader.append("X-Parse-Master-Key","XXXXX")
addHeader.append("Content-Type","plain/text")
return this.http.post(url, JSON.stringify({_ContentType: 'image/jpeg', base64: imagebase64}),{headers: addHeader})
}

And ,the file upload successfully,but when I open it ,it is string not a jpg ,how to do with it ?

@natanrolnik
Copy link
Contributor

We try to use GitHub issues solely for bug reports. Please use StackOverflow for help questions, and use the correct tags (parse-server, for example).
You can post the link to the question here as well.

@doender
Copy link

doender commented Nov 10, 2017

I have the same issue. I believe this is a bug?

@montymxb
Copy link
Contributor

@doender if you upload an encoded file to parse-server it will not decode it for you. This is not a bug. Whatever is in the file you upload is what the file will retain when you download. If you want your file to to be accessible as a JPG, PNG, PDF, or any other format be sure to set:

  • the appropriate content type (for proper interpretation on download)
  • the file data as it would be read normally, unencoded

If you upload encoded data, like in base64, the file you will get later will be exactly that, base64 encoded data. In that case you would have to decode that data client side first before viewing.

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

4 participants