File processing method, device, computer equipment and computer-readable storage medium
By generating description metadata and encrypting file block processing, the problem of insufficient file processing security is solved and higher file security is achieved.
Patent Information
- Application Number
- CN202211145560.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-20
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2042-09-20
AI Technical Summary
In the prior art, file processing is poor in security, and other personnel can easily restore the initial file based on the metadata of the block file.
By obtaining the file attribute information uploaded by the client, descriptive metadata is generated, and upload instructions are sent to the client based on the description metadata and the storage metadata of the pre-stored file, obtaining and storing the target block file. Only the first pre-stored block file contains file header information, and other block files are encrypted based on the secret key to ensure file security.
Improves the security of file processing, ensuring that even if other pre-stored block files are obtained, it cannot be decrypted and parsed, and further ensures the security of file content.
Smart Images

Figure CN115567212B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing. Specifically, it relates to a file processing method, apparatus, computer device, and computer-readable storage medium. Background Technique
[0002] With the development of information technology, people often upload some data or files to a database for electronic office work. The confidentiality and security of data or files have always been very important links in electronic office work.
[0003] In the related art, an initial file is often split into multiple block files and uploaded to a file storage server in a random order, and the storage address, file identifier, and arrangement order are recorded in the metadata of each block file. When a user needs to download or query a file, the corresponding block file is found according to the storage address and file identifier in the metadata of each block file, and the corresponding block files are restored to the initial file according to the arrangement order. In this way, the purpose of secure file storage is achieved.
[0004] However, in the solution of the related art, other people can easily restore the initial file according to the metadata of each block file, which leads to the problem of poor security in file processing in the solution of the related art. Summary of the Invention
[0005] The purpose of this application is to provide a file processing method, apparatus, computer device, and computer-readable storage medium, which can achieve the effect of improving the security of file processing.
[0006] The embodiments of this application are implemented as follows:
[0007] In the first aspect of the embodiments of this application, a file processing method is provided. The method includes:
[0008] Obtain the file attribute information uploaded by the client, and generate descriptive metadata according to the file attribute information. The file attribute information includes the unique identifier and file size of the file to be stored. The descriptive metadata is used to record the file attribute information, and the unique identifier is used to identify the file content of the file to be stored;
[0009] Send an upload instruction to the client according to the described metadata and the storage metadata of each pre-stored file. The upload instruction is used to indicate the target file to be uploaded and the file size of the target file. The pre-stored file includes at least one pre-stored block file. The first pre-stored block file in each pre-stored block file includes file header information, and the file header information includes the size information and the secret key of the block file. Each pre-stored block file after the first pre-stored block file is encrypted based on the secret key. The storage metadata is used to indicate the unique identifier and the storage address of the pre-stored file;
[0010] Obtain and store the target block file sent by the client, determine the target storage metadata corresponding to the unique identifier of each target block file, store each target block file at the storage address indicated by the target storage metadata, and update the pre-stored file.
[0011] Optionally, the sending the corresponding upload instruction to the client according to the described metadata and the storage metadata of each pre-stored file includes:
[0012] Determine whether there is a target storage metadata in the storage metadata of each pre-stored file that matches the unique identifier in the described metadata;
[0013] If it exists, determine the file size of the target file to be uploaded in the file to be stored according to the stored file size and the maximum storage size in the target storage metadata, and send the first upload instruction to the client. Among them, if the file size of the target file is 0, the first upload instruction includes the file size of the target file. Otherwise, the first upload instruction includes the file size of the target file and the file header information of the first block file in the pre-stored block file;
[0014] If it does not exist, generate new storage metadata according to the file attribute information, and send a second upload instruction to the client. The second upload instruction is used to instruct the client to start uploading from the first byte of the file to be stored.
[0015] Optionally, the determining the file size of the target file to be uploaded in the file to be stored according to the stored file size and the maximum storage size in the target storage metadata, and sending the first upload instruction to the client includes:
[0016] Obtain and parse the target storage metadata to determine the stored file size and the maximum storage size;
[0017] Compare the sizes of the maximum storage size and the stored file size;
[0018] If the maximum storage size is not greater than the stored file size, determine that the file size of the target file is 0, generate the first upload instruction according to the file size of the target file, and send the first upload instruction to the client;
[0019] If the maximum storage size is greater than the stored file size, determine that the file size of the target file is the difference between the maximum storage size and the stored file size, generate the first upload instruction according to the file size of the target file and the file header information of the first block file in the pre-stored block file, and send the first upload instruction to the client.
[0020] Optionally, the determining the target storage metadata corresponding to the identifiers of the target block files, storing the target block files at the storage addresses indicated by the target storage metadata, and updating the pre-stored file includes:
[0021] If there is a pre-stored block file corresponding to the target storage metadata, encrypt each target block file according to the secret key in the file header information corresponding to the pre-stored block file and then store it, and use the stored target block files and the associated pre-stored block files as a new pre-stored file, and use the description metadata of the file to be stored corresponding to the target block file as the description metadata of the new pre-stored file;
[0022] If there is no pre-stored block file corresponding to the target storage metadata, encrypt the other block files except the first block file in each target block file according to the secret key in the file header information of the first block file in each target block file and then store it.
[0023] Optionally, the determining the target storage metadata corresponding to the identifiers of the target block files, storing the target block files at the storage addresses indicated by the target storage metadata, and updating the pre-stored file includes:
[0024] Store each encrypted target block file of the client, and use the stored target block files and the associated pre-stored block files as a new pre-stored file, and use the description metadata of the file to be stored corresponding to the target block file as the description metadata of the new pre-stored file.
[0025] Optionally, the description metadata of the pre-stored file further includes the encoding of the pre-stored file;
[0026] The method further includes:
[0027] Receive a file download instruction sent by the client, where the file download instruction includes the encoding of the file and the download start position;
[0028] Determine whether there is a piece of data to be downloaded that matches the encoding of the file in the pre-stored file according to the encoding of each pre-stored file;
[0029] If there is, determine the target download file from the data to be downloaded according to the download start position;
[0030] Determine the storage address of the target download file according to the storage metadata corresponding to the target download file, and obtain each download block file from the storage address of the target download file and send it to the client.
[0031] Optionally, the obtaining each download block file from the storage address of the target download file and sending it to the client includes:
[0032] Determine the file header information of the download block file;
[0033] Determine the encrypted file in each download block file according to the size information in the file header information of the download block file;
[0034] Decrypt the encrypted file according to the secret key in the file header information of the download block file to obtain the decrypted file, and send the decrypted file to the client.
[0035] In a second aspect of the embodiments of the present application, a file processing method is provided, and the method includes:
[0036] Send the file attribute information of the file to be stored to the server, where the file attribute information includes the unique identifier and the file size of the file to be stored;
[0037] Receive and parse the upload instruction sent by the server to obtain the target file to be uploaded indicated by the upload instruction and the file size of the target file;
[0038] Split the target file into multiple files to be stored in blocks and send them to the server for storage.
[0039] In a third aspect of the embodiments of the present application, a file processing device is provided, and the device includes:
[0040] An acquisition and generation module, configured to acquire the file attribute information uploaded by the client, and generate description metadata according to the file attribute information, where the file attribute information includes the unique identifier and the file size of the file to be stored, the description metadata is used to record the file attribute information, and the unique identifier is used to identify the file content of the file to be stored;
[0041] A sending module, configured to send an upload instruction to the client according to the description metadata and the storage metadata of each pre-stored file, where the upload instruction is used to indicate a target file to be uploaded and the file size of the target file. At least one pre-stored block file is included in the pre-stored files, and the first pre-stored block file in each pre-stored block file includes file header information, where the file header information includes block file size information and a secret key. Each pre-stored block file after the first pre-stored block file is obtained by encrypting based on the secret key. The storage metadata is used to indicate the unique identifier and storage address of the pre-stored file;
[0042] A storage module, configured to obtain and store the target block files sent by the client, determine target storage metadata corresponding to the identifiers of each target block file, store each target block file at the storage address indicated by the target storage metadata, and update the pre-stored file.
[0043] In a fourth aspect of the embodiments of the present application, a file processing device is provided, and the device includes:
[0044] An attribute information sending module, configured to send file attribute information of a file to be stored to a server, where the file attribute information includes the unique identifier and file size of the file to be stored;
[0045] A receiving and parsing module, configured to receive and parse the upload instruction sent by the server, and obtain the target file to be uploaded and the file size of the target file indicated by the upload instruction;
[0046] A splitting and sending module, configured to split the target file into multiple block files to be stored and send them to the server for storage.
[0047] In a fifth aspect of the embodiments of the present application, a computer device is provided. The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the file processing method described in the first aspect and the file processing method described in the second aspect.
[0048] In a fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the file processing method described in the first aspect and the file processing method described in the second aspect.
[0049] The beneficial effects of the embodiments of the present application include:
[0050] A file processing method provided by an embodiment of the present application obtains file attribute information uploaded by a client, generates descriptive metadata based on the file attribute information, sends an upload instruction to the client according to the descriptive metadata and the storage metadata of each pre-stored file, obtains and stores the target block file sent by the client, determines the target storage metadata corresponding to the unique identifier of each target block file, stores each target block file at the storage address indicated by the target storage metadata, and updates the pre-stored file.
[0051] Among them, when obtaining the file attribute information uploaded by the client and generating descriptive metadata based on the file attribute information, since the file attribute information includes the unique identifier and file size of the file to be stored, and the unique identifier is used to identify the file content of the file to be stored, in this way, the unique identifier and file size of each file to be stored can be obtained, and the descriptive metadata of each file to be stored can be generated, which is convenient for performing subsequent operations.
[0052] Sending an upload instruction to the client according to the descriptive metadata and the storage metadata of each pre-stored file. Since the upload instruction is used to indicate the target file to be uploaded and the file size of the target file, after sending the upload instruction to the client, the client can find the corresponding file to be stored according to the target file, and split the corresponding block file from the file to be stored for uploading. And, since only the first pre-stored block file among the pre-stored block files stored in the computer device includes file header information, and the other pre-stored block files do not include file header information, in this way, even if other persons or devices obtain the other pre-stored block files, they cannot obtain the corresponding secret key to decrypt and / or parse the other pre-stored block files. Thus, the security of file processing can be improved.
[0053] In addition, since the file structure of the first pre-stored block file includes a secret key, size information, and a delimiter at the same time, even if other persons or devices obtain the first pre-stored block file, they cannot distinguish the secret key, the size information, and the delimiter, and thus can ensure that other persons or devices cannot easily obtain the secret key. In this way, the security of file processing can be further ensured.
[0054] Obtain and store the target block files sent by the client, determine the target storage metadata corresponding to the unique identifiers of the respective target block files, store the respective target block files at the storage addresses indicated by the target storage metadata, and update the pre-stored file. If the respective target block files are block files that do not encrypt the file content stored in the file body, when storing the respective target block files at the storage addresses indicated by the target storage metadata, the file body of each target file block can be encrypted by identifying the file header information of each target block file or the file header information of the first pre-stored block file having the same unique identifier as each target block file. In this way, it can be ensured that after storing the respective target block files at the corresponding storage addresses, all the block files stored in the computer device are encrypted, and each pre-stored file block of the updated pre-stored file is encrypted in the same encryption manner.
[0055] In this way, each target block file uploaded by the client can be obtained, and each target block file can be stored at the corresponding storage address to form a new pre-stored file, so as to achieve the purpose of file upload, and further improve the security of file processing.
[0056] In this way, the effect of improving the security of file processing can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0058] Figure 1 It is a flowchart of the first file processing method provided by the embodiment of the present application;
[0059] Figure 2 It is a flowchart of the second file processing method provided by the embodiment of the present application;
[0060] Figure 3 It is a flowchart of the third file processing method provided by the embodiment of the present application;
[0061] Figure 4 It is a flowchart of the fourth file processing method provided by the embodiment of the present application;
[0062] Figure 5 It is a flowchart of the fifth file processing method provided by the embodiment of the present application;
[0063] Figure 6 It is a flowchart of the sixth file processing method provided by the embodiment of the present application;
[0064] Figure 7 A schematic structural diagram of a file processing device provided by an embodiment of the present application;
[0065] Figure 8 A schematic structural diagram of another file processing device provided by an embodiment of the present application;
[0066] Figure 9 A schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0067] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. The components of the embodiments of the present application usually described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations.
[0068] Therefore, the detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but merely represents selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the scope of protection of the present application.
[0069] It should be noted that like reference numerals and letters denote like items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0070] In the related art, an initial file is often split into multiple block files and uploaded to a file storage server in a random order, and the storage address, file identifier, and arrangement order are recorded in the metadata of each block file. When a user needs to download or query a file, the corresponding block file is found according to the storage address and file identifier in the metadata of each block file, and the corresponding block files are restored to the initial file in the arrangement order. In this way, the purpose of secure file storage is achieved. However, in the solution of the related art, other people can easily restore the initial file according to the metadata of each block file, which results in the problem of poor security in file processing in the solution of the related art.
[0071] To this end, an embodiment of the present application provides a file processing method. By obtaining the file attribute information uploaded by the client, generating descriptive metadata based on the file attribute information, sending an upload instruction to the client according to the descriptive metadata and the storage metadata of each pre-stored file, obtaining and storing the target block file sent by the client, determining the target storage metadata corresponding to the unique identifier of each target block file, storing each target block file at the storage address indicated by the target storage metadata, and updating the pre-stored file, the effect of improving the security of file processing can be achieved.
[0072] The embodiment of the present application is described by taking the file processing method applied to a computer device as an example. However, it does not mean that the embodiment of the present application can only be applied to file processing in a computer device.
[0073] The file processing method provided by the embodiment of the present application is explained in detail below.
[0074] Figure 1 is a flowchart of a file processing method provided by the present application. This method can be applied to a computer device, which can be any terminal device or server. See Figure 1 An embodiment of the present application provides a file processing method, including:
[0075] Step 1001: Obtain the file attribute information uploaded by the client, and generate descriptive metadata based on the file attribute information.
[0076] Optionally, the client can be an application program running on the computer device or an application program running on other computer devices. The embodiment of the present application does not make any limitations in this regard. The user can input corresponding data or instructions to the client through the input device, or operate the client to interact with other application programs or other computer devices. The embodiment of the present application does not make any limitations in this regard.
[0077] Optionally, the file attribute information includes the unique identifier of the file to be stored and the file size.
[0078] The descriptive metadata can be used to record the file attribute information, and can also be used to store information such as the file name and file encoding (ID) of each file to be stored. The embodiment of the present application does not make any limitations in this regard.
[0079] The file to be stored can refer to any file that needs to be stored, or can refer to any file that needs to be uploaded by the client to the server, database, or server. The embodiment of the present application does not make any limitations in this regard.
[0080] The file size can refer to the size of the storage space that the file to be stored needs to occupy in the computer device, or can refer to the number of bytes of the file to be stored.
[0081] This unique identifier is used to identify the file content of the file to be stored. The file content can specifically refer to the text, code, symbols, etc. in the file to be stored. The embodiments of the present application do not limit this.
[0082] In addition, this unique identifier can be obtained by performing an operation on the file to be stored through a corresponding hash function. For example, the MD5 Information Digest Algorithm (MD5 Message-Digest Algorithm, abbreviated as MD5) can be used to obtain this unique identifier.
[0083] That is to say, if the text contents of any two files to be stored are the same, then the unique identifiers of these two files to be stored are also the same. On the contrary, if the text contents of any two files to be stored are different, then the unique identifiers of these two files to be stored are different.
[0084] The unique identifier in the file attribute information can be obtained by the client invoking the corresponding hash function for operation, or can be obtained by other application programs invoking the corresponding hash function for operation and then sent to the client. The embodiments of the present application do not limit this.
[0085] Moreover, after generating the descriptive metadata, the descriptive metadata can also be stored so that when the descriptive metadata is needed subsequently, the descriptive metadata can be called quickly and accurately.
[0086] In this way, the unique identifier and file size of each file to be stored can be obtained, and the descriptive metadata of each file to be stored can be generated, which is convenient for performing subsequent operations.
[0087] Step 1002: Send an upload instruction to the client according to the descriptive metadata and the storage metadata of each pre-stored file.
[0088] Optionally, the upload instruction is used to indicate the target file to be uploaded and the file size of the target file.
[0089] Optionally, the target file can refer to the part that needs to be uploaded in the file to be stored. Specifically, the target file can be the same as the file to be stored, or can be a part of the file to be stored. The embodiments of the present application do not limit this.
[0090] If the target file is the same as the file to be stored, it means that the entire file to be stored needs to be used as the target file for upload. In this case, the file size of the target file is the size of the file to be stored. If the target file is a part of the file to be stored, it means that only a part of the file to be stored needs to be uploaded. In this case, the file size of the target file is smaller than the size of the file to be stored.
[0091] The pre-stored file includes at least one pre-stored block file, and the first pre-stored block file in each pre-stored block file includes file header information.
[0092] The pre-stored file may refer to a file that has been stored in the computer device, and when the pre-stored file is stored in the computer device, the pre-stored file may be split into at least one block file for storage.
[0093] Each pre-stored block file may refer to each block file obtained by splitting the pre-stored file.
[0094] Moreover, when storing each pre-stored block file, the pre-stored block files may be stored in the order of the starting storage position and the ending storage position of each pre-stored block file, or may be stored in any preset order, or may be stored in a random order. The embodiments of the present application do not make any limitations in this regard.
[0095] The starting storage position may refer to the position of the first byte stored in each pre-stored block file in the pre-stored file, and the ending storage position may refer to the position of the last byte stored in each pre-stored block file in the pre-stored file.
[0096] The first pre-stored block file in each pre-stored block file may refer to the block file that stores the first byte of the pre-stored file.
[0097] Optionally, the file header information includes the size information of the block file and the secret key. Then, the file header information in the pre-stored block file can indicate the size information and the secret key of each pre-stored block file.
[0098] The size information may refer to the number of bytes storing the content of the pre-stored file in the block file, or may refer to the capacity of the block file, or may refer to the size of the storage space of the block file.
[0099] The secret key may be a parameter for encrypting and decrypting the file content stored in each block file. Specifically, the secret key can be used to convert the file content stored in each block file from plaintext form to ciphertext form, or can be used to convert the file content stored in each block file from ciphertext form to plaintext form.
[0100] For example, the secret key may be a 32-byte parameter. After inputting the secret key and the plaintext-form file content in each block file into the corresponding encryption algorithm, the plaintext-form file content can be converted into ciphertext-form file content. After inputting the secret key and the ciphertext-form file content in each block file into the corresponding decryption algorithm, the ciphertext-form file content can be converted into plaintext-form file content.
[0101] Exemplarily, the file structure of the first pre-stored block file may be [secret key + size information + delimiter + file body], where the delimiter is a symbol used to distinguish the file header information from the file content of the file to be stored, and the delimiter may be "|". The file body may store the file content of the file to be stored, specifically, it may store the file content of the file to be stored after being encrypted with the secret key. The embodiments of the present application do not limit this.
[0102] For another example, the file structure of other pre-stored block files except the first pre-stored block file among the pre-stored block files may only include the file body, and the file bodies of other pre-stored block files may be encrypted based on the secret key in the first pre-stored block file.
[0103] Optionally, each pre-stored block file after the first pre-stored block file is obtained by encryption based on the secret key. Moreover, the size of the file content of the file to be stored stored in each pre-stored block file after the first pre-stored block file is the same as the size of the file content of the file to be stored stored in the first pre-stored block file.
[0104] That is to say, each pre-stored block file after the first pre-stored block file does not store file header information, but performs encryption and decryption by calling the secret key in the file header information of the first pre-stored block file, and when splitting each pre-stored block file, it is split according to the size information in the file header information of the first pre-stored block file.
[0105] The storage metadata may be used to indicate the unique identifier and storage address of the pre-stored file. The storage metadata may also be used to indicate the pseudo name of the pre-stored file, the size of the stored file, and the maximum storage size of the pre-stored file. The embodiments of the present application do not limit this.
[0106] It should be noted that since the upload instruction is used to indicate the target file to be uploaded and the file size of the target file, after the upload instruction is sent to the client, the client can find the corresponding file to be stored according to the target file, and split out the corresponding block files from the file to be stored for uploading. Moreover, among the pre-stored block files stored in the computer device, only the first pre-stored block file includes file header information, while other pre-stored block files do not include file header information. In this way, even if other persons or devices obtain other pre-stored block files, they cannot obtain the corresponding secret key to decrypt and / or parse other pre-stored block files. Thus, the security of file processing can be improved.
[0107] In addition, since the file structure of the first pre-stored block file includes a secret key, size information, and a distinguishing symbol, even if other persons or devices obtain the first pre-stored block file, they cannot distinguish the secret key, the size information, and the distinguishing symbol. Thus, it can be ensured that other persons or devices cannot easily obtain the secret key, thereby further ensuring the security of file processing.
[0108] Step 1003: Obtain and store the target block files sent by the client, determine the target storage metadata corresponding to the unique identifiers of the target block files, store the target block files at the storage addresses indicated by the target storage metadata, and update the pre-stored file.
[0109] Optionally, the target block files refer to the block files uploaded by the client after splitting the file to be stored into block files. The target block file can be a block file obtained by encrypting the file content stored in the file body, or a block file that has not encrypted the file content stored in the file body.
[0110] The target storage metadata refers to the storage metadata that contains the same unique identifier as the unique identifier of each target block file.
[0111] The operation of updating the pre-stored file can be using each target block file with the same unique identifier as a new pre-stored file, or using each target block file with the same unique identifier and the previously stored pre-stored block files together as a new pre-stored file. The embodiments of the present application do not limit this.
[0112] It should be noted that if the target block files are block files that have not encrypted the file content stored in the file body, when storing the target block files at the storage addresses indicated by the target storage metadata, the file body of each target file block can be encrypted by identifying the file header information of each target block file or the file header information of the first pre-stored block file that has the same unique identifier as each target block file. In this way, it can be ensured that after storing each target block file at the corresponding storage address, all the block files stored in the computer device are encrypted, and each pre-stored file block of the updated pre-stored file is encrypted in the same encryption method.
[0113] In this way, each target block file uploaded by the client can be obtained, and each target block file can be stored at the corresponding storage address to form a new pre-stored file, so as to achieve the purpose of file upload, and further improve the security of file processing.
[0114] In an embodiment of the present application, by obtaining file attribute information uploaded by a client, generating descriptive metadata based on the file attribute information, sending an upload instruction to the client according to the descriptive metadata and storage metadata of each pre-stored file, obtaining and storing a target block file sent by the client, determining target storage metadata corresponding to the unique identifier of each target block file, storing each target block file at a storage address indicated by the target storage metadata, and updating the pre-stored file.
[0115] Among them, by obtaining file attribute information uploaded by a client and generating descriptive metadata based on the file attribute information, since the file attribute information includes the unique identifier and file size of the file to be stored, and the unique identifier is used to identify the file content of the file to be stored, in this way, the unique identifier and file size of each file to be stored can be obtained, and descriptive metadata of each file to be stored can be generated, which is convenient for performing subsequent operations.
[0116] According to the descriptive metadata and storage metadata of each pre-stored file, an upload instruction is sent to the client. Since the upload instruction is used to indicate the target file to be uploaded and the file size of the target file, after the upload instruction is sent to the client, the client can find the corresponding file to be stored according to the target file and split out the corresponding block file from the file to be stored for uploading. And, since among the pre-stored block files stored in the computer device, only the first pre-stored block file includes file header information, and the other pre-stored block files do not include file header information, in this way, even if other persons or devices obtain the other pre-stored block files, they cannot obtain the corresponding secret key to decrypt and / or parse the other pre-stored block files. Thus, the security of file processing can be improved.
[0117] In addition, since in the file structure of the first pre-stored block file, the secret key, size information, and delimiter are included at the same time, even if other persons or devices obtain the first pre-stored block file, they cannot distinguish the secret key, the size information, and the delimiter, and thus it can be ensured that other persons or devices cannot easily obtain the secret key. In this way, the security of file processing can be further ensured.
[0118] Obtain and store the target block files sent by the client, determine the target storage metadata corresponding to the unique identifiers of each target block file, store each target block file at the storage address indicated by the target storage metadata, and update the pre-stored file. If each target block file is a block file that does not encrypt the file content stored in the file body, when storing each target block file at the storage address indicated by the target storage metadata, the file body of each target file block can be encrypted by identifying the file header information of each target block file or the file header information of the first pre-stored block file having the same unique identifier as each target block file. In this way, it can be ensured that after each target block file is stored at the corresponding storage address, all the block files stored in the computer device are encrypted, and each pre-stored file block of the updated pre-stored file is encrypted in the same encryption manner.
[0119] In this way, each target block file uploaded by the client can be obtained, and each target block file can be stored at the corresponding storage address to form a new pre-stored file, so as to achieve the purpose of file upload, and furthermore, the security of file processing can be improved.
[0120] In this way, the effect of improving the security of file processing can be achieved.
[0121] In a possible implementation, refer to Figure 2 , according to the description metadata and the storage metadata of each pre-stored file, send the corresponding upload instruction to the client, including:
[0122] Step 1004: Determine whether there is a target storage metadata in the storage metadata of each pre-stored file that matches the unique identifier in the description metadata.
[0123] It should be noted that when executing step 1004, it can be determined whether there is a unique identifier in the storage metadata of a pre-stored file that is the same as the unique identifier in the description metadata by traversing the storage metadata of all pre-stored files stored in the computer device and comparing the unique identifiers in the storage metadata of all pre-stored files with the unique identifier in the description metadata.
[0124] In this way, it can be accurately determined whether there is such target storage metadata.
[0125] Step 1005: If it exists, determine the file size of the target file to be uploaded in the file to be stored according to the stored file size and the maximum storage size in the target storage metadata, and send the first upload instruction to the client.
[0126] Wherein, if the file size of the target file is 0, the first upload instruction includes the file size of the target file; otherwise, the first upload instruction includes the file size of the target file and the file header information of the first block file in the pre-stored block file.
[0127] Optionally, the stored file size may refer to the size of the pre-stored file stored in the computer device, and the maximum storage size may refer to the size of the complete file content of the pre-stored file.
[0128] Generally, the maximum storage size is equal to or greater than the stored file size.
[0129] It should be noted that if it exists, it indicates that the unique identifier of a pre-stored file stored in the computer device is the same as the unique identifier of the file to be stored, which also means that the complete file content of the pre-stored file is the same as the complete file content of the file to be stored.
[0130] It should be noted that if the maximum storage size is equal to the stored file size, it indicates that the pre-stored file has been completely stored in the computer device. In this case, there is no need to upload the file content of the pre-stored file or the file to be stored. Otherwise, it indicates that only a part of the pre-stored file is stored in the computer device. In this case, it is still necessary to continue uploading the part of the file content of the pre-stored file that is not stored in the computer device.
[0131] Step 1006: If it does not exist, generate new storage metadata according to the file attribute information and send a second upload instruction to the client.
[0132] The second upload instruction is used to instruct the client to start uploading from the first byte of the file to be stored.
[0133] Optionally, the unique identifier in the new storage metadata may be different from the unique identifiers of all pre-stored files currently stored in the computer device.
[0134] Then, the storage address indicated in the new storage metadata may also be different from the storage addresses of all pre-stored files currently stored in the computer device.
[0135] It should be noted that if it exists, it indicates that the unique identifiers of all pre-stored files stored in the computer device are different from the unique identifier of the file to be stored, which also means that there is no complete file content of any pre-stored file that is the same as the complete file content of the file to be stored. That is to say, no file content of the file to be stored is stored in the computer device, and it is necessary to completely upload the file to be stored from the first byte to the computer device.
[0136] In a possible implementation, refer to Figure 3 to determine the file size of the target file to be uploaded in the file to be stored according to the stored file size and the maximum storage size in the target storage metadata, and send a first upload instruction to the client, including:
[0137] Step 1007: Obtain and parse the target storage metadata to determine the stored file size and the maximum storage size.
[0138] In this way, the stored file size and the maximum storage size can be accurately determined, which can improve the accuracy of file processing.
[0139] Step 1008: Compare the maximum storage size with the stored file size.
[0140] Step 1009: If the maximum storage size is not greater than the stored file size, determine that the file size of the target file is 0, generate the first upload instruction according to the file size of the target file, and send the first upload instruction to the client.
[0141] Optionally, in this case, the first upload instruction can also instruct the client to directly generate and output information indicating that the upload is completed, so as to timely feedback the user's upload situation.
[0142] It should be noted that if the maximum storage size is not greater than the stored file size, it indicates that the pre-stored file has been completely stored in the computer device. In this case, there is no need to upload the file content of the pre-stored file or the file to be stored. Therefore, the file size of the target file is determined to be 0. After sending the first upload instruction generated according to the file size of the target file to the client, the client can be instructed not to perform any processing on the file to be stored and there is no need to upload the file to be stored.
[0143] In this way, the problem of repeated uploading of the file to be stored can be avoided, and the problem of storing multiple pre-stored files with the same unique identifier or the same file content in the computer device can also be avoided, thereby achieving the effect of reducing the storage redundancy and storage pressure of the computer device.
[0144] Step 1010: If the maximum storage size is greater than the stored file size, determine that the file size of the target file is the difference between the maximum storage size and the stored file size, generate the first upload instruction according to the file size of the target file and the file header information of the first block file in the pre-stored block file, and send the first upload instruction to the client.
[0145] Optionally, in this case, the first upload instruction can be used to instruct the client to split the target block file according to the size information in the file header information of the first block file, and can also be used to instruct the client to locate the starting position of the first target file block to be split according to the file size of the target file.
[0146] In this way, the flexibility of generating the upload instruction and sending the upload instruction to the client can be improved, and the accuracy of uploading the file to be stored can be improved.
[0147] In a possible implementation, determining the target storage metadata corresponding to the identifiers of the target block files, storing the target block files at the storage addresses indicated by the target storage metadata, and updating the pre-stored file includes:
[0148] If there is a pre-stored block file corresponding to the target storage metadata, then encrypt each target block file with the secret key in the file header information corresponding to the pre-stored block file and then store it, and use the stored target block files and the associated pre-stored block files as a new pre-stored file, and use the description metadata of the file to be stored corresponding to the target block file as the description metadata of the new pre-stored file.
[0149] Optionally, the pre-stored block file corresponding to the target storage metadata may refer to a pre-stored block file with the same unique identifier as the target storage metadata.
[0150] Optionally, the associated pre-stored block files may refer to pre-stored block files with the same unique identifier as the target block files.
[0151] It should be noted that if there is a pre-stored block file corresponding to the target storage metadata, it can indicate that the file content of each target block file is the subsequent file content of a pre-stored file currently stored in the computer device. That is to say, a part of the content of the file to be stored corresponding to each target block file has been stored in the computer device. Therefore, it is necessary to use the stored target block files and the associated pre-stored block files as a new pre-stored file, so as to ensure that the block files with the same unique identifier can be stored at a storage address as the same pre-stored file, and it can also ensure that each block file in each pre-stored file has the same unique identifier, thereby ensuring the unity, correctness and reliability of the file content of each pre-stored file.
[0152] If there is no pre-stored block file corresponding to the target storage metadata, then encrypt the other block files in each target block file except the first block file with the secret key in the file header information of the first block file in each target block file and then store it.
[0153] Optionally, after encrypting other block files in each target block file except the first block file, the storage can be specifically performed by storing the encrypted other block files at the storage addresses indicated by the storage metadata with the same unique identifier as each target block file.
[0154] It should be noted that if there is no pre-stored block file corresponding to the target storage metadata, it can be indicated that the file content of each target block file is new file content, and there is no file block in the computer device with the same unique identifier as each target block file. Therefore, it is necessary to store each target block file as a new pre-stored file in the computer device. Then, in this case, the first block file in each target block file has file header information. After encrypting other block files in each target block file except the first block file according to the secret key in the file header information of the first block file in each target block file, it can be ensured that the encryption methods of each target block file are the same.
[0155] In a possible implementation, the client can encrypt each target block file according to the secret key in the file header information in the above upload instruction. In this case, each target block file received by the computer device is an encrypted block file. Therefore, the computer device does not need to encrypt each target block file anymore and can directly store each target block file.
[0156] Determine the target storage metadata corresponding to the identifiers of each target block file, store each target block file at the storage address indicated by the target storage metadata, and update the pre-stored file, including:
[0157] Store each encrypted target block file of the client, and use the stored each target block file and the associated pre-stored block files as a new pre-stored file, and use the description metadata of the file to be stored corresponding to the target block file as the description metadata of the new pre-stored file.
[0158] In this way, the client can encrypt each target block file, and there is no need for the server to perform additional encryption processing, which can reduce the processing pressure on the server.
[0159] In a possible implementation, see Figure 4 , after generating the description metadata of the file to be stored, the description metadata will be stored, and after storing each target block file corresponding to the file to be stored, the description metadata of the file to be stored can be used as the description metadata of the pre-stored file. The description metadata of the pre-stored file also includes the encoding of the pre-stored file. The method further includes:
[0160] Step 1011: Receive a file download instruction sent by the client.
[0161] Optionally, the file download instruction includes the encoding of the file and the starting position of the download.
[0162] The encoding of the file may refer to the encoding or ID of the file to be downloaded.
[0163] The starting position of the download may refer to the position of the first byte of the file to be downloaded in the entire file to be downloaded.
[0164] Step 1012: Determine whether there is a file to be downloaded in the pre-stored files that matches the encoding of the file according to the encoding of each pre-stored file.
[0165] Optionally, the file to be downloaded may refer to any pre-stored file stored in the computer device.
[0166] Optionally, a file to be downloaded that matches the encoding of the file may refer to a pre-stored data corresponding to the storage metadata determined by searching for descriptive metadata with the encoding of the file, reading the unique identifier in the descriptive metadata, and then searching for storage metadata with the unique identifier according to the read unique identifier.
[0167] Step 1013: If there is a match, determine the target download file from the file to be downloaded according to the starting position of the download.
[0168] Optionally, the target download file may refer to a file in the file to be downloaded that includes the bytes from the starting position of the download to the last byte of the file to be downloaded.
[0169] It should be noted that if there is a match, it indicates that the file to be downloaded indicated by the file download instruction is stored in the computer device.
[0170] Step 1014: Determine the storage address of the target download file according to the storage metadata corresponding to the target download file, and obtain each download block file from the storage address of the target download file and send it to the client.
[0171] Optionally, each download block file may be all or part of the pre-stored block files corresponding to the file to be downloaded, specifically determined by the size of the target download file.
[0172] For example, if the starting position of the target download file is before the termination storage position of the first pre-stored block file among all the pre-stored block files corresponding to the file to be downloaded, then all the pre-stored block files may be used as each download block file.
[0173] If the download start position of the target download file is before the termination storage position of the Nth pre-stored block file among all the pre-stored block files corresponding to the file to be downloaded and after the start storage position of the Nth pre-stored block file, then all the pre-stored block files after the Nth pre-stored block file can be used as each download block file.
[0174] It should be noted that if the download start position is different from the start storage position of each pre-stored block file, then the pre-stored block file including the byte corresponding to the download start position can be directly used as the first download block file for download.
[0175] In this way, it can be ensured that the file content in each download block file sent to the client can completely include the target download file, and in this way, the integrity and reliability of the downloaded file can be ensured.
[0176] In a possible way, after executing step 1012, if there is no file to be downloaded indicated by the file download instruction in the computer device, that is, there is no to-be-downloaded file matching the encoding of the file, in this case, a download failure prompt message can be directly sent to the client.
[0177] In a possible implementation, refer to Figure 5 , obtaining each download block file from the storage address of the target download file and sending it to the client includes:
[0178] Step 1015: Determine the file header information of the download block file.
[0179] It should be noted that if each download block file includes the first pre-stored block file of each pre-stored block file, then the file header information of the first download block file in each download block file can be directly read. If each download block file does not include the first pre-stored block file of each pre-stored block file, then the file header information of the first pre-stored block file of each pre-stored block file can be read as the file header information of each download block file.
[0180] Step 1016: Determine the encrypted file in each download block file according to the size information in the file header information of the download block file.
[0181] That is to say, it is determined that the sizes of the encrypted files in each download block file are the same.
[0182] Step 1017: Decrypt the encrypted file according to the secret key in the file header information of the download block file to obtain the decrypted file, and send the decrypted file to the client.
[0183] In this way, it can be ensured that the files sent to the client are all in the form of plain text after decryption.
[0184] In a possible implementation, when storing each target block file at the storage address indicated by the target storage metadata, a pseudo name can also be randomly generated for each target block file, and corresponding suffixes can be added to each target block file in the order of the target block files.
[0185] The order of each target block file can refer to the order in which the associated pre-stored block files are sorted according to the starting storage location and / or the ending storage location.
[0186] For example, if the order of a target block file is 1, then the suffix.part1 can be added to this target block file, and if the order of another target block file is N, then the suffix.partN can be added to this other target block file.
[0187] Exemplarily, assuming that the secret key is a 32-byte parameter, then the 33rd to 50th bytes in the first pre-stored block file corresponding to each downloaded block file can be taken out, and the information between the 33rd byte and the delimiter is split out as the size information of each downloaded block file through the position of the delimiter.
[0188] Specifically, the suffix partN of the first downloaded block file that needs to be taken out in the storage module can also be calculated through the following formula:
[0189] N = (download start position ÷ size information) + 1
[0190] The value of (download start position ÷ size information) is rounded, the pre-stored block file with the suffix partN is used as the first downloaded block file that needs to be taken out, then the first 32 characters in the first pre-stored block file corresponding to each downloaded block file are taken out as the secret key, and the file content before encryption is decrypted through the secret key.
[0191] If N = 1, then the bytes before the delimiter in the file header information need to be removed before decrypting this downloaded block file, so that the correctness of the decrypted file content can be ensured.
[0192] For another example, the starting extraction coordinate Pos of the decrypted content of partN can also be calculated through the following formula:
[0193] Pos = download start position % size information
[0194] Using Pos as the starting extraction to intercept the decrypted content of the downloaded block file of partN and return it to the client. In this way, even if the download start position is different from the starting storage position of the first downloaded block file, the bytes between the download start position and the ending storage position of the first downloaded block file can be intercepted through Pos and returned to the client. In this way, the accuracy of sending the target downloaded file to the client can be improved.
[0195] Then, set N = N + 1. If there is still a pre-stored file block with the suffix partN in the computer device, continue to retrieve it, decrypt it, and return it to the client.
[0196] Loop the above processing process until all the pre-stored block files are retrieved, that is, all the downloaded block files are retrieved, and decrypt all the pre-stored block files and return them to the client.
[0197] See Figure 6 , this embodiment of the present application also provides a file processing method, which includes:
[0198] Step 2001: Send the file attribute information of the file to be stored to the server.
[0199] The file attribute information includes the unique identifier and the file size of the file to be stored.
[0200] Step 2002: Receive and parse the upload instruction sent by the server to obtain the target file to be uploaded and the file size of the target file indicated by the upload instruction.
[0201] The upload instruction includes the above first upload instruction and the above second upload instruction.
[0202] Step 2003: Split the target file into multiple files to be stored blocks and send them to the server for storage.
[0203] It should be noted that in this way, the purpose of uploading the file to the server can be achieved. Moreover, during the process of uploading each file to be stored block, the client does not need to use the metadata of each file to be stored block. In this way, there is no need to send the metadata to the client, thereby improving the security of file processing.
[0204] In a possible implementation manner, if the received upload instruction is the first upload instruction, splitting the target file into multiple files to be stored blocks and sending them to the server for storage includes:
[0205] Parse the first upload instruction to determine the file size of the target file.
[0206] If the file size of the target file is 0, generate and output the information indicating that the upload is completed.
[0207] In this case, the client does not need to operate on each file to be stored.
[0208] If the file size of the target file is not 0, obtain the file header information in the first upload instruction, and split at least one file to be stored block from the target file according to the size information in the file header information.
[0209] Exemplarily, if the secret key is a 32-byte parameter, the content from the 33rd byte to the 50th byte of the file header information is read to determine the position of the above-mentioned delimiter, and the content before the delimiter in the content from the 33rd byte to the 50th byte is identified to determine the size information in the file header information.
[0210] Specifically, the first character of the target file can be used as the starting position to split out a to-be-stored block file that is the same size as the size information.
[0211] If the secret key is a 32-byte parameter, the content of the first 32 bytes of the file header information can also be taken out, and the taken-out content can be used as the secret key to encrypt the to-be-stored block file. It is also possible not to take out the secret key, but to encrypt the to-be-stored block file by the server after uploading the to-be-stored block file. The embodiments of the present application do not limit this.
[0212] Send each to-be-stored block file to the server.
[0213] Optionally, each to-be-stored block file can be an encrypted block file or an unencrypted block file.
[0214] After sending each to-be-stored block file to the server, each to-be-stored block file can be regarded as the target block file received by the server.
[0215] In this way, the first upload instruction can be correctly responded to, ensuring the reliability and accuracy of file processing.
[0216] In a possible implementation manner, if the received upload instruction is a second upload instruction, splitting the target file into multiple to-be-stored block files and sending them to the server for storage includes:
[0217] Regarding the to-be-stored file as the target file, splitting the target file into at least one to-be-stored block file according to a preset size.
[0218] Optionally, the preset size can be set by relevant technical personnel according to actual needs, or can be selected by the client according to the current network environment and device hardware environment. The embodiments of the present application do not limit this.
[0219] Randomly generate a secret key corresponding to the to-be-stored block file, and use the secret key corresponding to the to-be-stored block file and the preset size as the file header information of the first to-be-stored block file among each to-be-stored block file.
[0220] Optionally, randomly generating a secret key corresponding to the to-be-stored block file may mean calling any encryption algorithm to obtain a secret key for encrypting and decrypting the block file.
[0221] Send each file block to be stored to the server.
[0222] In this way, the second upload instruction can be correctly responded to, and the file to be stored can be uploaded starting from the first byte of the file to be stored.
[0223] In a possible implementation, the method further includes:
[0224] Send a file download instruction to the server.
[0225] Optionally, the file download instruction includes the encoding of the file and the download start position.
[0226] Optionally, the file download instruction can be an instruction input by the user to the client through an input device.
[0227] Receive each downloaded file block sent by the server.
[0228] In this way, the purpose of downloading a file from the server can be achieved. Moreover, during the process of receiving each downloaded file block, the client does not need to use the metadata of each downloaded file block. Thus, there is no need to send the metadata to the client, and the security of file processing can be improved accordingly.
[0229] The following describes the apparatus, device, computer-readable storage medium, etc. for executing the file processing method provided in this application. For the specific implementation process and technical effects, please refer to the above, and details will not be repeated below.
[0230] Figure 7 is a schematic structural diagram of a file processing apparatus provided by an embodiment of this application. Refer to Figure 7 The apparatus includes:
[0231] An acquisition and generation module 301, configured to acquire file attribute information uploaded by a client, and generate descriptive metadata according to the file attribute information. The file attribute information includes a unique identifier of the file to be stored and the file size. The descriptive metadata is used to record the file attribute information, and the unique identifier is used to identify the file content of the file to be stored;
[0232] A sending module 302, configured to send an upload instruction to the client according to the descriptive metadata and the storage metadata of each pre-stored file. The upload instruction is used to indicate the target file to be uploaded and the file size of the target file. The pre-stored files include at least one pre-stored block file. The first pre-stored block file in each pre-stored block file includes file header information. The file header information includes block file size information and a secret key. Each pre-stored block file after the first pre-stored block file is encrypted based on the secret key. The storage metadata is used to indicate the unique identifier of the pre-stored file and the storage address;
[0233] A storage module 303, configured to obtain and store the target block files sent by the client, determine target storage metadata corresponding to the identifiers of the target block files, store the target block files at the storage addresses indicated by the target storage metadata, and update the pre-stored files.
[0234] Figure 8 It is a schematic structural diagram of a file processing device provided by an embodiment of the present application. Refer to Figure 8 , the device includes:
[0235] An attribute information sending module 401, configured to send file attribute information of a file to be stored to a server, where the file attribute information includes a unique identifier and a file size of the file to be stored;
[0236] A receiving and parsing module 402, configured to receive and parse an upload instruction sent by the server, and obtain a target file to be uploaded and the file size of the target file indicated by the upload instruction;
[0237] A splitting and sending module 403, configured to split the target file into multiple block files to be stored and send them to the server for storage.
[0238] The above device is used to execute the method provided in the foregoing embodiment, and its implementation principle and technical effects are similar, which will not be elaborated here.
[0239] The above modules may be one or more integrated circuits configured to implement the above method, for example: one or more application specific integrated circuits (ASICs), or, one or more microprocessors, or, one or more field programmable gate arrays (FPGAs), etc. Again, when the above certain module is implemented in the form of a processing element dispatching program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program code. Again, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0240] Figure 9 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Refer to Figure 9 , the computer device includes: a memory 501 and a processor 502. A computer program that can run on the processor 502 is stored in the memory 501. When the processor 502 executes the computer program, the steps in any of the above method embodiments are implemented.
[0241] The embodiments of the present application also provide a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0242] Optionally, the present application also provides a program product, such as a computer-readable storage medium, including a program, which is used to execute any of the above-mentioned file processing method embodiments when executed by a processor.
[0243] In several embodiments provided by the present invention, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.
[0244] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0245] In addition, the functional units in each embodiment of the present invention can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.
[0246] The above-mentioned integrated units implemented in the form of software functional units can be stored in a computer-readable storage medium. The above-mentioned software functional units are stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute some steps of the methods in each embodiment of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (English: Read-Only Memory, abbreviated as: ROM), random access memories (English: Random Access Memory, abbreviated as: RAM), magnetic disks or optical discs that can store program codes.
[0247] The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
[0248] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. A file processing method, characterized in that, The method includes: Obtaining file attribute information uploaded by a client, and generating descriptive metadata according to the file attribute information. The file attribute information includes a unique identifier and a file size of a file to be stored. The descriptive metadata is used to record the file attribute information, and the unique identifier is used to identify the file content of the file to be stored; Sending an upload instruction to the client according to the descriptive metadata and the storage metadata of each pre-stored file. The upload instruction is used to indicate a target file to be uploaded and the file size of the target file. The pre-stored files include at least one pre-stored block file. The first pre-stored block file in each of the pre-stored block files includes file header information. The file header information includes block file size information and a secret key. Each of the pre-stored block files after the first pre-stored block file is encrypted based on the secret key. The storage metadata is used to indicate the unique identifier and the storage address of the pre-stored file; Obtaining and storing the target block files sent by the client, determining target storage metadata corresponding to the unique identifiers of the target block files, storing each of the target block files at the storage address indicated by the target storage metadata, and updating the pre-stored file; The sending an upload instruction to the client according to the descriptive metadata and the storage metadata of each pre-stored file includes: Determining whether there is a target storage metadata in the storage metadata of each pre-stored file that matches the unique identifier in the descriptive metadata; If it exists, determining the file size of the target file to be uploaded in the file to be stored according to the stored file size and the maximum storage size in the target storage metadata, and sending a first upload instruction to the client. Wherein, if the file size of the target file is 0, the first upload instruction includes the file size of the target file. Otherwise, the first upload instruction includes the file size of the target file and the file header information of the first block file in the pre-stored block file; If it does not exist, generating new storage metadata according to the file attribute information, and sending a second upload instruction to the client. The second upload instruction is used to instruct the client to start uploading from the first byte of the file to be stored; The determining target storage metadata corresponding to the unique identifiers of the target block files, storing each of the target block files at the storage address indicated by the target storage metadata, and updating the pre-stored file includes: If there is a pre-stored block file corresponding to the target storage metadata, encrypting each of the target block files according to the secret key in the file header information corresponding to the pre-stored block file and then storing them, and taking the stored target block files and the associated pre-stored block files as a new pre-stored file, and taking the descriptive metadata of the file to be stored corresponding to the target block file as the descriptive metadata of the new pre-stored file; If there is no pre-stored block file corresponding to the target stored metadata, encrypt other block files except the first block file in each of the target block files with the secret key in the file header information of the first block file in each of the target block files, and then store them.
2. The document processing method according to claim 1, wherein The determining the file size of the target file to be uploaded in the file to be stored according to the stored file size and the maximum storage size in the target stored metadata, and sending the first upload instruction to the client includes: Obtaining and parsing the target stored metadata to determine the stored file size and the maximum storage size; Comparing the maximum storage size with the stored file size; If the maximum storage size is not greater than the stored file size, determining that the file size of the target file is 0, generating the first upload instruction according to the file size of the target file, and sending the first upload instruction to the client; If the maximum storage size is greater than the stored file size, determining that the file size of the target file is the difference between the maximum storage size and the stored file size, generating the first upload instruction according to the file size of the target file and the file header information of the first block file in the pre-stored block file, and sending the first upload instruction to the client.
3. The document processing method according to claim 1, wherein The determining the target stored metadata corresponding to the identifier of each of the target block files, storing each of the target block files at the storage address indicated by the target stored metadata, and updating the pre-stored file includes: Storing each of the target block files encrypted by the client, using each of the stored target block files and the associated pre-stored block files as a new pre-stored file, and using the description metadata of the file to be stored corresponding to the target block file as the description metadata of the new pre-stored file, where the associated pre-stored block files are used to indicate the pre-stored block files with the same unique identifier as each of the target block files.
4. The document processing method according to any one of claims 1-3, characterized in that, The description metadata of the pre-stored file further includes the encoding of the pre-stored file; The method further includes: Receiving a file download instruction sent by the client, where the file download instruction includes the encoding of the file and the download start position; Determining whether there is a piece of data to be downloaded that matches the encoding of the file in the pre-stored file according to the encoding of each of the pre-stored files; If there is, determining the target download file from the data to be downloaded according to the download start position; Determining the storage address of the target download file from the storage metadata corresponding to the target download file, and obtaining each download block file from the storage address of the target download file and sending it to the client.
5. The document processing method according to claim 4, wherein The obtaining each download block file from the storage address of the target download file and sending it to the client includes: Determining the file header information of the download block file; Determining the encrypted file in each of the download block files according to the size information in the file header information of the download block file; Decrypting the encrypted file with the secret key in the file header information of the download block file to obtain the decrypted file, and sending the decrypted file to the client.
6. A file processing method, characterized in that, The method includes: Sending file attribute information of a file to be stored to a server, where the file attribute information includes a unique identifier and a file size of the file to be stored; Receiving and parsing an upload instruction sent by the server to obtain a target file to be uploaded and the file size of the target file indicated by the upload instruction. The upload instruction includes a first upload instruction and a second upload instruction. The first upload instruction includes the file size of the target file and file header information of the first block file in a pre-stored block file. The second upload instruction is used to instruct the client to start uploading from the first byte of the file to be stored; Dividing the target file into multiple block files to be stored and sending them to the server for storage; The dividing the target file into multiple block files to be stored and sending them to the server for storage includes: If the received upload instruction is the first upload instruction and the file size of the target file is 0, generating and outputting information indicating that the upload is completed; If the received upload instruction is the first upload instruction and the file size of the target file is not 0, obtaining the file header information in the first upload instruction, and dividing at least one block file to be stored from the target file according to the size information in the file header information; If the received upload instruction is the second upload instruction, using the file to be stored as the target file and dividing the target file into at least one block file to be stored according to a preset size.
7. A file processing device, characterized in that, The device includes: An acquisition and generation module, configured to acquire file attribute information uploaded by a client and generate descriptive metadata according to the file attribute information. The file attribute information includes a unique identifier and a file size of a file to be stored. The descriptive metadata is used to record the file attribute information, and the unique identifier is used to identify the file content of the file to be stored; A sending module, configured to send an upload instruction to the client according to the descriptive metadata and storage metadata of each pre-stored file. The upload instruction is used to indicate a target file to be uploaded and the file size of the target file. The pre-stored files include at least one pre-stored block file. The first pre-stored block file in each of the pre-stored block files includes file header information. The file header information includes size information and a secret key of the block file. Each of the pre-stored block files after the first pre-stored block file is obtained by encrypting based on the secret key. The storage metadata is used to indicate the unique identifier and storage address of the pre-stored file; A storage module, configured to acquire and store the target block files sent by the client, determine target storage metadata corresponding to the identifiers of each of the target block files, store each of the target block files at the storage address indicated by the target storage metadata, and update the pre-stored files; The sending module is specifically configured to: Determine whether there is a target storage metadata in the storage metadata of each pre-stored file that matches the unique identifier in the descriptive metadata; If it exists, determine the file size of the target file to be uploaded in the file to be stored according to the stored file size and the maximum storage size in the target storage metadata, and send a first upload instruction to the client. If the file size of the target file is 0, the first upload instruction includes the file size of the target file; otherwise, the first upload instruction includes the file size of the target file and the file header information of the first block file in the pre-stored block file. If it does not exist, generate new storage metadata according to the file attribute information, and send a second upload instruction to the client, where the second upload instruction is used to instruct the client to start uploading from the first byte of the file to be stored. The storage module is specifically configured to: If there is a pre-stored block file corresponding to the target storage metadata, encrypt each of the target block files according to the secret key in the file header information corresponding to the pre-stored block file and then store them, and use the stored target block files and the associated pre-stored block files as a new pre-stored file, and use the description metadata of the file to be stored corresponding to the target block file as the description metadata of the new pre-stored file. If there is no pre-stored block file corresponding to the target storage metadata, encrypt the other block files in each of the target block files except the first block file according to the secret key in the file header information of the first block file in each of the target block files and then store them.
8. A computer device, characterized in that, Including: A memory and a processor, where the memory stores a computer program that can run on the processor. When the processor executes the computer program, the steps of the file processing method described in any one of claims 1 to 5 above and the steps of the file processing method described in claim 6 above are implemented.
9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium. When the computer program is executed by the processor, the steps of the file processing method described in any one of claims 1 to 5 above and the steps of the file processing method described in claim 6 above are implemented.
Citation Information
Patent Citations
File uploading method, file downloading method and file management device
CN113273163A