Try our conversational search powered by Generative AI!

How can I programatically get all uploaded files for a form that uses the file upload compononent

Vote:
 

Hi!
I need a way to programatically get all uploaded files for a form that uses the "File Upload" component and has the checkbox "store form submissions" checked.

Any suggestions on how to accomplish this?

Best regards!

#187126
Jan 12, 2018 15:41
Vote:
 

Forms store upload files in "Local Asset Folder" of the [File Upload] element. So you can find the element in your form, then list all the content below "Uploaded Files" folder, you will get all the upload files. Below is how you can find the folder:

var assetFolder = _contentAssetHelper.Service.GetOrCreateAssetFolder(elementContentLink);
var folder = _contentRepository.Service.GetChildren<ContentFolder>(assetFolder.ContentLink)
                .FirstOrDefault(f => f.Name.Equals(Constants.FileUploadFolderName));

elementContentLink in this case is your File Upload element's content link.

#187149
Jan 15, 2018 4:25
Vote:
 

Thanks for your reply. I marked it as the answer for my question. I had to change 

_contentRepository.Service.GetChildren<ContentFolder>

to

_contentRepository.Service.GetChildren<MediaData>

In order to get my solution to work as expected.

#187216
Jan 16, 2018 10:34
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.