0

I have created simple component to upload files with following code:

<aura:component implements="force:appHostable" controller="BeetleEyeAssets">


<aura:attribute name="accept" type="List" default="['.jpg', '.jpeg', '.zip']"/>
<aura:attribute name="multiple" type="Boolean" default="true"/>
<aura:attribute name="disabled" type="Boolean" default="false"/>

<lightning:fileUpload  name="fileUploader"
                       label= "Demo Upload"
                       multiple="{!v.multiple}"
                       accept="{!v.accept}"
                       disabled="{!v.disabled}"
                       recordId="abcd"
                       onuploadfinished="{! c.handleUploadFinished }"/></aura:component>

Both my js and apex are empty at the moment. When i try to upload small image i get following error:

error screeen

Can anyone help me please?

  • 2
    Did you actually provide a valid record Id? "abcd" isn't a real Id. – sfdcfox Nov 7 '18 at 18:12
  • Nope i thought it is id i have to add like to html element. Where can i get valid record id? – Thimotty Nov 7 '18 at 18:16
  • If you're using it in recordpages use force:hasRecordId . RecordId is mandatory for lightning:fileupload – codeyinthecloud Nov 7 '18 at 18:25
1

"recordId" must be a valid Salesforce ID. This is either a 15-character case-sensitive string or an 18-character case-insensitive string. This Id represents the record to which the file will be attached. It is a required attribute. If you just want to upload a file that is not attached to a record, you will need to use lightning:input type="file" instead. You can get this Id by performing a query, or from some interfaces like force:recordData or force:hasRecordId.

  • Thank you, sfdcfox, i think that is what i needed exactly :) – Thimotty Nov 7 '18 at 19:11

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.