[c++ practical project] - cloud backup server

 Project Introduction

  • The cloud backup server can upload files to the server through the browser .
  • And it can be viewed and downloaded through a browser at any time , and the downloading process supports resumable uploads .
  • There is a hotspot management module on the server, which compresses and stores non-hotspot files to save disk space on the server .

 Function introduction of each module of the server

Configuration file management module

  • Manage the configuration file. When the server starts, load the information configured in the configuration file to the server , including the time of the hotspot, the suffix of the compressed file, the port number of the server , etc.

File Information Management Module

  • Manage the uploaded file information , and load the backup file information to the server when the server starts.
  • Backup file information The file information in the backup directory and compressed directory, file information includes file backup path, compression path, compression flag, file size, url, etc.

Hotspot Management Module

  • Continuously poll to check the files in the backup directory . If there is a file in the backup directory that is a non-hot file, then compress the file, put the compressed file in the compressed directory, delete the files in the backup directory, and then upload the file information The compression flag in is set to true , indicating that the file has been compressed.

 communication management module

1.. When the browser sends a get /listshow/ http/1.1 request, the server will give the browser an html page, and the user can download the desired file on this page, or upload the file to the server.

2. When the client sends a get /download/filename http1.1 request to the server, it means downloading the file.

  • First, the server will go to the file information management module to find out whether the file exists .
  • If it exists, it is necessary to determine whether the file is compressed, and if not, directly send the file in the backup directory to the browser .
  • If the file is compressed, decompress the compressed file in the compressed directory and put it in the backup directory, delete the compressed file, and set the compression flag of the file information to false, indicating that the file is not compressed.
  • During the download process, if the download is interrupted for some reason, the re-download will start from the position where it was interrupted last time, and the file will not be re-downloaded.

File download process:

3. When the client sends a post/updown http/1.1 request, it means uploading the file to the server, and the file name and file content are stored in the body of the http request. After the server receives the request, it reads the file name and file data in the http request, creates a new file in the backup directory, puts the data of the file in the new file, and adds new file information to the file information management system.

 Upload function:

After uploading the file, after the hot time has passed, the uploaded file will be compressed from backdir to packdir.

 Project Design

github link: https://github.com/sjp1237/cloudserver

Guess you like

Origin blog.csdn.net/sjp11/article/details/128199634