Web application file Processing for node. js

Source: Internet
Author: User

File System Module

File I/O is encapsulated by standard POSIX functions and requires access to the module using the Require (' FS ')

All of these methods provide both asynchronous and synchronous approaches.

1. Renaming files

var base_dir = __dirname; Copied.

  

2. modify file permissions and file permission properties

  

3. Get file meta information

  

4. Read file data

Fs.realfile (Path,[callback])

5. Verify that the file exists

Fs.exists (Path,[callback])

6. deleting files

Fs.unlink (Path,[callback])

The callback function has only one exception parameter, err

7. File reading and writing

Fs.write (Fd,buffer,offset,lenght,position,[callback]);

FD: Reading data from an FD file

Buffer:buffer buffers

Offset: Address to write to the buffer

Length: Number of data bytes pre-read

Position: Integer variable that identifies the starting position at which to read the file,

If NULL, writes are started from the current position.

[Callback]:(Err,written), how many bytes of data have been written.

  Fs.read (Fd,buffer,offset,lenght,position,[callback]);

  

The buffer parameter can be created by using new buffer in node. js Bufferapi.

Web application file Processing for node. js

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.