You are viewing limited content. For full access, please sign in.

Question

Question

Validate PDF headers for Forms attachments

asked on November 15, 2017

We have some wonderful users who, when faced with a file upload that only accepts .PDF, will happily rename their .TXT, .PNG, or whatever and attach that. The file upload doesn't seem to care, but the Save to Repository task will fail with the exception, "PDF header signature not found."

 

My best guess to handle this so far is to add a workflow immediately after the form submission that uses Retrieve Business Process Variables, For Each File, and a C# Script to check the header of the file for the identifying "%PDF-". I'm not sure, though, how the script can interact with the files--are they in the file system somewhere that the workflow user will have access to?

0 0

Replies

replied on April 9, 2019

I have also had this issue and would be interested in seeing a solution to it.

0 0
replied on April 11, 2019

I ended up tracking down the attachments in the Forms database. I'm running this from Workflow:

select
	ad.[file_name]
	,msg = 'not a valid PDF'
	from LF_Forms.dbo.cf_bp_main_instances mi
	inner join LF_Forms.dbo.cf_submissions s
		on mi.bp_instance_id = s.bp_instance_id
	inner join LF_Forms.dbo.cf_form_submissions fs
		on s.submission_id = fs.submission_id
	inner join LF_Forms.dbo.cf_bp_step_form_mapping sfm
		on mi.process_id = sfm.process_id
		and fs.step_id = sfm.step_id
	inner join LF_Forms.dbo.cf_fields f
		on sfm.form_id = f.form_id
		and f.[type] <> 'table-end'
	inner join LF_Forms.dbo.cf_bp_dataset ds
		on f.attribute_id = ds.attribute_id
	inner join LF_Forms.dbo.members m
		on ds.member_id = m.id
	inner join LF_Forms.dbo.cf_bp_data d
		on fs.submission_id = d.submission_id
		and f.attribute_id = d.attribute_id
	inner join LF_Forms.dbo.cf_bp_data_attachment_mapping dam
		on d.bp_data_id = dam.bp_data_id
	inner join LF_Forms.dbo.cf_bp_attachment_data ad
		on dam.attachment_id = ad.attachment_id
	where ad.[file_name] like '%.pdf'
		and convert(varchar(5),attachment,0) <> '%PDF-'
		and mi.bp_instance_id = @instance

 

1 0
replied on April 11, 2019

Thanks for the update!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.