3

Is it possible to upload files as a guest user in a community?

I am using a lightning web component lighting-file-upload component with a case's id as the recordId. The file upload works for authenticated users, but not for guest users.

I did some research and found the following resources, but still cannot successfully upload files as a guest user:

  1. This salesforce doc entitled Limit Files in Your Community says in a note:

NOTE By default, guest user files are blocked from being uploaded. Once developer customizations (Lightning pages, for instance) have been created, admins can change the settings to let guest users upload files. To enable, go to Setup > General Settings, and select Allow site guest users to upload files.

  1. These Salesforce release notes seem to also indicate that you can enable uploads by checking "Allow site guest users to upload files" in general settings> salesforce file settings.

After enabling this setting, I still have not been able to upload files.

Could I be missing some permissions?

Or does this checkbox/setting only work with the aura component file:upload?

Any other ideas of what is going wrong?

Thanks!

UPDATE: For reference here is the component I am using (I set the recordId with a tracked variable that is generated after a case is created):

<lightning-file-upload
 class="slds-col"
 label="Upload File"
 name="fileUploader"
 onuploadfinished={handleUploadFinished}
 record-id={caseId}
 multiple>
 </lightning-file-upload>
  • 1
    Does your LWC work properly with non-community users? Have you tried putting it on an internal page (eg. Contact Lightning Page)? Can you share the code of your component? – Przemysław Tamoń Dec 3 '19 at 22:47
  • I haven't tested it on an internal page--only in a private and public lightning community page. I will try that and see if it is fruitful in the debugging process – Sarah Ganci Dec 3 '19 at 23:02
  • Does the Guest User have at least a Read access on the Case record? Look at this question for details on permissions required to be able to upload a file on the record. – Jayant Das Dec 3 '19 at 23:09
  • The guest user profile has read and create access for Case Object. Thank you, though! – Sarah Ganci Dec 3 '19 at 23:22
5

I did a quick test and it is indeed possible to upload a file using guest user in a community. Below are further details on your specific questions.


Is it possible to upload files as a guest user in a community?

Yes.

Or does this checkbox/setting only work with the aura component file:upload?

The Org setting is applicable for LWC as well.

Could I be missing some permissions?

As you have confirmed that the Guest User Profile has access to Case object, BUT see below

Any other ideas of what is going wrong?

This is most likely your issue here. The profile permissions enable the CRUD access to Case object. But you will still need to ensure that the Case record being accessed which is defined in record-id is shared with the Guest User at least as Read Only. Unless the Guest User has access to that record, the file upload won't be successful.

| improve this answer | |
  • 1
    Ah this makes sense--thank you for your help, Jayant! I ended up adding a sharing rule on case for guest profile based on case specific criteria. After that, I was able to upload and attach files! Now I am trying to figure out how to give that same user permissions to delete the file they just attached, but I am sure I will figure it out. Thanks again! – Sarah Ganci Dec 4 '19 at 19:20
  • @SarahGanci Happy to help, so glad it worked for you. – Jayant Das Dec 4 '19 at 19:33
  • Be aware that there are security updates that will be enabled in March, that might break this (do for me currently). Hoping to get a solution - success.salesforce.com/0D53A00004inpnJ – Tony White Dec 23 '19 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.