CONTENT-TYPE changes and file not readable

Ramprasanth Sakthivelraja 65 Reputation points
2023-08-24T09:13:24.34+00:00

Hi

CONTENT-TYPE of the file (spreadsheet) changes to 'octet-stream', when I try to save email attachments in Azure Storage using Logic Apps.

Kindly help to rectify it.

Thanks in advance.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2023-08-24T12:28:54.5366667+00:00

    @Ramprasanth Sakthivelraja Thanks for reaching out. Can you confirm if you have set the Content-Type correctly as Attachment Content Type as below:

    User's image

    I have tested the same at my end and if I set the Content Type correctly items('For_each')?['contentType'] as above then it is set correctly at the storage blob end as below.

    User's image

    Storage Blob:User's image

    In case if you have validated the above and still facing the issue then please share your workflow screenshot and what value you have specified.


1 additional answer

Sort by: Most helpful
  1. Deepanshukatara-6769 16,565 Reputation points Moderator
    2023-08-24T09:26:18.2433333+00:00

    Use the Content-Type from Email Attachments: In your Logic App, make sure that you are using the correct property from the email attachment to set the Content-Type when saving the file to Azure Storage. You should use the Content-Type property of the email attachment to set the Content-Type of the saved file.

    Logic App Designer: When using the Logic App Designer, make sure that you set the Content-Type of the Azure Blob Storage action based on the value of the Content-Type property of the email attachment.

    1. Expressions: If you are using expressions in Logic Apps, you can use dynamic content to extract the Content-Type from the email attachment and use it in the Azure Blob Storage action. For example:
    
    outputs('Compose')['attachments'][0]['contentType']
    

    Here, outputs('Compose') refers to the output of a previous action (like the "Compose" action that may extract attachments), and [0] refers to the first attachment. Adjust the expressions based on your Logic App configuration.

    Content-Disposition Header: If the Content-Type is still not being preserved, you can also check if the email attachments have the Content-Disposition header set correctly. This header can sometimes influence how the Content-Type is interpreted.

    Explicitly Set Content-Type in Azure Blob Storage Action: As a last resort, you can explicitly set the Content-Type in the Azure Blob Storage action using a constant value, but this might not preserve the original Content-Type from the email attachment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.