0

This is in a Full Sandbox.

Been using an LWC which I created to accept a .csv file upload. It's been working for months with no issues. Today I went to test a new dataset and received the following error:

Your company doesn't support the following file types: .csv

The code is as follows, but as I said, there has been no problem since it was built:

Code for file upload:

<template>
    <div class="file-upload-div">
        <h1 class="instruction-header">{uploadTitle}</h1>
        <lightning-file-upload
            name="fileUploader"
            accept=[.csv]
            record-id={myRecordId}
            onuploadfinished={handleUploadFinished}
            multiple>
        </lightning-file-upload>
    </div>
</template>

The only suggestions I've seen are related to configuring the 'File Upload and Download Security' in Setup (https://help.salesforce.com/articleView?id=000332030&type=1&mode=1). But .csv is allowed in this page.

Any ideas what could be happening?

6
  • Just want to confirm, this is in your production instance and not a preview sandbox?
    – bpilling
    Jan 19, 2021 at 20:21
  • Sorry for leaving that out. This is in a Full Sandbox.
    – T. Young
    Jan 19, 2021 at 20:26
  • Is there a reason your [.csv] is not ['.csv'] and have you tried specifying this as a variable in the controller instead of directly in markup (I don't know if that would make a difference, but a possibility)? Also, is the full sandbox on a preview instance - i.e is it a spring 21 instance?
    – bpilling
    Jan 19, 2021 at 20:41
  • So I realized the same thing. When I switched .csv to '.csv' in the markup, the compiler threw an error. So I moved it to the controller and deployed. That did the trick! So interesting that it worked for months prior to this. Thank you for your help.
    – T. Young
    Jan 19, 2021 at 21:31
  • Good to know that worked! I have posted my comment as a proper answer in case you would like to vote it up and for an easy answer for anyone stumbling across this in the future.
    – bpilling
    Jan 20, 2021 at 3:25

1 Answer 1

1

Move the [.csv] to a variable in the controller, and then bind this variable to the property. Eg:

In markup:

accept={acceptableFileTypes}

In Controller:

acceptableFileTypes = ['.csv'];

You must log in to answer this question.

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