If there was a binary extension, you could return the result and notify the client in the header that some binary format will be coming back. That said, what seems more enticing to me is a JSON API extension. person/1/photo) and provide it a new namespace as to avoid confusion in the future between the spec and special use-cases. Otherwise if you’re doing this OOB, maybe it’s best not to combine it with the JSON API interface (i.e. If you can base64 encode without it making things noticeably less performant, this would likely be the easiest option as your tools could treat this data just like everything else and the client-side can then decode it (knowing that the field is base64-encoded jpeg). I suppose it may come down to the tools you’re using. There would be many ways to do this out-of-band, but all would likely be specific to your particular use case. If base64 encoding becomes infeasible for your use-case, my recommendation would be to do this out-of-band as you suggested (i.e. Consequently, I would not suggest trying to dump raw binary data into your json payload. That said, generally, binary and text-formats don’t play nicely together if you’re not encoding the binary data. Generally speaking, this is a hard question to answer and (as usual) the answer is “it depends.” I imagine you want to link this data to the database in some way? If so, will you be storing it in the DB itself as a blob or will you be pointing to disk? If you don’t want to relate the binary to the database in any way, I assert that JSON API would likely be the wrong solution entirely and you should certainly roll your own as a separation of concern.įor small data, I would not expect base64 encoding to be prohibitively expensive in any way for use with standard JSON API (and you could even store this in the DB as is and have the client-side fix it up when it retrieves it).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |