How to store multipart form data attachment in azure storage account from Azure APIM with filename

Faraz Ahmed SH Shaikh 1 Reputation point
2023-09-19T06:58:56.49+00:00

Our Mobile App is uploading user attachments and storing it in an SQL table using a function App backend API. We now want to change the flow to MobApp-APIM-Storage Account. We have been able to store and retrieve the attachments through APIM and Storage Account APIs but are struggling with attachment information. Foll is how the input looks

POST Request-Content-Type multipart/form-data; boundary=oUBB7xpVogYp5Ye.iuLqgWTuE-4P0ViXB6_GTvp1g78MCdQtHRrKCy-DHRF0MNM2eGEW_Z

--oUBB7xpVogYp5Ye.iuLqgWTuE-4P0ViXB6_GTvp1g78MCdQtHRrKCy-DHRF0MNM2eGEW_Z content-disposition: form-data; name="document"; filename="other-doc.jpg" content-type: image/jpeg

����...`��

We need to store (if required) separately as metadata and return these fields in response as follows

Get Attachment Response { "attachmentName": "optionaldoc2.jpg", "attachmentType": "jpg", "attachmentData": "/9j/4AAQSkZ.....HoACSDSIAo//Z", "createdAt": "2022-11-19T20:11:44.05", "updatedAt": "2022-11-19T20:11:44.05" }

Specifically, we are not sure how to retrieve the fields name="document"; filename="other-doc.jpg" from input, store it and return in Get call.

Referred to the foll links but did not help.

https://github.com/Azure/api-management-policy-snippets/blob/master/policy-expressions/README.md https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,428 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
1,954 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 16,046 Reputation points
    2023-09-19T19:37:20.98+00:00

    Faraz Ahmed SH Shaikh Thanks for posting your question in Microsoft Q&A. The multipart/form-data is not currently supported in the policy expressions and our product team has a backlog item to implement this feature. I suggest you upvote the idea: multipart form-data available in feedback forum and see similar discussion around this topic (also other discussion).

    However, you can upload multipart/form-data content via APIM and forward to the backend APIs (Storage APIs for example) but unfortunately, retrieving the results back is not possible.

    I hope this helps and let us know if any questions.