[SalesForce] lightning:fileUpload bug

[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}"/>

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

    <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">
            <lightning:layoutitem>
                <lightning:fileUpload   
                    name="fileUploader"
                    label= "Upload Image"
                    multiple="{!v.multiple}"
                    accept="{!v.accept}"
                    disabled="{!v.disabled}"
                    recordId="{!v.Conversation.Id}"
                    onuploadfinished="{! c.handleUploadFinished }"/>
            </lightning:layoutitem>
            <lightning:layoutitem>
                <lightning:buttonGroup>
                    <lightning:button   label="Cancel" onclick="{!c.cancelModal}"/>
                    <lightning:button   label="Send" variant="brand" disabled="{!v.sendDisabled}" 
                                        iconName="utility:share" iconPosition="right" 
                                        onclick="{!c.SendImage}"/>
                </lightning:buttonGroup>
            </lightning:layoutitem>
        </lightning:layout>
    </aura:set>
</lightning:card>

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

 handleUploadFinished : function(component, event, helper)
 {
    console.log(component.get("v.Conversation").Id);
    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");
    fileUploaded.fire();
 },

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?


UPDATE

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?

Best Answer

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.