[SEE UPDATE AT BOTTOM] I'm using sfdx and a scratch org to develop/test my app, which uses the lightning:fileUpload component in two separate components (one for browser, the other for mobile).

It was working well in both components, then it stopped working in both (I think) at the same time -- and I wasn't changing any code on those components. When I try to upload, it allows me to select a file, then immediately gives me the error:

[selected filename].jpg upload progress is 0% 
Can't upload [selected filename].jpg

I know that error happens if you don't have a recordId to associate the uploaded file to, but I've verified that my recordId has a value (Conversation.Id) by putting {!v.Conversation.Id} in the markup -- and it's there. I've also tested hard-coding an id (both from my custom object, Conversation, and also from a Contact) into the markup -- still get the error.

I thought maybe there was some org setting that had inadvertently changed, so I tried uploading a file from Chatter -- no problem with that. It works perfectly.

Here's the markup I'm using (the lightning:fileUpload part is the same in the other component where it's failing):

<aura:attribute name="accept" type="List" default="['.jpg', '.jpeg','.png','.gif']"/>
<aura:attribute name="multiple" type="Boolean" default="false"/>
<aura:attribute name="disabled" type="Boolean" default="false"/>
<aura:attribute name="sendDisabled" type="Boolean" default="true"/>
<aura:attribute name="Conversation" type="Object"/>
<aura:attribute name="File" type="Object"/>

<lightning:overlayLibrary aura:id="photoSelector"/>
<aura:registerEvent name="FileUploaded" type="c:FileUploaded"/>
<aura:registerEvent name="SendPic" type="c:SendPic" />

<aura:handler name="SelectFile" event="c:SelectFile" action="{!c.onSelectFile}"/>

    <aura:set attribute="title">
            <lightning:icon iconName="utility:photo" size="small" class="icn-orange"/>
            Select Image and Send 

    <c:PhotoList Conversation="{!v.Conversation}"/>

    <aura:set attribute="footer">
        {!v.Conversation.Id} <!-- this is here just to prove it's not null -->
        <lightning:layout horizontalAlign="spread" verticalAlign="center">
                    label= "Upload Image"
                    onuploadfinished="{! c.handleUploadFinished }"/>
                    <lightning:button   label="Cancel" onclick="{!c.cancelModal}"/>
                    <lightning:button   label="Send" variant="brand" disabled="{!v.sendDisabled}" 
                                        iconName="utility:share" iconPosition="right" 

And here's the handleUploadFinished function -- though it never gets that far:

 handleUploadFinished : function(component, event, helper)
    var uploadedFiles = event.getParam("files");
    // alert("Files uploaded : " + uploadedFiles.length);
    var thisFile = uploadedFiles[0];
    if (thisFile.ContentSize > 4900000)
        component.set("v.File", thisFile);
        helper.fireFilesizeError(component, event, helper);
    var fileUploaded = $A.get("e.c:FileUploaded");

The files I'm trying to upload are not especially large (for example, 78 kb), so it's not a filesize issue. Can you spot where I'm going wrong? Or is there some org setting I don't know about?


I deleted some of the files, and as soon as I did, the upload started working again, in both components. So there's nothing wrong with the code. Now the question is... is this a cumulative file size limit? Is this only for scratch orgs, or for all orgs? Is it per user?

1 Answer 1


The default scratch org type when you use force:project:create is basically a Developer Edition, so it has some pretty small limits, including a total of 50 MB of file storage. You should end up with larger limits if you change the scratch org edition to Enterprise in the file config/project-scratch-def.json (I believe it's 250 MB, but I don't have a way to check right now). This is a cumulative limit for files. You can check your used space under Setup > Data Management > Storage Usage. All orgs have some sort of file storage limit. Paid orgs can have their values upped by purchasing additional storage blocks. The basic limits are outlined in Monitor Data and Storage Resources.

  • @sfdxfox, thanks! I just checked... I do have my scratch org definition set to Enterprise, but that still only gives me 50 MB of File Storage. At least I know my code isn't causing the problem. Nov 18, 2018 at 20:39
  • do you know the best way to access File Storage Limit and Usage through Apex? I'm researching and seeing a few threads from as far back as 2012. Bob Buzzard is talking about creating a VF page and then scraping it to pull that data. I'm hoping there's a more direct way now... Nov 18, 2018 at 21:14
  • I found instructions on making a cURL call to get the info: help.salesforce.com/articleView?id=000213191&type=1 and I found your post about cURL to Apex: salesforce.stackexchange.com/questions/67867/…. It seems really crazy to have to make an HTTP call to the org you're in to get the info! Also, I'm not sure how I'd handle auth... Nov 18, 2018 at 21:38
  • @PatMcClellan__c In Lightning, you have to do the named credential approach, which means you'll have to set a password for the scratch org and go through a manual process each time. Or, you can try the Visualforce cheat which some people have also put on github (example). Some day maybe we'll have a real way to do this, but that's not today.
    – sfdcfox
    Nov 18, 2018 at 23:48
  • sorry, I see I messed up your handle above because my hand is so used to typing sfdx! I was hoping to build in a way of disabling uploads when file storage capacity is reached, but I think that's more feature than I need. Nov 20, 2018 at 0:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .