<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mude Shoban Babu</title>
    <description>The latest articles on DEV Community by Mude Shoban Babu (@shoban12).</description>
    <link>https://dev.to/shoban12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1066543%2F35af91ef-20c8-49d6-ae4d-b4a13f15a5f7.png</url>
      <title>DEV Community: Mude Shoban Babu</title>
      <link>https://dev.to/shoban12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shoban12"/>
    <language>en</language>
    <item>
      <title>File upload issue in Chrome browser using exceljs with size more than 400kb</title>
      <dc:creator>Mude Shoban Babu</dc:creator>
      <pubDate>Tue, 19 Dec 2023 18:35:00 +0000</pubDate>
      <link>https://dev.to/shoban12/file-upload-issue-in-chrome-browser-using-exceljs-with-size-more-than-400kb-5f78</link>
      <guid>https://dev.to/shoban12/file-upload-issue-in-chrome-browser-using-exceljs-with-size-more-than-400kb-5f78</guid>
      <description>&lt;p&gt;Hello all,&lt;/p&gt;

&lt;p&gt;I am facing few issues in Rest Service with file upload using &lt;strong&gt;exceljs&lt;/strong&gt; and &lt;strong&gt;@nestjs/common(UploadedFile)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An Excel file size of 6mb is giving issue in &lt;strong&gt;Mozilla Firefox **and **Google Chrome&lt;/strong&gt;, it takes too long time to upload and gives below error (Issue)&lt;br&gt;
&lt;strong&gt;"502 Bad Gateway: Registered endpoint failed to handle the request"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When I am uploading non Excel file(other than Excel file, ex: docx) of any size in &lt;strong&gt;Mozilla Firefox&lt;/strong&gt;, no issues are coming, it giving me INVALID_FILE_FORMAT error, which is right (No issues)&lt;/p&gt;

&lt;p&gt;But When i upload a docx of more than 400kb in &lt;strong&gt;Google Chrome&lt;/strong&gt;, no error coming and code is coming out of execution, actually it should give INVALID_FILE_FORMAT error.(issue)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dependency versions:&lt;/strong&gt;&lt;br&gt;
"@nestjs/common": "8.2.3"&lt;br&gt;
"@nestjs/platform-express": "8.2.3",&lt;br&gt;
"exceljs": "4.3.0",&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code is below:&lt;/strong&gt;&lt;br&gt;
//code &lt;br&gt;
@UseInterceptors(&lt;br&gt;
FileInterceptor("file", {&lt;br&gt;
storage: memoryStorage(),&lt;br&gt;
fileFilter: excelFileFilter,&lt;br&gt;
limits: {&lt;br&gt;
fieldSize: 5 * 1024,&lt;br&gt;
fileSize: 8000000,&lt;br&gt;
},&lt;br&gt;
})&lt;br&gt;
)&lt;br&gt;
&lt;a class="mentioned-user" href="https://dev.to/post"&gt;@post&lt;/a&gt;("uploadFile")&lt;br&gt;
@httpcode(200)&lt;br&gt;
public async processExcelUpload(&lt;br&gt;
@uploadedfile() file: Express.Multer.File&lt;br&gt;
): Promise {&lt;/p&gt;

&lt;p&gt;//this code dont have any issues&lt;br&gt;
const workbook: Excel.Workbook = new Excel.Workbook();&lt;br&gt;&lt;br&gt;
const wb: Excel.Workbook = await workbook.xlsx.load(file.buffer);&lt;br&gt;
const worksheet: Excel.Worksheet = wb.worksheets[0];&lt;br&gt;&lt;br&gt;
.....etc..&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here is the excelFileFilter code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;export const excelFileFilter = (&lt;br&gt;
req: Request,&lt;br&gt;
file: Express.Multer.File,&lt;br&gt;
cb: (ex: HttpException, bool: boolean) =&amp;gt; void&lt;br&gt;
): void =&amp;gt; {&lt;br&gt;
if (!allowedMimeTypesExcel.includes(file.mimetype)) {&lt;br&gt;
return cb(&lt;br&gt;
new HttpException("INVALID_FILE_FORMAT", 400),&lt;br&gt;
false&lt;br&gt;
);&lt;br&gt;
}&lt;br&gt;
return cb(null, true);&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;Please let me know if anyone facing same issue and what is the solution for the same. Many thanks in advance ~Shoban.&lt;/p&gt;

</description>
      <category>exceljs</category>
      <category>nestjs</category>
      <category>typescript</category>
      <category>restapi</category>
    </item>
  </channel>
</rss>
