Nodejs Saving file problems

Source: Internet
Author: User

There was a problem with the jar package that I got from the front end:
The md5sum value of the jar package saved to the local management machine is not equal to the correct md5sum value of the upload, and there is no error in the upload process, indicating an error during the save process:
The front end is Base64 transcoding and then putting the contents of the jar into the Request.body[reqtype]:

First the error code:

First decode with Base64:

newBuffer(request.body‘base64‘).toString();

Then use WriteFile's Async method to write to the file:

//保存jar包到本地管理机

=====================================================
Discover the problem:
Nodejs asynchronous write to the file cause the file has not finished writing back, should be changed to synchronous Writefilesync, first write the file and then return. and the ToString () with Base64 decoding is also removed:

varnew‘base64‘);try {    //保存jar包到本地管理机catch(err){    console.log("this is error");    return;}

Nodejs Saving file problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.