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

Support base64-encoded image in either generate route #389

Open
mergu opened this issue Dec 25, 2023 · 1 comment
Open

Support base64-encoded image in either generate route #389

mergu opened this issue Dec 25, 2023 · 1 comment

Comments

@mergu
Copy link

mergu commented Dec 25, 2023

Is your feature request related to a problem? Please describe.
I'm attempting to make use of this API in a semi-restrictive environment, and only have reliable access to the base64-encoded image. When trying to pass the decoded image to mineskin, I receive generation failures. Confirmed the image is ok by uploading through the mineskin UI manually. I assume the problem here is utf-8 encoding done to my payload, which is out of my control.

I have also tried to use the generate/url route using a Data URL https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs, but one of the checks before pulling the texture fails and I receive {"success":false,"errorType":"GeneratorError","errorCode":"invalid_image_url","error":"Failed to find image from url","nextRequest":1703510085.607,"delayInfo":{"seconds":6,"millis":6000}}.

The data url was {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABAklEQVR4Xu3VMQ7CMAyF4VyBgZmBialsrIiFC3RmRuycH3CFJeu1SZlKUv2fZAFJg+xHJFKa8bx2r1I9zsdi6fc1RwfW0oG19PuaUxqytEcABEAA6wng8zJZBLCGAPRvzSsOcU+70fC21nf70Tkte6ZP2+H5WLZ2Ox3+H5A3as3E0nUbJH2Hnxpcz8eqOgBtVgOIA9rgdiPivp7TGm5BzQH4NdfGfT2G4AHEtV/OVx2ANpyrOHAcfK5KAdie9rM4bdhLg/Hrru/1OT1/SZtsALan/SxubgAf2H91WysF4J+bCcCH08b1yucCyJ1vJgAAAAAAAAAAAAAAAAAAAAAAALA6b27DnSK0ejouAAAAAElFTkSuQmCC"}

Describe the solution you'd like
I'd like either of the routes to support base64-encoded images. This is generally a more http-friendly format of data, compatible with any client. The easiest fix I believe would be supporting a data url in here - https://github.com/MineSkin/api.mineskin.org/blob/master/src/generator/Generator.ts#L864

Describe alternatives you've considered
I have considered uploading to another API, most support base64-encoded images such as the imgur api, and using the url. I would prefer not doing the extra hop.

@mergu
Copy link
Author

mergu commented Dec 25, 2023

An update on this, I've been able to successfully upload the png using some reflection hackery. Have also reported it to the plugin I'm using to make generic web requests with. Still think a base64 option would be handy but not necessary for myself anymore

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

1 participant