-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
create a mime handler for application/vnd.openxmlformats-officedocument.wordprocessingml.document #3089
Comments
Hey @fjf2002, Looks like that media type surpasses PostgreSQL identifier length: CREATE DOMAIN "application/vnd.openxmlformats-officedocument.wordprocessingml.document" AS bytea;
NOTICE: identifier "application/vnd.openxmlformats-officedocument.wordprocessingml.document" will be truncated to "application/vnd.openxmlformats-officedocument.wordprocessingml." As a workaround you could use the "any" handler, which also works on functions as mentioned on #2188 (comment) One solution for this could be allowing to return a wrapper composite type that has an CREATE TYPE spreadsheet_content AS (content bytea, mt excel_mt);
CREATE TYPE excel_mt AS ENUM (
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
, 'application/excel'
);
CREATE OR REPLACE FUNCTION .. RETURN spreadsheet_content .. I don't see other way to define the media statically on the function. |
@steve-chavez: Thanks. Let me see if I get this correctly. Use case: Download a MS Word DOCX file, by means of a function with scalar return type. As far as I understand,
As you said, unfortunately I cannot have a domain type You suggested the workaround with the any handler CREATE DOMAIN "*/*" as bytea; I suppose this hinders me to use an "any handler" for any other function that would be based on any other data type in the whole database (for example, your example with the / xml handler at https://postgrest.org/en/v12.0/references/api/media_type_handlers.html#the-any-handler)? |
@fjf2002 Right, setting the postgrest/src/PostgREST/Plan.hs Lines 1008 to 1010 in 0c65bf4
Yes, correct.
Just fixed that section to use a |
@steve-chavez: Thanks very much for your quick fixes and clarification. That should quite make sense. |
Fixing this on #3103
For now I'll document this is a limitation and recommend using the any handler as workaround. The |
Environment
Description of issue
Hello @steve-chavez,
thanks a lot for reworking the media-type handlers.
Currently I'm trying to understand the docs at https://postgrest.org/en/v12.0/references/api/media_type_handlers.html#handler-function .
The first example does work for me; however when I replace everywhere
application/vnd.twkb
withapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
, I get the errorHTTP/1.1 415 Unsupported Media Type
with bodyI checked that I indeed have created the domain:
What am I doing wrong?
The text was updated successfully, but these errors were encountered: