File storage method
By storing files in master-slave storage servers, the problem of high storage pressure on local databases is solved, server operating speed and business efficiency are improved, and data security is ensured.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING PACTERA JINXIN TECH LTD
- Filing Date
- 2023-08-23
- Publication Date
- 2026-04-24
AI Technical Summary
Storing a large number of files on the local database puts a lot of pressure on the local server's storage, slows down its operation, and affects the efficiency of business processing.
When the primary and secondary storage servers are available, the files to be stored are stored in the first storage directory of at least one server, which reduces the storage pressure on the application server and relieves the pressure in a timely manner when the server is restored to an available state, thereby achieving data backup and fast file retrieval.
It improved the operating speed of the application server, increased the efficiency of related business processing, reduced file download time, and prevented data loss.
Smart Images

Figure CN117194330B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to a file storage method. Background Technology
[0002] Some organizations require clients to provide documents related to the business (such as image files) when processing related business, and store these documents directly in their local database so that they can be retrieved from the database for further business review later.
[0003] However, when a large number of files are stored on the local database, the storage pressure on the local server is high, which may reduce the operating speed of the local server or even cause it to crash, seriously affecting the efficiency of business processing. Summary of the Invention
[0004] This disclosure provides a file storage method to at least partially solve one of the technical problems in related technologies. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a file storage method is provided, applied to an application server, comprising: receiving a file upload request sent by an application client, wherein the file upload request includes a file to be stored; determining a first file type to which the file to be stored belongs, and determining a storage directory for the file to be stored in the application server based on the first file type; responding to the file upload request, determining whether a primary storage server and / or a secondary storage server are in an available state; and, if at least one of the primary storage server and the secondary storage server is in an available state, sending a file storage request to the at least one server, wherein the file storage request includes the file to be stored and the storage directory, and the file storage request is used by the at least one server to store the file to be stored in a first storage directory, wherein the first storage directory is a disk directory to which the storage directory is allowed to link.
[0006] According to a second aspect of the present disclosure, a file storage method is provided, applied to a main storage server, comprising: receiving a file storage request sent by an application server, wherein the file storage request includes a file to be stored and a directory to be stored for the file to be stored in the application server, the directory to be stored being determined by the application server upon receiving a file upload request sent by an application client, determining a first file type to which the file to be stored in the file upload request belongs, and determining based on the first file type, the file storage request is sent by the application server in response to the file upload request and determining that the main storage server is in an available state; determining that the main storage server is in an available state; determining a first storage directory based on the directory to be stored, the first storage directory being a disk directory to which the directory to be stored is allowed to link; and storing the file to be stored in the first storage directory.
[0007] According to a third aspect of the present disclosure, a file storage device is provided, applied to an application server, comprising: a receiving module, configured to receive a file upload request sent by an application client, wherein the file upload request includes a file to be stored; a determining module, configured to determine a first file type to which the file to be stored belongs, and determine a storage directory for the file to be stored in the application server based on the first file type; a judging module, configured to respond to the file upload request and judge whether a primary storage server and / or a secondary storage server are in an available state; and a sending module, configured to send a file storage request to at least one of the primary and secondary storage servers if at least one of the primary and secondary storage servers is in an available state, wherein the file storage request includes the file to be stored and the storage directory, and the file storage request is used by the at least one server to store the file to be stored in a first storage directory, wherein the first storage directory is a disk directory to which the storage directory is allowed to link.
[0008] According to a fourth aspect of the present disclosure, a file storage device is provided, applied to a main storage server, comprising: a receiving module, configured to receive a file storage request sent by an application server, wherein the file storage request includes a file to be stored and a directory to be stored of the file to be stored in the application server, the directory to be stored being determined by the application server upon receiving a file upload request sent by an application client, determining a first file type to which the file to be stored in the file upload request belongs, and determining based on the first file type; the file storage request being sent by the application server in response to the file upload request, determining that the main storage server is in an available state; a determining module, configured to determine a first storage directory based on the directory to be stored, wherein the first storage directory is a disk directory to which the directory to be stored is allowed to link; and a storage module, configured to store the file to be stored in the first storage directory.
[0009] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement a file storage method as described in a first aspect of the present disclosure, or to implement a file storage method as described in a second aspect of the present disclosure.
[0010] According to a sixth aspect of the present disclosure, a computer-readable storage medium is provided, wherein when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform a file storage method as described in the first aspect of the present disclosure, or to implement a file storage method as described in the second aspect of the present disclosure.
[0011] According to a seventh aspect of the present disclosure, a computer program product is provided, comprising: a computer program that, when executed by a processor, implements the file storage method as described in the first aspect of the present disclosure, or implements the file storage method as described in the second aspect of the present disclosure.
[0012] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0013] 1. When at least one of the primary storage server and secondary storage server is available, the file to be stored is stored in the first storage directory of at least one server, which reduces the storage pressure on the application server, improves the running speed of the application server, and thus improves the efficiency of related business processing.
[0014] 2. When at least one of the primary and secondary storage servers is not available, the file to be stored is stored in the storage directory of the application server. When at least one of the primary and secondary storage servers becomes available again, the file to be stored is stored in at least one server. This avoids the situation where the file cannot be stored when at least one server is not available. At the same time, it can promptly reduce the storage pressure on the application server when at least one server becomes available, improve the running speed of the application server, and thus improve the efficiency of related business processing.
[0015] 3. By storing the files to be stored in the disk directory of the primary storage server or the secondary storage server, the files to be downloaded can be quickly located during the download process, improving download speed and thus enhancing the user experience;
[0016] 4. Data synchronization between the primary storage server and the secondary storage server enables backup of the primary storage server in case of failure, thus preventing the loss of business data.
[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0019] Figure 1 This is a schematic flowchart of the file storage method shown in the first embodiment of this disclosure;
[0020] Figure 2 This is a schematic flowchart of the file storage method shown in the second embodiment of this disclosure;
[0021] Figure 3 This is a schematic flowchart of the file storage method shown in the third embodiment of this disclosure;
[0022] Figure 4 This is a schematic flowchart of the file storage method shown in the fourth embodiment of this disclosure;
[0023] Figure 5 This is a schematic flowchart of the file storage method shown in the fifth embodiment of this disclosure;
[0024] Figure 6 This is a schematic flowchart of the file storage method shown in the embodiments of this disclosure;
[0025] Figure 7 This is a schematic diagram of the structure of the file storage device shown in the sixth embodiment of this disclosure;
[0026] Figure 8 A schematic diagram of the structure of a file storage device shown in the seventh embodiment of this disclosure;
[0027] Figure 9 This is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure. Detailed Implementation
[0028] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0029] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0030] It should be noted that the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the technical solution disclosed herein are all carried out with the consent of the user, and all comply with the provisions of relevant laws and regulations, and do not violate public order and good morals.
[0031] The file storage method of this disclosure is described below with reference to the accompanying drawings.
[0032] Figure 1 This is a schematic flowchart illustrating the file storage method according to the first embodiment of this disclosure. It should be noted that the file storage method implemented in this disclosure can be applied to application servers.
[0033] like Figure 1 As shown, the method for storing this file may include the following steps:
[0034] Step 101: Receive a file upload request sent by the application client.
[0035] The file upload request includes the file to be stored.
[0036] In this embodiment of the disclosure, when relevant business personnel handle related business, they need to upload business-related documents (such as scanned copies of ID cards). The business personnel perform the upload operation on the application client to upload the files. Therefore, in response to the upload operation, the application client can send a file upload request to the application server. The file upload request may include the file to be stored.
[0037] The file types to be stored can be images, videos, document files (such as PDF files and Word files), and text files (txt files), etc.
[0038] Step 102: Determine the first file type to which the file to be stored belongs, and determine the storage directory of the file to be stored in the application server based on the first file type.
[0039] In this embodiment of the disclosure, different types of files to be stored are stored in different directories. For example, image files are stored in directory A, video files are stored in directory B, text files are stored in directory C, and document files are stored in directory D.
[0040] As an example, file naming rules can be pre-set, that is, different types of files use different naming rules. For example, image files are named using a set number, such as a scanned copy of an ID card, which is named using the ID card number; and video files are named using the time and video identifier.
[0041] Therefore, the first file type of the file to be stored can be determined according to the naming rules or file extension of the file to be stored. Then, the storage directory of the file to be stored in the application server can be determined according to the first file type. It should be noted that the storage directory can be a disk directory in the application server, such as H:\work\.
[0042] Step 103: Respond to the file upload request and determine whether the primary storage server and / or secondary storage server are available.
[0043] Furthermore, in response to the file upload request, a server self-check procedure is executed to obtain the primary storage server and the secondary storage server to determine whether the primary storage server and / or the secondary storage server are in an available state.
[0044] It should be noted that the application server can record the status of the primary and secondary storage servers in the logs and send the logs to the client. Thus, relevant personnel can check the status of the primary and secondary storage servers based on the logs, and promptly debug or repair the server when the primary or secondary storage server experiences a failure.
[0045] Step 104: If at least one of the primary storage server and the secondary storage server is available, send a file storage request to at least one server.
[0046] The file storage request includes the file to be stored and the directory to be stored. The file storage request is used by at least one server to store the file to be stored in a first storage directory, which is a disk directory that the directory to be stored is allowed to link to.
[0047] It is important to understand that the storage directory in the application server has a mapping relationship with the target in the primary storage server and the secondary storage server. The primary storage server or the secondary storage server can determine the directory where the file to be stored needs to be stored based on the directory to be stored, which is the first storage directory. The first storage directory is the disk directory that the directory to be stored can link to.
[0048] Therefore, if at least one of the primary storage server and the secondary storage server is available, the application server sends a file storage request to the primary storage server. The primary storage server can determine the first storage directory based on the storage directory in the file storage request and store the file to be stored in the first storage directory.
[0049] It should be noted that the first storage directory is the disk directory that the storage directory is allowed to link to. Storing the files to be stored in the disk files makes it easier to quickly find the target files among multiple storage files during file download, thus improving download speed.
[0050] In summary, by receiving file upload requests from application clients, including the file to be stored; determining the first file type of the file to be stored; determining the storage directory of the file on the application server based on the first file type; responding to the file upload request and determining whether the primary storage server and / or secondary storage server are available; and if at least one of the primary and secondary storage servers is available, sending a file storage request to at least one server, including the file to be stored and the storage directory, the file storage request is used by at least one server to store the file to be stored in the first storage directory, which is a disk directory that the storage directory is allowed to link to. Thus, when at least one of the primary and secondary storage servers is available, storing the file to be stored in the first storage directory of at least one server reduces the storage pressure on the application server, improves the operating speed of the application server, and thereby improves the efficiency of related business processing.
[0051] To clearly illustrate how the above embodiments determine whether the primary storage server and / or secondary storage server are in an available state, this disclosure proposes another file storage method.
[0052] Figure 2 This is a schematic flowchart illustrating the file storage method according to the second embodiment of this disclosure. It should be noted that the file storage method implemented in this disclosure can be applied to application servers.
[0053] Step 201: Receive a file upload request sent by the application client.
[0054] The file upload request includes the file to be stored.
[0055] Step 202: Determine the first file type to which the file to be stored belongs, and determine the storage directory of the file to be stored in the application server based on the first file type.
[0056] Step 203: Respond to the file upload request by sending at least one status verification request to both the primary storage server and the secondary storage server.
[0057] As an example, when the application server responds to a file upload request, it simultaneously sends at least one status verification request to both the primary and secondary storage servers, i.e., sends at least one status verification request to attempt to wake up both the primary and secondary storage servers.
[0058] Step 204: In response to receiving a status verification response sent by the primary storage server in response to at least one status verification request, determine that the primary storage server is in an available state.
[0059] In this embodiment of the disclosure, upon receiving a status verification response sent by the primary storage server in response to at least one status request, it can be determined that the primary storage server is in an available state.
[0060] Step 205: In response to receiving a status verification response sent by the storage server in response to at least one status verification request, determine that the storage server is in an available state.
[0061] In this embodiment of the disclosure, upon receiving a status verification response sent by the storage server in response to at least one status verification request, it can be determined that the storage server is in an available state.
[0062] Step 206: If at least one of the primary storage server and the secondary storage server is available, send a file storage request to at least one server.
[0063] The file storage request includes the file to be stored and the directory to be stored. The file storage request is used by at least one server to store the file to be stored in a first storage directory, which is a disk directory that the directory to be stored is allowed to link to.
[0064] As an example, when the primary storage server is available, a file storage request is sent to the primary storage server. This file storage request is used to store the file to be stored in the first storage directory of the primary storage server. Then, it is determined whether the secondary storage server is available. If the secondary storage server is available, a file synchronization request is sent to the secondary storage server. This file synchronization request includes the file to be stored and the first storage directory, and is used by the secondary storage server to synchronize the file to be stored to the first storage directory. Conversely, if the primary storage server is unavailable and the secondary storage server is available, a file storage request is sent to the secondary storage server. This file storage request is used to store the file to be stored in the first storage directory of the secondary storage server.
[0065] In other words, when the primary storage server is available (e.g., both the primary and secondary storage servers are available), or when the primary storage server is available but the secondary storage server is unavailable, a file storage request is sent to the primary storage server. The primary storage server then stores the file to be stored in its own first storage directory. Additionally, the primary storage server can determine whether the secondary storage server is available. If the secondary storage server is available, the primary storage server sends a file synchronization request to it. This file synchronization request includes the file to be stored and the first storage directory, and is used by the secondary storage server to synchronize the file to be stored to the first storage directory. Conversely, if the primary storage server is unavailable but the secondary storage server is available, the primary storage server sends a file storage request to the secondary storage server, and the secondary storage server stores the file to be stored in its own first storage directory.
[0066] It should be noted that the main storage server can receive file storage requests from multiple application servers simultaneously. The main storage server can store the files to be stored from multiple application servers to the corresponding storage directory, enabling file aggregation, merging, and file sharing.
[0067] Furthermore, to prevent files from being unstorable when both the primary and secondary storage servers are unavailable, the file to be stored is stored in the specified directory if at least one of the primary and secondary storage servers is available. Once at least one of the primary and secondary storage servers becomes available again, the file storage request is resent to at least one server to ensure the file is stored on that server. For example, after both the primary and secondary storage servers are unavailable, the application server can send at least one status verification request to both servers at set intervals. Upon receiving a status verification response from the primary storage server in response to at least one status verification request, the primary storage server is confirmed to be available again. Similarly, upon receiving a status verification response from the secondary storage server in response to at least one status verification request, the secondary storage server is confirmed to be available again.
[0068] In summary, by responding to the file upload request, at least one status verification request is sent to both the primary and secondary storage servers; upon receiving a status verification response from the primary storage server in response to at least one status verification request, it is determined that the primary storage server is in an available state; and upon receiving a status verification response from the secondary storage server in response to at least one status verification request, it is determined that the secondary storage server is in an available state. Thus, sending at least one status verification request to both the primary and secondary storage servers improves the accuracy of determining whether the primary and secondary storage servers are in an available state.
[0069] To enable file download functionality, in this embodiment of the disclosure, the application server can also obtain the file to be downloaded from at least one server, provided that at least one of the primary storage server and secondary storage servers is available. The following describes the process in conjunction with... Figure 3 Please provide a detailed explanation.
[0070] Figure 3 This is a schematic flowchart of the file storage method shown in the third embodiment of this disclosure.
[0071] like Figure 3 As shown, the method for storing this file may include the following steps:
[0072] Step 301: Receive the first file download request sent by the application client.
[0073] The first file download request includes the target file identifier of the file to be downloaded.
[0074] Step 302: In response to the first file download request, determine the second file type to which the file to be downloaded belongs based on the target file identifier, and determine the query directory to which the file to be downloaded belongs based on the second file type.
[0075] Step 303: Determine whether the primary storage server and / or secondary storage server are in an available state.
[0076] Step 304: If at least one of the primary storage server and the secondary storage server is available, send a second file download request to at least one server.
[0077] The second file download request includes a directory to be queried and a target file identifier. The second file download request is used to obtain a first target file that matches the target file identifier in the second storage directory and send the first target file to the application server. The second storage directory is a disk directory that the directory to be queried is allowed to link to.
[0078] In this embodiment of the disclosure, when at least one of the primary storage server and the secondary storage server is available, a second file download request is sent to at least one server to obtain the file to be downloaded from the at least one server.
[0079] As an example, when the primary storage server is available, a second file download request is sent to the primary storage server, wherein the second file download request is used to obtain a first target file that matches the target file identifier in the second storage directory of the primary storage server; when the primary storage server is unavailable, a second file download request is sent to the secondary storage server, wherein the second file download request is used to obtain a first target file that matches the target file identifier in the second target directory of the secondary storage server.
[0080] In other words, when the primary storage server is available, a second file download request is sent to the primary storage server to search for a first target file that matches the target file identifier in the secondary storage directory of the primary storage server. If a first target file that matches the target file identifier exists in the secondary storage directory of the primary storage server, the first target file is sent to the application server, and the application server sends the first target file as a download file to the application client. When the primary storage server is unavailable, a second file download request is sent to the secondary storage server to search for a first target file that matches the target file identifier in the secondary storage server's secondary storage directory. If a first target file that matches the target file identifier exists in the secondary storage server's secondary storage directory, the first target file is sent to the application server, and the application server sends the first target file as a download file to the application client.
[0081] As another example, if at least one of the primary storage server and secondary storage servers is not available, the system queries the directory to be queried to see if a second target file matching the target file identifier exists. If a second target file matching the target file identifier exists in the directory to be queried, the second target file is sent to the application client as a file to be downloaded. If no second target file matching the target file identifier exists in the directory to be queried, target information is sent to the application client, wherein the target information is used to indicate that the download of the file to be downloaded has failed.
[0082] In other words, when both the primary storage server and the secondary storage server are unavailable, the system checks whether a second target file matching the target file identifier exists in the query directory on the application server. If a second target file matching the target file identifier exists in the query directory, the second target file is sent to the application client as a file to be downloaded. If no second target file matching the target file identifier exists in the query directory, target information is sent to the application client, whereby the target information indicates that the download of the file to be downloaded has failed.
[0083] Step 305: Receive a first target file sent by at least one server, and send the first target file as a file to be downloaded to the application client.
[0084] In this embodiment of the disclosure, when a first target file matching the target file identifier exists in the second storage directory of at least one server, at least one server may send the first target file to the application server, and the application server may send the first target file as a file to be downloaded to the application client.
[0085] In summary, the process involves receiving a first file download request from an application client, wherein the first file download request includes a target file identifier for the file to be downloaded; responding to the first file download request, determining the second file type to which the file to be downloaded belongs based on the target file identifier, and determining the query directory to which the file to be downloaded belongs based on the second file type; determining whether the primary storage server and / or the secondary storage server are available; and if at least one of the primary and secondary storage servers is available, sending a second file download request to at least one server, wherein the second file download request includes the query directory and the target file identifier, and the second file download request is used to... The first target file matching the target file identifier is retrieved from the second storage directory and sent to the application server. The second storage directory is a disk directory that the query directory allows links to. The application server receives the first target file sent by at least one server and sends it as a file to be downloaded to the application client. Thus, when at least one of the primary and secondary storage servers is available, the application server queries the disk directories that the query directory allows links to from at least one server to see if the first target file matching the target file identifier is stored, improving file query efficiency. This improves download speed when the first target file exists on at least one server.
[0086] To implement the above embodiments, this disclosure proposes another file storage method.
[0087] Figure 4 This is a schematic flowchart illustrating the file storage method according to the fourth embodiment of this disclosure. It should be noted that the file storage method of this embodiment can be applied to a main storage server.
[0088] like Figure 4 As shown, the method for storing this file may include the following steps:
[0089] Step 401: Receive a file storage request sent by the application server.
[0090] The file storage request includes the file to be stored and the directory on the application server where the file to be stored is located. The directory is determined by the application server upon receiving the file upload request from the application client, based on the first file type of the file to be stored in the file upload request. The file storage request is sent by the application server in response to the file upload request, after determining that the main storage server is in an available state.
[0091] In this embodiment of the disclosure, in response to a user upload operation, the application client sends a file upload request to the application server. When the application server receives the file upload request from the application client, it can determine the storage directory of the file to be stored on the application server based on the first file type to which the file to be stored belongs in the file upload request. In response to the file upload request, the application server can determine whether the primary storage server and / or secondary storage server are in an available state, and if the primary storage server is in an available state, it sends a file storage request to the primary storage server. The file storage request may include the file to be stored and the storage directory of the file to be stored on the application server.
[0092] Step 402: Determine the first storage directory based on the directory to be stored.
[0093] The first storage directory is the disk directory that the directory to be stored is allowed to link to.
[0094] Because the storage directories in the application server are mapped to the directories in the primary and secondary storage servers, the primary storage server can determine the first storage directory for storing the files to be stored based on the directory to be stored. The first storage directory is the disk directory to which the directory to be stored is allowed to link; that is, the files to be stored are stored on the disk of the primary storage server.
[0095] Step 403: Store the file to be stored in the first storage directory.
[0096] Then, the file to be stored is stored in the first storage directory.
[0097] In this embodiment of the disclosure, after storing the file to be stored in the first storage directory, as an example, it can also be determined whether the slave storage server is in an available state. If the slave storage server is in an available state, a file synchronization request can be sent to the slave storage server. The file synchronization request may include the file to be stored and the first storage directory. The slave storage server can respond to the file synchronization request and synchronize the file to be stored to its own first storage directory.
[0098] As another example, whenever a set period is reached, the primary storage server can determine whether the secondary storage server is available. If the secondary storage server is available, the latest files stored on the primary storage server during that period will be synchronized and updated to the secondary storage server.
[0099] In summary, by receiving a file storage request from the application server, where the request includes the file to be stored and the storage directory on the application server, and the storage directory is determined by the application server upon receiving a file upload request from the application client, identifying the first file type of the file to be stored, and determining that the main storage server is available based on the first file type, the file storage request is sent by the application server in response to the file upload request. Based on the storage directory, a first storage directory is determined, which is a disk directory that the storage directory is allowed to link to. The file to be stored is then stored in the first storage directory. This allows the file to be stored on the disk directory of the main storage server, reducing the storage pressure on the application server, improving its operating speed, and thus increasing the efficiency of related business processing.
[0100] In this embodiment of the disclosure, when the client responds to a download operation, it can send a first file download request to the application server. When the application server determines that the main storage server is available, it can send a second file download request to the main storage server to download the first target file that matches the target file identifier. The following describes the process in conjunction with... Figure 5 Please provide a detailed explanation.
[0101] Figure 5 This is a schematic flowchart illustrating the file storage method according to the fifth embodiment of this disclosure. It should be noted that the file storage method of this embodiment can be applied to a main storage server.
[0102] like Figure 5 As shown, the method for storing this file may include the following steps:
[0103] Step 501: Receive the second file download request sent by the application server.
[0104] The second file download request is sent by the application server after determining that the main storage server is in an available state. The second file download request includes the directory to be queried and the target file identifier. The directory to be queried is determined by the main storage server upon receiving the first file download request sent by the application client and responding to the first file download request. Based on the target file identifier in the first file download request, the main storage server determines the second file type to which the file to be downloaded in the first file download request belongs, and determines it based on the second file type.
[0105] In this embodiment of the disclosure, the application server can receive a first file download request sent by the application client. The first file download request includes a target file identifier for the file to be downloaded. In response to the first file download request, the application server determines a second file type for the file to be downloaded based on the target file identifier, determines the directory to be queried based on the second file type, and checks whether the main storage server is available. If the main storage server is available, the application server sends a second file download request to the main storage server. The second file download request includes the directory to be queried and the target file identifier.
[0106] Step 502: In response to the second file download request, retrieve the first target file that matches the target file identifier from the second storage directory.
[0107] The second storage directory is the disk directory that the query directory is allowed to link to.
[0108] Furthermore, in response to the second file download request, it is determined whether a first target file matching the target file identifier exists in the second storage directory. If a first target file matching the target file identifier exists in the second storage directory, the first target file matching the target file identifier is retrieved from the second storage directory.
[0109] Step 503: Send the first target file to the application server.
[0110] The first target file is used as the file to be downloaded and sent to the application client.
[0111] Then, the first target file is sent to the application server, which can then send the first target file to the application client as a file to be downloaded.
[0112] In summary, by receiving a second file download request from the application server; responding to the second file download request, retrieving a first target file matching the target file identifier from the second storage directory; and sending the first target file to the application server, whereby the first target file is used as the file to be downloaded to the application client, the file to be downloaded can be quickly located from the main storage during file download, improving download speed and thus enhancing user experience.
[0113] Based on any embodiment of this disclosure, such as Figure 6 As shown, the file storage method of this disclosure embodiment can also be implemented based on the following steps:
[0114] 1. When uploading image files, in order to improve the transmission speed and file transmission security, the image file to be uploaded can be converted into a data stream, and the data stream can be encapsulated to obtain an encapsulated message;
[0115] It should be noted that, since the original storage solution only stored txt files using FTP (File Transfer Protocol), the addition of image and video file storage functions made development more complicated. At the same time, the frequent patching of FTP vulnerabilities increased maintenance costs. Therefore, in this embodiment, NFS (Network File System) network disk can be used to store image files and other files, which is convenient for development and integration, and reduces the workload of maintenance.
[0116] 2. The local server (application server) receives the encapsulated message sent by the client (application client), decapsulates the encapsulated message to obtain the file to be uploaded, determines the file type of the file to be uploaded, and determines the storage directory based on the file type of the file to be uploaded.
[0117] 3. Perform mount service verification on the primary and secondary storage servers, i.e., determine whether the primary and secondary storage servers are in an available state. If at least one of the primary and secondary storage servers is available, a file storage request can be sent to at least one server to store the file to be stored in the first storage directory, which is a disk directory that the storage directory is allowed to link to. If neither the primary nor secondary storage server is available, the application server can store the file to be stored in the storage directory.
[0118] It should be noted that, due to the small initial workload, a single-machine mode can be used. As the workload increases, the availability, data security, and completeness of the storage service become priorities. Subsequently, the storage architecture was upgraded to a master-slave dual-machine mode, which can realize hourly scheduled data synchronization. In addition, it should be noted that relevant departments discovered a security risk that any host could view and access the service. This issue can be addressed by adding the function of only allowing service discovery and only allowing service access to specified IP hosts to the master and slave storage servers.
[0119] With the above Figures 1 to 3 Corresponding to the file storage method provided in the embodiments, this disclosure also provides a file storage device. Since the file storage device provided in the embodiments of this disclosure is similar to the one described above... Figures 1 to 3 The file storage method provided in the embodiments corresponds to the file storage device provided in the embodiments of this disclosure, and will not be described in detail in the embodiments of this disclosure.
[0120] Figure 7This is a schematic diagram of the structure of a file storage device according to the sixth embodiment of this disclosure. In this embodiment, the file storage device can be applied to an application server.
[0121] like Figure 7 As shown, the file storage device 700 includes: a receiving module 710, a determining module 720, a judging module 730, and a sending module 740.
[0122] The system includes a receiving module 710 for receiving a file upload request from an application client, wherein the file upload request includes a file to be stored; a determining module 720 for determining a first file type to which the file to be stored belongs, and determining the storage directory of the file to be stored in the application server based on the first file type; a judging module 730 for responding to the file upload request and judging whether the primary storage server and / or the secondary storage server are in an available state; and a sending module 740 for sending a file storage request to at least one server when at least one of the primary storage server and the secondary storage server is in an available state, wherein the file storage request includes a file to be stored and a storage directory, and the file storage request is used by at least one server to store the file to be stored in a first storage directory, wherein the first storage directory is a disk directory to which the storage directory is allowed to link.
[0123] As one possible implementation of this disclosure, the determination module 730 is configured to respond to the file upload request by sending at least one status verification request to the primary storage server and the secondary storage server; in response to receiving a status verification response sent by the primary storage server in response to at least one status verification request, determine that the primary storage server is in an available state; and in response to receiving a status verification response sent by the secondary storage server in response to at least one status verification request, determine that the secondary storage server is in an available state.
[0124] As one possible implementation of this disclosure, the sending module 740 is configured to send a file storage request to the main storage server when the main storage server is available, wherein the file storage request is used to store the file to be stored in the first storage directory of the main storage server, and to determine whether the secondary storage server is available. If the secondary storage server is available, the module sends a file synchronization request to the secondary storage server, wherein the file synchronization request includes the file to be stored and the first storage directory, and the file synchronization request is used by the secondary storage server to synchronize the file to be stored to the first storage directory; and to send a file storage request to the secondary storage server when the main storage server is unavailable and the secondary storage server is available, wherein the file storage request is used to store the file to be stored in the first storage directory of the secondary storage server.
[0125] As one possible implementation of this disclosure, the file storage device 700 further includes a storage module.
[0126] The storage module is configured to store the file to be stored in the storage directory when at least one of the primary and secondary storage servers is not available; and to resend the file storage request to at least one server when at least one server becomes available, so as to store the file to be stored on at least one server.
[0127] As a possible implementation of this disclosure, the receiving module 710 is further configured to receive a first file download request sent by the application client, wherein the first file download request includes a target file identifier of the file to be downloaded; the determining module 720 is further configured to, in response to the first file download request, determine a second file type to which the file to be downloaded belongs based on the target file identifier, and determine a query directory to which the file to be downloaded belongs based on the second file type; the judging module 730 is further configured to judge whether the primary storage server and / or the secondary storage server are in an available state; the sending module 740 is further configured to, if at least one of the primary storage server and the secondary storage server is in an available state, send a second file download request to at least one server, wherein the second file download request includes the query directory and the target file identifier, the second file download request is used to obtain a first target file matching the target file identifier in the second storage directory, and send the first target file to the application server, wherein the second storage directory is a disk directory to which the query directory is allowed to link; the receiving module 710 is further configured to receive the first target file sent by at least one server, and send the first target file as the file to be downloaded to the application client.
[0128] As one possible implementation of this disclosure, the sending module 740 is further configured to send the second file download request to the main storage server when the main storage server is available, wherein the second file download request is used to obtain a first target file matching the target file identifier in the second storage directory of the main storage server; and to send the second file download request to the secondary storage server when the main storage server is unavailable, wherein the second file download request is used to obtain a first target file matching the target file identifier in the second storage directory of the secondary storage server.
[0129] As one possible implementation of this disclosure, the file storage device 700 further includes a query module.
[0130] The query module is used to query whether a second target file matching the target file identifier exists in the query directory when at least one of the primary storage server and secondary storage servers is not available. The sending module 740 is also used to send the second target file as a file to be downloaded to the application client when a second target file matching the target file identifier exists in the query directory. The sending module 740 is also used to send target information to the application client when a second target file matching the target file identifier does not exist in the query directory, wherein the target information is used to indicate that the download of the file to be downloaded has failed.
[0131] The file storage device of this disclosure embodiment is applied to an application server. It receives a file upload request sent by an application client, wherein the file upload request includes a file to be stored; determines a first file type to which the file to be stored belongs, and determines the storage directory of the file to be stored on the application server based on the first file type; responds to the file upload request and determines whether a primary storage server and / or a secondary storage server are available; if at least one of the primary and secondary storage servers is available, it sends a file storage request to at least one server, wherein the file storage request includes the file to be stored and a storage directory, and the file storage request is used by at least one server to store the file to be stored in a first storage directory, the first storage directory being a disk directory to which the storage directory is allowed to link. Therefore, when at least one of the primary and secondary storage servers is available, storing the file to be stored in the first storage directory of at least one server reduces the storage pressure on the application server, improves the operating speed of the application server, and thus improves the efficiency of related business processing.
[0132] With the above Figure 4 Figure 5 Corresponding to the file storage method provided in the embodiments, this disclosure also provides a file storage device. Since the file storage device provided in the embodiments of this disclosure is similar to the one described above... Figure 4 Figure 5 The file storage method provided in the embodiments corresponds to the file storage method provided in the embodiments of this disclosure, and therefore the implementation of the file storage method is also applicable to the file storage device provided in the embodiments of this disclosure, and will not be described in detail in the embodiments of this disclosure.
[0133] Figure 8 A schematic diagram of the structure of a file storage device is shown in the seventh embodiment of this disclosure. In this embodiment, the file storage device can be applied to a main storage server.
[0134] like Figure 8 As shown, the file storage device 800 includes: a receiving module 810, a determining module 820, and a storage module 830.
[0135] The receiving module 810 is used to receive a file storage request sent by the application server. The file storage request includes a file to be stored and a directory on the application server where the file to be stored is to be stored. The directory is determined by the application server upon receiving a file upload request from an application client, determining the first file type to which the file to be stored belongs, and the file storage request is sent by the application server in response to the file upload request, confirming that the main storage server is in an available state. The determining module 820 is used to determine a first storage directory based on the directory to be stored, wherein the first storage directory is a disk directory that the directory to be stored is allowed to link to. The storage module 830 is used to store the file to be stored in the first storage directory.
[0136] As one possible implementation of this disclosure, the file storage device 800 further includes: a judgment module and a first sending module.
[0137] The system includes a judgment module for determining whether the slave storage server is in an available state; and a sending module for sending a file synchronization request to the slave storage server when the slave storage server is in an available state. The file synchronization request includes the file to be stored and a first storage directory, and the file synchronization request is used by the slave storage server to synchronize the file to be stored to the first storage directory.
[0138] As one possible implementation of this disclosure, the file storage device 800 further includes: an acquisition module and a second sending module.
[0139] The receiving module 810 is further configured to receive a second file download request sent by the application server. The second file download request is sent by the application server after determining that the main storage server is in an available state. The second file download request includes a directory to be queried and a target file identifier. The directory to be queried is determined by the main storage server upon receiving a first file download request from the application client and, in response to the first file download request, determining the second file type to which the file to be downloaded in the first file download request belongs based on the target file identifier. The obtaining module is configured to, in response to the second file download request, obtain a first target file matching the target file identifier from the second storage directory. The second storage directory is a disk directory to which the directory to be queried is allowed to link. The second sending module is configured to send the first target file to the application server, wherein the first target file is used as a file to be downloaded to the application client.
[0140] The file storage device of this disclosure embodiment is applied to a main storage server. It receives a file storage request sent by an application server. The file storage request includes a file to be stored and a directory on the application server to be stored. The directory to be stored is determined by the application server upon receiving a file upload request from an application client, identifying a first file type to which the file to be stored belongs, and determining the file storage request based on the first file type. The file storage request is sent by the application server in response to the file upload request, confirming that the main storage server is in an available state. A first storage directory is determined based on the directory to be stored, wherein the first storage directory is a disk directory to which the directory to be stored is allowed to link. The file to be stored is stored in the first storage directory. This allows the file to be stored in the disk directory of the main storage server, reducing the storage pressure on the application server, improving the application server's operating speed, and thus improving the efficiency of related business processing.
[0141] In an exemplary embodiment, an electronic device is also proposed.
[0142] The electronic devices include:
[0143] processor;
[0144] Memory used to store processor-executable instructions;
[0145] The processor is configured to execute instructions to implement the file storage method as proposed in any of the foregoing embodiments.
[0146] As an example, Figure 9 This is a schematic diagram of the structure of an electronic device 900 as shown in an exemplary embodiment of this disclosure, as follows: Figure 9 As shown, the aforementioned electronic device 900 may further include:
[0147] The system includes a memory 910 and a processor 920, and a bus 930 connecting different components (including the memory 910 and the processor 920). The memory 910 stores a computer program, and when the processor 920 executes the program, it implements the file storage method described in this embodiment of the present disclosure.
[0148] Bus 930 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0149] Electronic device 900 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by electronic device 900, including volatile and non-volatile media, removable and non-removable media.
[0150] The memory 910 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 940 and / or cache memory 950. The server 900 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 960 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 9 Not shown; usually referred to as a "hard drive"). Although Figure 9 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 930 via one or more data media interfaces. Memory 910 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this disclosure.
[0151] A program / utility 980 having a set (at least one) of program modules 970 may be stored, for example, in memory 910. Such program modules 970 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 970 typically perform the functions and / or methods described in the embodiments of this disclosure.
[0152] Electronic device 900 can also communicate with one or more external devices 990 (e.g., keyboard, pointing device, display 991, etc.), and with one or more devices that enable a user to interact with electronic device 900, and / or with any device that enables electronic device 900 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 992. Furthermore, electronic device 900 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 993. As shown, network adapter 993 communicates with other modules of electronic device 900 via bus 930. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0153] The processor 920 executes various functional applications and data processing by running programs stored in the memory 910.
[0154] It should be noted that the implementation process and technical principles of the electronic device in this embodiment are explained in the foregoing description of the file storage method of this disclosure embodiment, and will not be repeated here.
[0155] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, which can be executed by a processor of an electronic device to perform the file storage method proposed in any of the above embodiments. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0156] In an exemplary embodiment, a computer program product is also provided, including a computer program / instructions, characterized in that the computer program / instructions, when executed by a processor, implement the file storage method proposed in any of the above embodiments.
[0157] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0158] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A file storage method, characterized in that, Used in application servers, including: Receive a file upload request sent by an application client, wherein the file upload request includes a file to be stored; Determine the first file type to which the file to be stored belongs, and determine the storage directory of the file to be stored in the application server based on the first file type; In response to the file upload request, determine whether the primary storage server and / or the secondary storage server are in an available state; In response to the primary storage server being available, a file storage request is sent to the primary storage server, and if the secondary storage server is determined to be available, a file synchronization request is sent to the secondary storage server; wherein, the file storage request includes the file to be stored and the directory to be stored, and the file storage request is used by the primary storage server to store the file to be stored in a first storage directory, the first storage directory being a disk directory to which the directory to be stored is allowed to link; the file synchronization request includes the file to be stored and the first storage directory, and the file synchronization request is used by the secondary storage server to synchronously store the file to be stored in the first storage directory; If at least one of the primary storage server and the secondary storage server is not available, the file to be stored is stored in the directory to be stored.
2. The method according to claim 1, characterized in that, The step of responding to the file upload request and determining whether the primary storage server and / or secondary storage server are in an available state includes: In response to the file upload request, send at least one status verification request to the primary storage server and the secondary storage server; Upon receiving a status verification response sent by the primary storage server in response to the at least one status verification request, it is determined that the primary storage server is in an available state; Upon receiving a status verification response sent by the slave storage server in response to the at least one status verification request, it is determined that the slave storage server is in an available state.
3. The method according to claim 1, characterized in that, The method further includes: When the primary storage server is unavailable and the secondary storage server is available, a file storage request is sent to the secondary storage server, wherein the file storage request is used to store the file to be stored in the first storage directory of the secondary storage server.
4. The method according to claim 1, characterized in that, The method further includes: If at least one server becomes available again, the file storage request is resent to at least one server to store the file to be stored on at least one server.
5. The method according to claim 1, characterized in that, The method further includes: Receive a first file download request sent by the application client, wherein the first file download request includes a target file identifier of the file to be downloaded; In response to the first file download request, based on the target file identifier, the second file type to which the file to be downloaded belongs is determined, and based on the second file type, the query directory to which the file to be downloaded belongs is determined; Determine whether the primary storage server and / or the secondary storage server are in an available state; If at least one of the primary storage server and the secondary storage server is available, a second file download request is sent to the at least one server. The second file download request includes the directory to be queried and the target file identifier. The second file download request is used to obtain a first target file that matches the target file identifier in the second storage directory and send the first target file to the application server. The second storage directory is a disk directory that the directory to be queried is allowed to link to. The system receives a first target file sent by at least one server and sends the first target file as the file to be downloaded to the application client.
6. The method according to claim 5, characterized in that, When at least one of the primary storage server and the secondary storage server is available, sending a second file download request to the at least one server includes: When the main storage server is available, a second file download request is sent to the main storage server, wherein the second file download request is used to obtain a first target file that matches the target file identifier in the second storage directory of the main storage server; If the primary storage server is unavailable, a second file download request is sent to the secondary storage server, wherein the second file download request is used to obtain a first target file that matches the target file identifier in the second storage directory of the secondary storage server.
7. The method according to claim 5, characterized in that, The method further includes: If at least one of the primary storage server and the secondary storage server is not available, query the directory to be queried to see if there is a second target file that matches the target file identifier; If a second target file matching the target file identifier exists in the directory to be queried, the second target file is sent to the application client as a file to be downloaded; If no second target file matching the target file identifier exists in the directory to be queried, target information is sent to the application client, wherein the target information is used to indicate that the download of the file to be downloaded has failed.
8. A file storage method, characterized in that, Applied to primary storage servers, including: The system receives a file storage request sent by an application server. The file storage request includes a file to be stored and a directory to be stored on the application server. The directory to be stored is determined by the application server upon receiving a file upload request from an application client, based on a first file type. The file storage request is sent by the application server in response to the file upload request, after determining that the main storage server is in an available state. Based on the directory to be stored, a first storage directory is determined, wherein the first storage directory is a disk directory that the directory to be stored is allowed to link to; Store the file to be stored in the first storage directory; Determine if the storage server is available; When the slave storage server is available, a file synchronization request is sent to the slave storage server. The file synchronization request includes the file to be stored and the first storage directory. The file synchronization request is used by the slave storage server to synchronize and store the file to be stored in the first storage directory.
9. The method according to claim 8, characterized in that, The method further includes: The system receives a second file download request sent by the application server. The second file download request is sent by the application server after determining that the main storage server is in an available state. The second file download request includes a directory to be queried and a target file identifier. The directory to be queried is determined by the main storage server upon receiving a first file download request from the application client and responding to the first file download request by determining the second file type to which the file to be downloaded in the first file download request belongs, based on the target file identifier in the first file download request. In response to the second file download request, a first target file matching the target file identifier is obtained from the second storage directory, wherein the second storage directory is a disk directory that the query directory is allowed to link to; The first target file is sent to the application server, wherein the first target file is used as a file to be downloaded and sent to the application client.
Citation Information
Patent Citations
Data migration method and system
CN111966742A
Distributed file system and file caching method
CN113961529A
File downloading method and device
CN114401261A