Logic App - get attachment from Email and put it on Azure File Storage incorrect size on Storage

Mateusz Wygoda 46 Reputation points
2023-08-10T11:54:49.52+00:00

Hello,

I have build Logic App to retrieve attachment from email and put those data to Azure File Storage. I have facing issue that attachment from Email has different size then attachment on Azure File Storage. Additionally attachment created on Azure File Storage are unable to open. I don't retrieve content of the file.

Below flow whitch is retriving data:

User's image

Create file has field to get content from Get Attachemnt component:

body('Get_Attachment_(V2)')?['contentBytes']

User's image

This action is retrieving email in Get Attachement with content:
Payload retrivet on step:

{
  "@odata.context": "Some value",
  "@odata.type": "#microsoft.graph.fileAttachment",
  "@odata.mediaContentType": "image/jpeg",
  "id": "AAMkADkxMjA2MmQxLTNiNGUtNG",
  "lastModifiedDateTime": "2023-08-10T11:10:25Z",
  "name": "SomeName.jpg",
  "contentType": "image/jpeg",
  "size": 24722,
  "isInline": false,
  "contentId": null,
  "contentLocation": null,
  "contentBytes": "Here is Byte content"
}

And on Create file we get body after creation of file:

{
  "createdDateTime": "2023-08-10T11:11:01.0876467+00:00",
  "lastModifiedDateTime": "2023-08-10T11:11:01+00:00",
  "name": "SomeName.jpg",
  "isFolder": false,
  "path": "asdf/SomeName.jpg",
  "fileSize": 27960,
  "id": "13835110831840296960",
  "etag": "\"0x8DB99927B0A5226\"",
  "contentType": "image/jpeg"
}

As you can see Size is different after creation and I don't know why. And file is unable to open on file share.

User's image

I will appreciate if you will be able to help me.

Best Regards,

Mateusz

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

1 answer

Sort by: Most helpful
  1. Mateusz Wygoda 46 Reputation points
    2023-09-19T10:26:47.5466667+00:00

    Hi,

    Solution for this to solve is to put in Create file steps that kind of content:

    "fileContent": {
           "$content": "@body('Get_Attachment_(V2)')?['contentBytes']",
           "$content-type": "application/octet-stream"
    }
    
    
    

    Thanks to that our file has been create in correct way.

    Thank you Microsoft Support to solve this issue.

    Regards,

    Mateusz

    0 comments No comments

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.