cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ankit77
Helper I
Helper I

How to check if the blob already exists in blob container by contents

I have a file which I read from SharePoint folder and upload it in Blob storage using Create Blob action, Now there might be case that this blob is already present. In that case, I would not be running Create Blob action. How can I check if the blob already exists?

 

I cant check by Name, because there can be same name of blob coming in and in that case it will be overwritten in Blob container.

 

Is there a way I check the content of blob with the content of file in SharePoint before using Create Blob action.

 

I used "Get file content using path" and there i get "$content" but in action "Get Blob metadata using path" I get the metadata but in there I dont have "content" and in action "Get Blob content using path" I get the actual file content and not the encoded(base64) value as in $content. So I cant check both these values'

2 REPLIES 2
brricard
Microsoft
Microsoft

Hello,

 

"I cant check by Name, because there can be same name of blob coming in and in that case it will be overwritten in Blob container."

 

I don't see why is this a problem.

 

Example if the name of the blob is the same than the files' name:

Blob1: samplefile

File1: samplefile.pdf

File2: samplefile.png

---

A new file is uploaded to sharepoint;

1) Check file name: samplefile.pdf

2) Check all blobs - list blobs action

3.1) If there is a blob with the same name check the files

a) If there is a file with the same name, do nothing;

b) If there is NO file with the same name, upload it.

3.2) If there is no blob with the same name;

a) Create blob and upload the file.

 

This will work if there is a consistency between blob name and files listed there.

--------

 

Regarding your question, I do see the same behavior between checking content in sharepoint vs get blob connectors; 

 

brricard_0-1620808264389.png

 

Also, please keep in mind we are storing files in different types of data source. If I find a way to compare both outputs (we can use a substring just to compare the first values - part of it are equal) I will share it.

 

Thank you,

BR

Ankit77
Helper I
Helper I

"I cant check by Name, because there can be same name of blob coming in and in that case it will be overwritten in Blob container."
I don't see why is this a problem.

There is a problem, let say I have a file coming in SharePoint as Test1.csv and metadata.csv. These two files are moved to Blob container and later by some functionality, contents of these two files are combined and copied in a Tabular storage. Now I get test2.csv and metadata.csv in SharePoint. Now the metadata.csv is a new file which is overwritten with the existing one in SharePoint. Flow triggers and send these two files in Blob container and I am ok with my metadata.csv replacing the old metadata.csv in Blob container. and later on Test2.csv and new metadata.csv is combined and copied in tabular storage.
There may be scenario where I get only Test3.csv file in SharePoint. In that case test3.csv is combined with last metadata.csv file in SharePoint and since this metadata.csv was already copied in the blob , it replaces it and then both files are combined and copied in tabular storage. So each time i need to check if the metadata file coming in SharePoint already exists in Blob container or not. If it does not exist then I would like to copy it else I would not.and this has to be done by checking the content.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (47,086)