Collections API for PUTing images should not require encoded parameter

RESOLVED FIXED

Status

Marketplace
API
P3
normal
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: basta, Assigned: ashort)

Tracking

Avenir
x86_64
Windows 7
Points:
---

Details

(Reporter)

Description

5 years ago
JSON encoding the body or URL encoding the body is expensive (especially if the image is more than a few hundred KB, which is almost a certainty for desktop-resolution images).

Rather than requiring an "image" parameter, the API should simply accept the image as the request body (as a base64 string). This will eliminate garbage on the client and conceivably improve performance on the server as well (one fewer large decode operation to perform).
(Assignee)

Comment 1

5 years ago
Glad you see it my way. Somebody should've said something on the original bug. :)
Assignee: nobody → ashort
Priority: -- → P3
(Assignee)

Comment 2

5 years ago
The simplest thing seems to be just allowing a PUT of image/* data with no encoding. My understanding of file upload and XHR is that this isn't significantly harder to deal with from JS. Thoughts?
(Reporter)

Comment 3

5 years ago
It's actually a bit of a pain in the ass without encoding because it requires raw access to the XHR, which our requests library doesn't give us out-of-the-box.

Also, if we are going to do live preview/edit like mmaslaney talked about, we'll be doing it from a <canvas>, which means it will be significantly easier to get a data URI than it will be to twiddle an XHR to upload a raw file object.
(Assignee)

Comment 4

5 years ago
then I'm not sure what this bug is about, since PUT to image/ expects a data URI right now.
(Reporter)

Comment 5

5 years ago
Right now, according to the docs, the API expects something that looks like this:

    {"image":"data:image/png;base64,..."}

when it should accept simply:

    data:image/png;base64,...

There's no sense in putting it in a parameter.
(Assignee)

Comment 6

5 years ago
Aha. Got it.
(Assignee)

Comment 7

5 years ago
https://github.com/mozilla/zamboni/commit/2276eeb74
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.