FsHttp
FsHttp copied to clipboard
Allow filename metadata with other "parts" like bytearray or stream
I am using the following code with Telegram:
http {
POST $"https://api.telegram.org/bot%s{apiTelegramKey}/sendPhoto"
query [ "chat_id", telegramChatId
"caption", caption
"parse_mode", "MarkdownV2" ]
multipart
part (ContentData.ByteArrayContent weather) (Some "image/jpeg") "photo"
And it seems to hit that bot API correctly, a filename parameter is required in addition to the fieldname (photo).
Is there a way to do this that doesn't rely on having to save the byte[] or stream to disk and then use the existing filePart DU?
Hi @lithiumfrost - sorry for the late reply. I'll have a look at this soon...
@lithiumfrost I don't understand the question. What exactly should be possible? In general, it's not neseccary to have anything saved to disk. Or: Is the question about content type "guessing", so that (Some "image/jpeg")
could omitted?
Happy to explain.
The MIME "part" in a multipart form-data submission has multiple pieces of metadata:
------WebKitFormBoundaryN8Y1MQiNiQs7fEEd
Content-Disposition: form-data; name="images"; filename="testfile1.txt"
Content-Type: text/plain
Hello World, no trailling newlines
------WebKitFormBoundaryN8Y1MQiNiQs7fEEd
I can provide the mime-type, but I can't provide the filename value in the header (the third header value in the example) which is required by telegram in the API call. I believe that it's the same specification as a web browser has.