1

According to Spring 19, it should now be possible to upload files as a Guest Community user.

But if you try either of,

  1. <lightning:fileUpload>
  2. . <lightning:input aura:id="fileId" onchange="{!c.handleFilesChange}" type="file" name="file" label="{!v.label}"> along with custom Apex (Without sharing)

it fails to upload files, I tried this against a custom object.

Simple Lightning component example below:

<lightning:fileUpload  aura:id="fileUploader" label= "Documents" multiple="true" 
 recordId="{!v.fdw.app.Id}" onuploadfinished="{! c.handleUploadFinished }"/>

Debug logs for Community guest user seems to be giving error while creating ContentDocumentLink.

Related Debug log trace as below.

02:15:05.0 (6412865)|HEAP_ALLOCATE|[32]|Bytes:4 02:15:05.0 (14733563)|VARIABLE_ASSIGNMENT|[32]|this.Title|"2019-05-02 13_04_59- (10 more) ..."|0x3459e1ce 02:15:05.0 (14800526)|VARIABLE_SCOPE_BEGIN|[32]|cv|ContentVersion|true|false 02:15:05.0 (14824748)|VARIABLE_ASSIGNMENT|[32]|cv|{"Title":"2019-05-02 13_04_59- (10 more) ..."}|0x3459e1ce 02:15:05.0 (14831351)|STATEMENT_EXECUTE|[33] 02:15:05.0 (14863568)|METHOD_ENTRY|[33]||System.EncodingUtil.base64Decode(String) 02:15:05.0 (15366339)|METHOD_EXIT|[33]||System.EncodingUtil.base64Decode(String) 02:15:05.0 (15476425)|VARIABLE_ASSIGNMENT|[33]|this.VersionData|BLOB(14076 bytes)|0x3459e1ce 02:15:05.0 (15484691)|STATEMENT_EXECUTE|[34] 02:15:05.0 (15489332)|HEAP_ALLOCATE|[34]|Bytes:1 02:15:05.0 (15509894)|HEAP_ALLOCATE|[34]|Bytes:31 02:15:05.0 (15577773)|VARIABLE_ASSIGNMENT|[34]|this.PathOnClient|"/2019-05-02 13_04_59 (11 more) ..."|0x3459e1ce 02:15:05.0 (15584954)|STATEMENT_EXECUTE|[35] 02:15:05.0 (15614660)|HEAP_ALLOCATE|[35]|Bytes:8 02:15:05.0 (15625148)|DML_BEGIN|[35]|Op:Insert|Type:ContentVersion|Rows:1 02:15:05.0 (15666572)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 02:15:05.0 (202795736)|DML_END|[35] 02:15:05.0 (202824238)|STATEMENT_EXECUTE|[37] 02:15:05.0 (202834036)|HEAP_ALLOCATE|[37]|Bytes:64 02:15:05.0 (202876533)|HEAP_ALLOCATE|[37]|Bytes:4 02:15:05.0 (202897343)|HEAP_ALLOCATE|[37]|Bytes:7 02:15:05.0 (203255763)|SOQL_EXECUTE_BEGIN|[37]|Aggregations:0|SELECT ContentDocumentId FROM ContentVersion WHERE id = :tmpVar1 02:15:05.0 (219893445)|SOQL_EXECUTE_END|[37]|Rows:1 02:15:05.0 (219933351)|HEAP_ALLOCATE|[37]|Bytes:8 02:15:05.0 (219955124)|HEAP_ALLOCATE|[37]|Bytes:68 02:15:05.0 (220089165)|HEAP_ALLOCATE|[37]|Bytes:8 02:15:05.0 (220109080)|HEAP_ALLOCATE|[37]|Bytes:40 02:15:05.0 (220166834)|HEAP_ALLOCATE|[37]|Bytes:12 02:15:05.0 (220206632)|VARIABLE_ASSIGNMENT|[37]|cv|{"ContentDocumentId":"069N0000001RiTUIA0","Id":"068N0000001RW4sIAG"}|0x6f11b49f 02:15:05.0 (220215545)|STATEMENT_EXECUTE|[38] 02:15:05.0 (220277460)|HEAP_ALLOCATE|[38]|Bytes:4 02:15:05.0 (220480051)|VARIABLE_ASSIGNMENT|[38]|this.ContentDocumentId|"069N0000001RiTUIA0"|0x1b3e677a 02:15:05.0 (220490200)|HEAP_ALLOCATE|[38]|Bytes:1 02:15:05.0 (220525784)|VARIABLE_ASSIGNMENT|[38]|this.ShareType|"V"|0x1b3e677a 02:15:05.0 (220571846)|VARIABLE_ASSIGNMENT|[38]|this.LinkedEntityId|"a0jN0000009bzCbIAI"|0x1b3e677a 02:15:05.0 (220612000)|VARIABLE_SCOPE_BEGIN|[38]|contentLinkDoc|ContentDocumentLink|true|false 02:15:05.0 (220634097)|VARIABLE_ASSIGNMENT|[38]|contentLinkDoc|{"ContentDocumentId":"069N0000001RiTUIA0","ShareType":"V","LinkedEntityId":"a0jN0000009bzCbIAI"}|0x1b3e677a 02:15:05.0 (220640696)|STATEMENT_EXECUTE|[40] 02:15:05.0 (220672740)|HEAP_ALLOCATE|[40]|Bytes:8 02:15:05.0 (220682700)|DML_BEGIN|[40]|Op:Insert|Type:ContentDocumentLink|Rows:1 02:15:05.0 (220713085)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 02:15:05.0 (263227829)|DML_END|[40] 02:15:05.0 (263322419)|EXCEPTION_THROWN|[40]|System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: [] 02:15:05.0 (263712544)|HEAP_ALLOCATE|[40]|Bytes:265 02:15:05.0 (263763674)|METHOD_EXIT|[11]|01pN0000001tiGM|FileUploadController.saveTheFile(Id, String, String, String) 02:15:05.0 (263778390)|SYSTEM_MODE_EXIT|true 02:15:05.0 (264564654)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: []

Class.FileUploadController.saveTheFile: line 40, column 1 Class.FileUploadController.saveChunk: line 11, column 1 02:15:05.0 (264581079)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: []

Any helpful thoughts to get File upload working for Community guest users? Much Appreciated. Thanks!

  • Are you assigning owner of the files uploaded by guest users? – Santanu Boral May 21 at 4:13
  • Hi @SantanuBoral Thanks for comment, Contact record is created first (which is expected parent id of File) and it would be owned by Guest user implicitly. I could see the contact owner as guest community user in SF instance. The error propagated when we try to insert the file. – PasanE May 21 at 4:36

Your Answer

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

Browse other questions tagged or ask your own question.