amplify-ui icon indicating copy to clipboard operation
amplify-ui copied to clipboard

How to check the file format issues when we upload file using storage browser -AmplifyUI

Open RutujaPhapale opened this issue 10 months ago • 3 comments

Upload a non-CSV file and verify that the appropriate error message is displayed I have tried using the getActionCompleteMessage: (files : File[]) => { return { content : "Please upload a CSV file" , type : "warning"}}, But above warning message appears even when i user upload a CSV file , How can i check the fille format

RutujaPhapale avatar Feb 13 '25 16:02 RutujaPhapale

Hi @RutujaPhapale! Would you mind providing more information on what you are trying to solve with uploading files using our Storage connected component, and what your current approach is? Any sample code on what you are trying to achieve would also be appreciated.

tiffanynwyeung avatar Feb 13 '25 19:02 tiffanynwyeung

Hi @tiffanynwyeung , when a user uploads a non-csv file , message pop-ups-"all files failed to upload", I want to change the message template-"We only acccept CSV files" , I tried changing the function getActionCompleteMessage I have tried using the

getActionCompleteMessage: (files : File[]) => { 
      return { content : "Please upload a CSV file" , type : "warning"}},

But i think this function is responsible for any actions which gets completed though failed, overwrite and message it is giving even when the user uploads a CSV file, I tried giving the logic to check the message format for only .csv but it is not working.

My doubt is how can i check whether the file uploaded is NON-CSV and i will change message only for that.

I did below changes, but then i have to change message for each and every action, for example in below i have not described any message for Pending state then no message is displayed for pending, I want to only alter the failed state, but i need to change all because for other no message is showing.

 return <StorageBrowser
    displayText={{
      UploadView: {
        getActionCompleteMessage: ({ counts }) => {
          if (counts.COMPLETE > 0) {
            return { 
              content: "All files uploaded", 
              type: "success" 
            }
          };
          if (counts.OVERWRITE_PREVENTED > 0) {
            return {
              content: "Overwrite of files is prevented",
              type: "info"
            }
          };
          if (counts.FAILED > 0) {
            return {
              content: "We support only CSV files."
              type: "error"
            };
          }
          return undefined;
        },
}/>

RutujaPhapale avatar Feb 14 '25 04:02 RutujaPhapale

@RutujaPhapale, wanted to follow up here and let you know that we'll convert this issue to a feature request since this is an interesting and valid use case for Storage Browser.

cwomack avatar Feb 17 '25 19:02 cwomack