Introduction:-

In this article, we will see how you can use Power Automate flow to get the SharePoint list attachment (zip file) and unzip it. This flow will unzip the files and upload the unzipped files to a SharePoint document library. First flow will get the zip attachment, upload it to document library within a sub site and then it will unzip the files to the same document library. At the end, flow will remove the zip file from the document library and will keep only unzipped files

Trigger

This flow will trigger when item is created or updated in the list which has zip attachment.

Initialize Variables

Initialize variable – Site Title: Title of the site where document library exists.
Initialize variable – Site Url: URL of the site where document library exist.

Get attachments

Use ‘Get attachments’ action of SharePoint to get all list attachments. Pass ID of the item at input.

Get attachment content
Use ‘Get attachment content’ action of SharePoint to get content of each attachment. Pass ID of the item and Id of attachment items(‘Apply_to_each_attachment’)?[‘Id’] as input

Create file
Use ‘Create file’ action of SharePoint to create zip file in document library of subsite.

Pass subsite URL, library name, File Name, and File Content

File Name: items(‘Apply_to_each_attachment’)?[‘DisplayName’]

File Content: body(‘Get_attachment_content’)

Extract folder 

Use ‘Extract folder’ action of SharePoint to unzip files to the documents library. Zip file inside the library is unzipped inside the library.

Source File Path: /Shared Documents/outputs(‘Create_file’)?[‘body/Name’]

Destination Folder Path: /Shared Documents

Delete file:

Use ‘Delete file’ action of SharePoint to delete zip file from the library. Pass Id of zip file to delete.

For any Help or Queries Contact us on info@crmonce.com or +918096556344