Anonymous user cannot upload private file

Created on 27 September 2016, over 8 years ago
Updated 24 February 2025, about 2 months ago

Anonymous users are not able to upload files when the upload destination is set to "private files". This problem does not occur with the basic Drupal core file field, only when file_entity is enabled.

I ran into this problem when creating a job application form where anonymous users should submit their CV. After choosing a file, the file is automatically uploaded and gets a file id. Immediately the file field's ReferenceAccess constraint (\Drupal\Core\Entity\Plugin\Validation\Constraint\ReferenceAccessConstraint) kicks in and throws a validation error: You do not have access to the referenced entity (file: 1). The user is not able to submit the form.

Proposed solution: I'm not sure if this is doable, but ideally the ReferenceAccessConstraint would check if the file entity was created by the anonymous user (session) who is creating the reference, and allow the reference to be created.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇳🇱Netherlands marcvangend Amsterdam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024