Currently if the Public file system is in use for the storage webform uploaded files, those files are publicly accessible to those who have know the URL prior to the full submission of the webform.

My client has requested that I investigate an alternative without changing the file system to private.

The incoming patch(es) does the following:
- Adds an option to have the file stored in the temporary scheme prior to submission.
- If option is in use, files are uploaded the `temporary://webform/...`
- If option is in use, upon the full submission, the file is "renamed" and moved to it's final destination.

Patch(es) incoming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered created an issue. See original summary.

Deciphered’s picture

Find attached patches, one against dev, one against stable (for client usage).

The last submitted patch, 2: temporary_scheme-2907866-7.x-4.15-2.patch, failed testing. View results

Liam Morland’s picture

Status: Needs review » Needs work

Thanks for the patch.

This may need changes because of #2816303: File upload destination should be private files by default if available.

The change to webform.module could just be a change to the conditions of the above 'if' statement.

Under "Save the file to the temporary file system" and in other places, you can use !empty(). Remove the spaces before "temporary_scheme".

It would be great if this had some tests.

Liam Morland’s picture

Category: Task » Feature request
alex.skrypnyk’s picture

Re-rolled #2 against 7.x-4.20

smd_ksu’s picture

This works great but how do I get the temporary, non-submitted files deleted? They remain even after cron run.

smd_ksu’s picture

Sounds like maybe temp files don't get removed until 6hrs later. Will monitor this.

Liam Morland’s picture

Status: Needs work » Needs review

There is more information about file deletion in change record "Files that have no remaining usages are no longer deleted by default".

smd_ksu’s picture

Status: Needs review » Needs work

Following up to confirm the files did get deleted. Great patch. Thanks

Liam Morland’s picture

Why did you switch this to "Needs work"?

smd_ksu’s picture

Status: Needs work » Needs review

I think the comment just defaulted to that status. Not on purpose.

ctlopez’s picture

Status: Needs review » Needs work

I have been struggling with the same problem this patch is for. I have implemented the patch and it looks like it is successfully loading files to the temp location as specified. Two caveats to it though: first as an admin when I go out to the Administer files tab, the temp files still appear. This is remedied by changing the filter to only show public files - not a huge issue but it was a bit confusing until I figured it out.

Secondly, the upload button doesn't appear to work - and I mean that literally. When I as a user select a file to upload and the temporary file structure check is enabled (as per this patch), when I click the upload button to upload a file the button becomes locked, as if it is processing. However, when I go in and check the files as an admin I am able to see the file submitted. So the upload button works but to an end user it appears as if it isn't and thus could cause form reloads or users to give up on submitting the forms. I think that needs to be looked at further.

Liam Morland’s picture

@alex.skrypnyk Thanks for the patch. Does this address the issues raised in #13?

Please put the patch into a merge request.

Liam Morland’s picture

Status: Reviewed & tested by the community » Needs work

My comments in #4 still apply.

Does this address the issues raised in #13?

solideogloria’s picture

solideogloria’s picture

This is actually a core issue.