web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Saving multiple attach...
Power Apps
Answered

Saving multiple attachment controls files into a sharepoint library

(1) ShareShare
ReportReport
Posted on by 72

Good day,

 

I'm creationg a power app that has a "form" that contains multiple attachment controls.
at the end of the form I have created a button that creates a collection with the names and values of each attachment control and format it to Json Payload that includes binary data.

(Please mind that code is in France Regional syntax):

 

The button code:

 

// Clear the existing collection
ClearCollect(
 attachmentnames;
 // Check if doc_1 has an attachment and add it to the collection if it does
 If(CountRows(doc_1.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_1.Attachments).Name; Content: JSON(First(doc_1.Attachments).Value)});
 // Repeat for each attachment control
 If(CountRows(doc_2.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_2.Attachments).Name; Content: First(doc_2.Attachments).Value});
 If(CountRows(doc_3.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_3.Attachments).Name; Content: First(doc_3.Attachments).Value});
 If(CountRows(doc_4.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_4.Attachments).Name; Content: First(doc_4.Attachments).Value});
 If(CountRows(doc_5.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_5.Attachments).Name; Content: First(doc_5.Attachments).Value});
 If(CountRows(doc_6.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_6.Attachments).Name; Content: First(doc_6.Attachments).Value});
 If(CountRows(doc_7.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_7.Attachments).Name; Content: First(doc_7.Attachments).Value});
 If(CountRows(doc_8.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_8.Attachments).Name; Content: First(doc_8.Attachments).Value});
 If(CountRows(doc_10.Attachments) > 0; {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_10.Attachments).Name; Content: First(doc_10.Attachments).Value})
);;

// Convert collection to JSON
Set(
 jsonPayload;
 JSON(attachmentnames;JSONFormat.IncludeBinaryData)
);;

 

 

I have created a text canvas to hold the jsonPayload output, and the issue is  that the outcome of the content is a "blob"; here is a wee exemple:

 

 

[{"Content":"\"appres://blobmanager/69fdd2c0485e4e34b9e8c1fd84d36885/29\"","Name":"Pièce d'identité__Serveur Global Protect.txt"}]

 

 

 

When running my flow: I want to be able to save the files in a sharepoint library, and this is where I am blocked.

The flow is supposed to convert the supposed to be "Base64" output of my JsonPayload, and because the Schema is not correct, the flow fails.

 

And I feel like I'm in a dead end.

Any solution to get the "correct format"?
Thanks in advance. 

Categories:
I have the same question (0)
  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    hi @wassimbenammar ,

    you can try this:

    // Clear the existing collection
    ClearCollect(
     attachmentnames,
     // Check if doc_1 has an attachment and add it to the collection if it does
     If(
     CountRows(doc_1.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_1.Attachments).Name, 
     Content: Text(First(doc_1.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     // Repeat for each attachment control
     If(
     CountRows(doc_2.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_2.Attachments).Name, 
     Content: Text(First(doc_2.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     If(
     CountRows(doc_3.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_3.Attachments).Name, 
     Content: Text(First(doc_3.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     If(
     CountRows(doc_4.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_4.Attachments).Name, 
     Content: Text(First(doc_4.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     If(
     CountRows(doc_5.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_5.Attachments).Name, 
     Content: Text(First(doc_5.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     If(
     CountRows(doc_6.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_6.Attachments).Name, 
     Content: Text(First(doc_6.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     If(
     CountRows(doc_7.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_7.Attachments).Name, 
     Content: Text(First(doc_7.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     If(
     CountRows(doc_8.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_8.Attachments).Name, 
     Content: Text(First(doc_8.Attachments).Value, JSONFormat.IncludeBinaryData)}
     ),
     If(
     CountRows(doc_10.Attachments) > 0, 
     {Name: "Pièce d'identité_" & nometprenom.Value & "_" & First(doc_10.Attachments).Name, 
     Content: Text(First(doc_10.Attachments).Value, JSONFormat.IncludeBinaryData)}
     )
    );
    
    // Convert collection to JSON
    Set(
     jsonPayload,
     JSON(attachmentnames, JSONFormat.IncludeBinaryData)
    );
  • wassimbenammar Profile Picture
    72 on at

    @anandm08Thank you for you reply, but that also returns the famous "blob"

  • Verified answer
    wassimbenammar Profile Picture
    72 on at

    I think it was only my understanding how the power automate flow will handle the parse.

    I have intialized a variable that will hold the Schema from the power app input and applied it the parse json.

    And I actually did not need to convert to binary and just use the blob in the content field of the file creation action and it worked just fine.

    I think I was complicating the task a bit too much (a bad habit of a C# er).

    The Schema Used

    {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "Content": {
     "type": "string"
     },
     "Name": {
     "type": "string"
     }
     },
     "required": [
     "Content",
     "Name"
     ]
     }
    }

    the Create file arguments:

     

    wassimbenammar_0-1721126862314.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 600

#2
WarrenBelz Profile Picture

WarrenBelz 478 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard