I am using the attachment control to save files to sharepoint using this code
Set(VarDemoFromAttachmentControl;JSON(Image8.Image;JSONFormat.IncludeBinaryData))
;;Set(VarImage;Image8.Image)//
;;Set(Base64Only;Mid(VarDemoFromAttachmentControl;Find(",";VarDemoFromAttachmentControl)+1;Len(VarDemoFromAttachmentControl)-Find(",";VarDemoFromAttachmentControl)-1))
;;Set(VarFileName;Last(AttachmentControl.Attachments).Name)
;;UpdateContext({lOmschrijving:VarFileName})
;;Set(VarFileLink;PowerAppsToSharePoint_3.Run(Last(AttachmentControl.Attachments).Name;Base64Only).sharepointfilelink)
;;Reset(AttachmentControl)
;;Reset(TextInput8)
I got from a Sean Young video.
I found that if I get a file of which the filename already exists it is just overwritten without any warning.
I tried doctoring the filename with a piece of guid
Set(VarDemoFromAttachmentControl;JSON(Image8.Image;JSONFormat.IncludeBinaryData))
;;UpdateContext({FileGUID:Right(GUID();6)})
;;Set(VarImage;Image8.Image)//
;;Set(Base64Only;Mid(VarDemoFromAttachmentControl;Find(",";VarDemoFromAttachmentControl)+1;Len(VarDemoFromAttachmentControl)-Find(",";VarDemoFromAttachmentControl)-1))
;;Set(VarFileName;Last(AttachmentControl.Attachments).Name)
;;UpdateContext({lOmschrijving:VarFileName})
;;Set(VarFileLink;Substitute(PowerAppsToSharePoint_3.Run(Last(AttachmentControl.Attachments).Name;Base64Only).sharepointfilelink;Last(AttachmentControl.Attachments).Name;FileGUID & Last(AttachmentControl.Attachments).Name))
;;Reset(AttachmentControl)
;;Reset(TextInput8)
but it just saves with the same name although variable varfilelink does look good.
If I add the guid to the back of varfilelink (molesting the file extension) it DOES save the file with the wrong extention to sharepoint.
Of course this can all be easily solved, just a trifle, but .. how?
Solved! Go to Solution.
Already found a soulution. Only accept extentions eh? Well just Add the guid and then the .extention again. An unique filename at last
Already found a soulution. Only accept extentions eh? Well just Add the guid and then the .extention again. An unique filename at last
Hi,
Thanks for sharing 🙂
I done a similar thing with the same video.
Did you find how to name the file using the TextInput without making the file unusable??
Can you direct me to where in the code did you manage to do it?
What I did:
if a file is called
dog.jpg
and you wish to name it dog123GUID123.jpg
it does not work (will not save)
but if you name it
dog.123GUID123
It will work but then te file is unusable because of wrong extention (will not open)
So I call it (just paste guid and .ext on at the end)
dog.jpg123GUID123.jpg
And then all is fine Only the text after the last point is considered to be extention.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
206 | |
187 | |
82 | |
51 | |
37 |
User | Count |
---|---|
288 | |
244 | |
121 | |
75 | |
55 |