File uploading method, electronic equipment and computer readable medium

By using a file upload method that presets a set of checksums and fragment digest values, the problems of resource waste and low security caused by hash algorithms are solved, and efficient and secure file uploads are achieved.

CN119011573AActive Publication Date: 2024-11-22YICI NETCOM (HANGZHOU) TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202411499179.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2024-11-22
Estimated Expiration
2044-10-25

AI Technical Summary

Technical Problem

Existing file upload methods are based on hash algorithms, which result in long CPU resource consumption, long waiting times, and low security. This is especially true when uploading large files, where there is significant resource waste and a risk of data leakage.

Method used

The system uses a preset checksum determination method and a random data range pre-agreed with the server to determine the checksum and fragment digest value set of the file to be uploaded. The client uploads the file according to the collision detection conditions of the server, and the server judges the file integrity through the fragment digest value set and sends the corresponding notification.

Benefits of technology

It improves file upload efficiency, avoids wasting resources and time, enhances security, reduces duplicate uploads, and prevents data leaks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119011573A_ABST
    Figure CN119011573A_ABST
Patent Text Reader

Abstract

The invention discloses a file uploading method, electronic equipment and a computer readable medium, and the method comprises the steps: determining a verification value of a to-be-uploaded file and a fragment digest value set according to a preset verification value determination mode and a random data range pre-agreed with a server; sending a file uploading start request message carrying the verification value and the fragment digest value set to the server; uploading the to-be-uploaded file according to an uploading task identifier and a collision detection condition carried in an incomplete uploading notification message under the condition that the incomplete uploading notification message sent by the server is received; under the condition that a complete uploading notification message sent by the server side is received, analyzing the complete uploading notification message to obtain file storage information; the complete uploading notification message is sent under the condition that the server side determines that a file with a verification value exists locally and a fragment digest value set determined according to the file is matched with the fragment digest value set carried in the file uploading start request message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of file uploading, and in particular, to a file uploading method, an electronic device and a computer-readable medium. Background Art

[0002] File upload is an important function in cloud storage systems. Especially for some small private clouds, it can not only avoid uploading unnecessary files, but also ensure that only one copy of the same file is stored, thus avoiding wasting bandwidth and storage costs.

[0003] The current file upload method is usually based on hash algorithms (such as md5 algorithm and sha series algorithms). Specifically, the client first calculates the hash value of the file to be uploaded according to the hash algorithm, and then sends a data request carrying the hash value to the server. The server detects whether the hash value already exists, thereby determining whether it already has the file, and returns the corresponding detection result to the client. However, this method has many defects such as long CPU resource occupation, long waiting time, and low security. Summary of the invention

[0004] The present application aims to solve one of the technical problems in the related art to a certain extent. To this end, the present application provides a file uploading method, an electronic device and a computer readable medium.

[0005] As a first aspect of the present application, a file uploading method is provided, which is used for a client, wherein the method comprises: Determine the checksum and fragment summary value set of the file to be uploaded according to the preset checksum determination method and the random data range pre-agreed with the server; Sending a file upload start request message carrying the verification value and the fragment summary value set to the server; Upon receiving the incomplete upload notification message sent by the server, uploading the file to be uploaded according to the upload task identifier and the collision detection condition carried in the incomplete upload notification message; wherein the collision detection condition is generated by the server according to the set of fragment summary values ​​carried in the file start upload request message; When receiving a complete upload notification message sent by the server, the complete upload notification message is parsed to obtain file storage information; wherein, the complete upload notification message is sent by the server when it is determined that a file with the verification value exists locally and a set of fragment summary values ​​determined based on the file matches the set of fragment summary values ​​carried in the file start upload request message.

[0006] Optionally, uploading the file to be uploaded according to the upload task identifier and the collision detection condition carried in the incomplete upload notification message includes: In the case that it is determined according to the collision detection condition that the collision detection fails, generating a file normal upload request message according to the file to be uploaded, and sending the file normal upload request message to the server; In the case where it is determined according to the collision detection condition that the collision detection passes, generating a file upload progress request message according to the upload task identifier, and sending the file upload progress request message to the server; Receive a file upload progress response message sent by the server, and upload the file to be uploaded according to the file upload progress response message.

[0007] Optionally, uploading the file to be uploaded according to the file upload progress response message includes: Obtain the number of uploaded bytes carried in the file upload progress response message; Upload the data in the file to be uploaded to the server from the upload start point in the file to be uploaded that matches the number of bytes uploaded.

[0008] Optionally, determining the check value and the fragment summary value set of the file to be uploaded according to a preset check value determination method and a random data range pre-agreed with the server includes: Dividing the file to be uploaded into a starting data block and a plurality of split data blocks according to the size of the file to be uploaded, a preset starting data block size, and a preset split data block size; Determine the check value of the file to be uploaded according to the size of the file to be uploaded, the preset starting data block size, the preset split data block size, the starting data block and the multiple split data blocks, and a preset check value algorithm; According to the random data range pre-agreed with the server, the starting data block and multiple segmented data blocks, a shard set and a shard summary value set thereof are determined; wherein one shard is one data block, and the shard value summary corresponds one-to-one to the shard.

[0009] Optionally, determining the checksum of the file to be uploaded according to the size of the file to be uploaded, the preset starting data block size, the preset split data block size, the starting data block and the multiple split data blocks, and a preset checksum algorithm includes: Determine the number of sample data block intervals according to the size of the file to be uploaded, the preset starting data block size, and the preset segmented data block size; Determine a plurality of sample data chunks from the plurality of segmented data chunks according to the number of sample data chunk intervals; Determining a summary value of the file to be uploaded according to the size of the file to be uploaded, the starting data block, and the multiple sample data blocks; Determine the checksum of the summary value according to a preset check value algorithm; A checksum value of the file to be uploaded is determined based on the digest value and the checksum.

[0010] As a second aspect of the present application, a file uploading method is provided for use on a server, wherein the method comprises: Receive a file upload start request message sent by a client, and obtain a check value and a fragment summary value set of the file to be uploaded carried therein; wherein the check value and the fragment summary value set are determined by the client according to a preset check value determination method and a random data range pre-agreed with the server; When it is determined that a file having the verification value exists locally and the set of fragment digest values ​​determined based on the file matches the set of fragment digest values ​​carried in the file start upload request message, sending a complete upload notification message carrying file storage information to the client; When it is determined that the file to be uploaded is not completely uploaded, an incomplete upload notification message including an upload task identifier and a collision detection condition is sent to the client, so that the client can upload the file to be uploaded according to the upload task identifier and the collision detection condition; wherein the collision detection condition is generated by the server according to the set of fragment summary values ​​carried in the file start upload request message.

[0011] Optionally, when it is determined that the file to be uploaded is not completely uploaded, sending an incomplete upload notification message including an upload task identifier and a collision detection condition to the client includes: In the case where it is determined that a file with the check value exists locally and a set of shard summary values ​​determined based on the file does not match the set of shard summary values ​​carried in the file start upload request message, and in the case where it is determined that a file with the check value does not exist locally and there is no unfinished task corresponding to the check value, an upload task identifier and a collision detection condition are generated, and an incomplete upload notification message carrying the upload task identifier and the collision detection condition is sent to the client; When it is determined that there is no file with the verification value locally but there is an unfinished task corresponding to the verification value, a collision detection condition is generated, and an incomplete upload notification message carrying the upload task identifier of the unfinished task and the collision detection condition is sent to the client.

[0012] Optionally, when it is determined that a file having the verification value exists locally, the method further includes: According to a random data range pre-agreed with the client, a set of shards and a set of shard summary values ​​thereof are determined from a plurality of data blocks corresponding to the locally existing files having the verification value; wherein one shard is one data block, and the shard value summary corresponds one-to-one to the shard.

[0013] As a third aspect of the present application, an electronic device is provided, wherein the electronic device includes: one or more processors; A memory having one or more computer programs stored thereon, wherein when the one or more computer programs are executed by the one or more processors, the one or more processors implement the file upload method described in the first aspect of the present application or the file upload method described in the second aspect of the present application.

[0014] As a fourth aspect of the present application, a computer-readable medium is provided, on which a computer program is stored, wherein when the computer program is executed by a processor, the file upload method described in the first aspect of the present application or the file upload method described in the second aspect of the present application is implemented.

[0015] In the file upload method provided in the embodiment of the present application, the client determines the check value and the fragment summary value set of the file to be uploaded according to the preset check value determination method and the random data range pre-agreed with the server, and sends a file start upload request message carrying the check value and the fragment summary value set to the server, which can quickly calculate the check value and the fragment summary value set used by the server to determine whether the file to be uploaded has been completely uploaded, effectively improving the file upload efficiency and avoiding resource waste and time waste; subsequently, when the client receives the incomplete upload notification message sent by the server, according to the upload task identifier and collision detection condition carried in the incomplete upload notification message, the file to be uploaded is uploaded, and the client performs collision detection through the collision detection condition generated by the server according to the fragment summary value set, which can further improve the file upload efficiency and security, and avoid resource waste and time waste. When the client receives the complete upload notification message sent by the server, it can directly obtain the file storage information by parsing the complete upload notification message, without having to repeatedly upload the file to be uploaded, further avoiding resource waste and time waste. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The present application is further described below in conjunction with the accompanying drawings: Figure 1It is a flowchart of an implementation method of a method for uploading files on a client side provided in an embodiment of the present application; Figure 2 This is a flowchart of an implementation method of uploading a file to be uploaded according to an upload task identifier and a collision detection condition provided in an embodiment of the present application; Figure 3 It is a flowchart of an implementation method of uploading a file to be uploaded according to a file upload progress response message provided in an embodiment of the present application; Figure 4 It is a flowchart of an implementation method of determining a checksum value and a set of fragment summary values ​​of a file to be uploaded provided in an embodiment of the present application; Figure 5 It is a flowchart of an implementation method of determining the check value of a file to be uploaded provided in an embodiment of the present application; Figure 6 This is a schematic diagram of the division of files to be uploaded provided in an embodiment of the present application; Figure 7 This is a flowchart of an implementation method of a method for uploading files on a server side provided in an embodiment of the present application; Figure 8 It is a flowchart of an implementation method of sending an incomplete upload notification message including an upload task identifier and a collision detection condition to a client provided in an embodiment of the present application; Fig. 9 It is a module diagram of an implementation of an electronic device provided in an embodiment of the present application; Fig.10 It is a schematic diagram of a computer-readable medium provided in an embodiment of the present application.

[0017] Description of Reference Numerals 101: Processor 102: Memory 103: I / O interface 104: bus DETAILED DESCRIPTION The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments based on the embodiments are intended to be used to explain the present application and cannot be understood as limiting the present application.

[0018] References to "one embodiment" or "an example" or "an example" in this specification mean that a particular feature, structure, or characteristic described in conjunction with the embodiment itself may be included in at least one embodiment disclosed in the present application. The appearance of the phrase "in one embodiment" in various places in the specification does not necessarily refer to the same embodiment.

[0019] Current file upload methods are usually based on hash algorithms. However, the larger the file to be uploaded, the longer it takes to calculate the hash value. For the client, the CPU resources will be occupied and the waiting time will be longer, resulting in more waste of resources and time. In addition, in the scenario where the hash value of the file remains a string of a specific length, it is theoretically possible to simulate the client and initiate an upload request to the server by enumerating all hash values, launching an attack on the server, and even obtaining the corresponding file based on the file representation returned by the server, resulting in data leakage and seriously affecting data security.

[0020] In view of this, as a first aspect of the embodiment of the present application, a file uploading method is provided for use by a client, such as Figure 1 As shown, the method may include the following steps: In step S110, the check value and the fragment summary value set of the file to be uploaded are determined according to the preset check value determination method and the random data range pre-agreed with the server; In step S120, a file upload start request message carrying the verification value and the segment summary value set is sent to the server; In step S130, upon receiving the incomplete upload notification message sent by the server, the to-be-uploaded file is uploaded according to the upload task identifier and the collision detection condition carried in the incomplete upload notification message; wherein the collision detection condition is generated by the server according to the set of fragment summary values ​​carried in the file start upload request message; In step S140, when the complete upload notification message sent by the server is received, the complete upload notification message is parsed to obtain the file storage information; wherein, the complete upload notification message is sent by the server when it is determined that there is a file with the verification value locally and the set of fragment summary values ​​determined based on the file matches the set of fragment summary values ​​carried in the file start upload request message.

[0021] After receiving the file upload start request message sent by the client, the server determines whether the file requested by the client to upload has been completely uploaded to the server according to the checksum value of the file to be uploaded and the fragment summary value set carried therein. When the server determines that the file requested by the client to upload has not been completely uploaded to the server, it sends an incomplete upload notification message to the client. When the server determines that the file requested by the client to upload has been completely uploaded to the server, it sends a complete upload notification message to the client.

[0022] When receiving an incomplete upload notification message sent by the server, the client decides how to upload the file to be uploaded based on the upload task identifier and collision detection conditions carried in the incomplete upload notification message. When receiving a complete upload notification message sent by the server, the client obtains the file storage information by parsing the complete upload notification message. It can be understood that the file storage information records the relevant storage information of the file to be uploaded requested by the client after it was completely uploaded to the server.

[0023] In the file upload method provided in the embodiment of the present application, the client determines the check value and the fragment summary value set of the file to be uploaded according to the preset check value determination method and the random data range pre-agreed with the server, and sends a file start upload request message carrying the check value and the fragment summary value set to the server, which can quickly calculate the check value and the fragment summary value set used by the server to determine whether the file to be uploaded has been completely uploaded, effectively improving the file upload efficiency and avoiding resource waste and time waste; subsequently, when the client receives the incomplete upload notification message sent by the server, according to the upload task identifier and collision detection condition carried in the incomplete upload notification message, the file to be uploaded is uploaded, and the client performs collision detection through the collision detection condition generated by the server according to the fragment summary value set, which can further improve the file upload efficiency and security, and avoid resource waste and time waste. When the client receives the complete upload notification message sent by the server, it can directly obtain the file storage information by parsing the complete upload notification message, without having to repeatedly upload the file to be uploaded, further avoiding resource waste and time waste.

[0024] As described above, upon receiving the incomplete upload notification message sent by the server, the client will perform collision detection according to the collision detection condition carried therein. Accordingly, in some embodiments, the to-be-uploaded file is uploaded (i.e., the process involved in step S130) according to the upload task identifier and the collision detection condition carried in the incomplete upload notification message. Figure 2 As shown, the following steps may be included: In step S210, when it is determined according to the collision detection condition that the collision detection fails, a file normal upload request message is generated according to the file to be uploaded, and the file normal upload request message is sent to the server; In step S220, when it is determined that the collision detection is passed according to the collision detection condition, a file upload progress request message is generated according to the upload task identifier, and the file upload progress request message is sent to the server; In step S230, a file upload progress response message sent by the server is received, and the file to be uploaded is uploaded according to the file upload progress response message.

[0025] For the case where the file requested to be uploaded by the client is not completely uploaded to the server, specifically, when the server determines that there is a file with the verification value locally and the set of fragment summary values ​​determined based on the file does not match the set of fragment summary values ​​carried in the file start upload request message, and when the server determines that there is no file with the verification value locally and there is no unfinished task corresponding to the verification value, the server generates an upload task identifier and a collision detection condition, and sends an incomplete upload notification message carrying the upload task identifier and the collision detection condition to the client. When the server determines that there is no file with the verification value locally but there is an unfinished task corresponding to the verification value, the server generates a collision detection condition, and sends an incomplete upload notification message carrying the upload task identifier of the unfinished task and the collision detection condition to the client.

[0026] In the above three cases, the server determines that the file requested by the client is not completely uploaded to the server, so the server sends an incomplete upload notification message to the client. However, in the first two cases, it means that the server currently does not have an unfinished task for the client, and the server needs to generate a new upload task ID. In the last case, it means that the server currently has an unfinished task for the client, and there is no need to generate a new upload task ID. Instead, the upload task ID of the unfinished task is directly returned to the client.

[0027] For collision detection conditions, if the server determines that the file requested by the client is not completely uploaded to the server, it will generate collision detection conditions from the fragment summary value set received from the client and return it to the client. The client performs collision detection according to the collision detection conditions. Specifically, the client compares the fragment summary value set in the collision detection condition with the fragment summary value set determined by itself before. If they are inconsistent, it means that the fragment summary value set sent by the client to the server has changed. If the uploaded file is also likely to be affected, it is determined that the collision detection has failed. If they are consistent, it is determined that the collision detection has passed.

[0028] When it is determined that the collision detection fails, the client will switch to uploading according to the conventional hash algorithm uploading method, that is, generate a file normal upload request message according to the file to be uploaded, and send the file normal upload request message to the server.

[0029] When it is determined that the collision detection has passed, the client will query the upload progress, that is, generate a file upload progress request message according to the upload task identifier, and send the file upload progress request message to the server, receive the file upload progress response message sent by the server, and upload the file to be uploaded according to the file upload progress response message.

[0030] In some embodiments, the uploading of the to-be-uploaded file according to the file upload progress response message (ie, the step involved in step 230) is as follows: Figure 3 As shown, the following steps may be included: In step S310, the number of uploaded bytes carried in the file upload progress response message is obtained; In step S320, data in the file to be uploaded is uploaded to the server from the upload start point in the file to be uploaded that matches the number of bytes uploaded.

[0031] For example, when the number of uploaded bytes carried in the file upload progress response message is 0, the client will start uploading from the beginning of the file to be uploaded. When the number of uploaded bytes carried in the file upload progress response message is 50, the client will start uploading from the 51st byte of the file to be uploaded.

[0032] It can be understood that the entire file upload process involves several stages including starting to request upload, querying upload progress, uploading each segment data, and completing upload. The file upload method provided in the embodiment of the present application only optimizes the stage of starting to request upload, and therefore only involves the two stages of starting to request upload and querying upload progress, and does not elaborate on the subsequent stages of uploading each segment data, completing upload, etc. In fact, starting from step S230, the client will execute the subsequent stages as usual.

[0033] The applicant of the present application further proposed that the reason why the relevant technology takes longer to calculate the hash value when the file is larger is because the hash algorithm itself is more complicated, and it is even more complicated to use the hash algorithm directly on the basis of large files. In view of this, the efficiency of the check value calculation can be greatly improved by first splitting the file, then splicing the specific data block with the file size as the summary value, and finally checking and calculating the summary value. Accordingly, in some embodiments, the check value of the file to be uploaded and the set of fragment summary values ​​are determined according to the preset check value determination method and the random data range pre-agreed with the server (i.e., step S110), such as Figure 4 As shown, the following steps may be included: In step S410, the file to be uploaded is divided into a starting data block and a plurality of split data blocks according to the size of the file to be uploaded, a preset starting data block size, and a preset split data block size; In step S420, a checksum of the file to be uploaded is determined according to the size of the file to be uploaded, the preset starting data block size, the preset split data block size, the starting data block and the multiple split data blocks, and a preset checksum algorithm; In step S430, a shard set and a shard summary value set are determined based on the random data range pre-agreed with the server, the starting data block and multiple segmented data blocks; wherein one shard is one data block, and the shard value summary corresponds one-to-one to the shard.

[0034] In the embodiment of the present application, there is no specific limitation on how to execute step S410. For example, a data block matching a preset starting data block size can be divided from the beginning of the file to be uploaded as the starting data block; then the remaining data in the file to be uploaded is divided into multiple data blocks according to the preset split data block size as split data blocks. When the length of the last data block is less than the preset split data block size, it is also regarded as a split data block.

[0035] After the client divides the file to be uploaded into a starting data block and multiple split data blocks, the file to be uploaded includes multiple continuous data blocks, from which multiple data blocks located in a random data range are selected, one data block is used as a fragment, to form a fragment set, and the summary value of each fragment is calculated to form a fragment summary value set.

[0036] In the embodiment of the present application, there is no specific limitation on how to perform step S420. For example, the summary value of the file to be uploaded may be calculated first, and then the checksum of the summary value may be calculated and the checksum may be obtained by concatenating them. Accordingly, in some embodiments, the checksum of the file to be uploaded (i.e., step S420) is determined based on the size of the file to be uploaded, the preset starting data block size, the preset split data block size, the starting data block and the multiple split data blocks, and the preset checksum algorithm. Figure 5 As shown, the following steps may be included: In step S510, the number of sample data block intervals is determined according to the size of the file to be uploaded, the preset starting data block size, and the preset segmented data block size; In step S520, a plurality of sample data chunks are determined from the plurality of segmented data chunks according to the number of sample data chunk intervals; In step S530, a summary value of the file to be uploaded is determined according to the size of the file to be uploaded, the starting data block, and the plurality of sample data blocks; In step S540, a checksum of the digest value is determined according to a preset checksum algorithm; In step S550, a checksum of the file to be uploaded is determined according to the digest value and the checksum.

[0037] In the embodiment of the present application, there is no specific limitation on how to perform step S510. For example, the size of the file to be uploaded, the preset starting data block size, the preset split data block size, the number of split data blocks, the sample data size, the number of sample data blocks, and the number of sample data block intervals are represented as A, B, X, D, E, F, and G respectively. Then: the total size of multiple split data blocks is C=(AB), and the number of split data blocks D=(C / X)=((AB) / X). ​​The total size (AB) of multiple split data blocks is divided by 10 to obtain the sample data size E=(AB) / 10. The sample data size E represents the total amount of data in multiple split data blocks that participate in the summary value calculation. In order to control the amount of calculation within a limited range, when the sample data size E obtained by dividing the total size (AB) of the multiple split data blocks by 10 does not exceed the preset size (for example, 200MB), the calculated E value can be kept unchanged; when the sample data size E obtained by dividing the total size (AB) of the multiple split data blocks by 10 exceeds the preset size (for example, 200MB), the calculated E value can be assigned to the preset size (for example, 200MB). Divide the sample data size E by the preset split data block size X to obtain the number of sample data blocks F=E / X, where the number of sample data blocks F represents the total number of split data blocks participating in the summary value calculation among the multiple split data blocks, that is, F split data blocks of size X among the multiple split data blocks participate in the summary value calculation. Divide the number of sample data blocks D by the number of sample data blocks F to obtain the number of sample data block intervals G, where G represents the number of split data blocks spaced between two sample data blocks.

[0038] In the embodiment of the present application, there is no specific limitation on how to execute step S530. For example, the size of the file to be uploaded, the starting data block, and the multiple sample data blocks may be updated to the MD5 context, thereby calculating the MD5 value as the summary value of the uploaded file.

[0039] In the embodiment of the present application, there is no specific limitation on how to update multiple sample data blocks into the MD5 context. For example, the client can start a coroutine to read each sample data block and send it to a channel until multiple sample data blocks are sent, and then start another coroutine to read the sample data block from the channel and update it into the MD5 context until multiple sample data blocks are read and updated.

[0040] In the embodiment of the present application, the preset check value algorithm is not specifically limited, for example, it can be a cyclic redundancy check (CRC32) algorithm. A fixed-length hexadecimal number can be formatted, and the checksum is filled in the hexadecimal number, and the empty space is filled with 0.

[0041] In the embodiment of the present application, there is no specific limitation on how to execute step S550. For example, the checksum may be concatenated after the digest value to form a check value of a fixed length; or the checksum may be concatenated after the digest value and a fixed character string of a fixed number of bits may be padded before the digest value to form a check value of a fixed length.

[0042] The following reference Figure 6 For example, Figure 6 As shown, it is a schematic diagram of the division of the file to be uploaded provided by the embodiment of the present application. First, the starting data block is divided from the file to be uploaded according to the preset starting data block size n bytes. The starting data block is also the first fragment of the file to be uploaded (the fragment identifier can be represented by part_x, x can be an integer starting from 0, and x represents the (x+1)th fragment). Then, according to the preset split data block size m bytes, the remaining data in the file to be uploaded is divided into multiple split data blocks (the split data block identifier can be represented by block_x, x can be an integer starting from 0, and x represents the (x+1)th split data block). The first split data block is also the second fragment of the file to be uploaded. Finally, according to the sample data block interval number interval, multiple sample data blocks such as block_0 and block_n are selected from the multiple split data blocks. In addition, the fragment set v_part can also be selected and the fragment summary value set v_md5 can be calculated.

[0043] As a second aspect of the embodiment of the present application, a file uploading method is provided for use on a server, wherein: Figure 7 As shown, the method may include the following steps: In step S610, a file upload start request message sent by a client is received, and a check value and a fragment summary value set of the file to be uploaded carried therein are obtained; wherein the check value and the fragment summary value set are determined by the client according to a preset check value determination method and a random data range pre-agreed with the server; In step S620, when it is determined that a file having the verification value exists locally and the set of fragment digest values ​​determined based on the file matches the set of fragment digest values ​​carried in the file start upload request message, a complete upload notification message carrying file storage information is sent to the client; In step S630, when it is determined that the file to be uploaded is not completely uploaded, an incomplete upload notification message including an upload task identifier and a collision detection condition is sent to the client, so that the client can upload the file to be uploaded according to the upload task identifier and the collision detection condition; wherein the collision detection condition is generated by the server according to the set of fragment summary values ​​carried in the file start upload request message.

[0044] The file upload method executed by the server side has been described above when describing the file upload method executed by the client side, so it will not be repeated here.

[0045] In the file upload method provided in the embodiment of the present application, the client determines the check value and the fragment summary value set of the file to be uploaded according to a preset check value determination method and a random data range pre-agreed with the server, and sends a file start upload request message carrying the check value and the fragment summary value set to the server, which can quickly calculate the check value and the fragment summary value set used by the server to determine whether the file to be uploaded has been completely uploaded, effectively improving the file upload efficiency and avoiding waste of resources and time; subsequently, when the server determines that there is a file with the check value locally and the fragment summary value set determined based on the file matches the fragment summary value set carried in the file start upload request message, the server sends a complete upload notification message carrying file storage information to the client, so that the client can directly obtain the file storage information by parsing the complete upload notification message, without having to repeatedly upload the file to be uploaded, further avoiding waste of resources and time. When the server determines that the file to be uploaded is not completely uploaded, it sends an incomplete upload notification message including an upload task identifier and a collision detection condition to the client, so that the client can upload the file to be uploaded according to the upload task identifier and the collision detection condition; wherein the collision detection condition is generated by the server according to the set of fragment summary values ​​carried in the file start upload request message, so that the client performs collision detection according to the collision detection condition, which can further improve the efficiency and security of file uploading and avoid waste of resources and time.

[0046] In some embodiments, when it is determined that the file to be uploaded is not completely uploaded, an incomplete upload notification message including an upload task identifier and a collision detection condition (ie, involved in step S630) is sent to the client. Figure 8 As shown, the following steps may be included: In step S710, when it is determined that a file with the check value exists locally and a set of shard summary values ​​determined based on the file does not match the set of shard summary values ​​carried in the file start upload request message, and when it is determined that a file with the check value does not exist locally and an unfinished task corresponding to the check value does not exist, an upload task identifier and a collision detection condition are generated, and an incomplete upload notification message carrying the upload task identifier and the collision detection condition is sent to the client; In step S720, when it is determined that there is no file with the verification value locally but there is an unfinished task corresponding to the verification value, a collision detection condition is generated, and an incomplete upload notification message carrying the upload task identifier of the unfinished task and the collision detection condition is sent to the client.

[0047] As described above, when the server determines that there is a file with the verification value (i.e., the verification value sent by the client) locally, it further determines a set of fragment summary values ​​based on the file. Accordingly, in some embodiments, when it is determined that there is a file with the verification value locally, the method may further include the following steps: according to a random data range pre-agreed with the client, determine a set of fragments and a set of fragment summary values ​​thereof from a plurality of data blocks corresponding to the locally existing file with the verification value; wherein one fragment is one data block, and the fragment value summary corresponds one-to-one to the fragment.

[0048] The following is a detailed description of the process of the file upload method provided by the present application in conjunction with a most specific embodiment. The process of the file upload method may include the following steps: S1, the client calculates the checksum K of the file to be uploaded; Specifically, step S1 may include the following steps: the client updates the size A of the file to be uploaded into the MD5 context, ensuring that the size of the file to be uploaded participates in the calculation of the digest value of the file to be uploaded; the client divides a data block matching a preset starting data block size B (for example, 1MB) from the beginning of the file to be uploaded as the starting data block, and also updates the starting data block into the MD5 context; the size of the remaining data in the file to be uploaded is C=(AB), and the client divides the remaining data of size C according to a preset split data block size X (for example, 64KB) to obtain a number of split data blocks D; the client divides C by 10 to obtain a sample data size E; the client divides the sample data size E by the preset split data block size X to obtain a number of sample data blocks F; The client divides the number of sample data blocks F by the number of split data blocks D to obtain the number of sample data block intervals G; determines multiple sample data blocks from the multiple split data blocks according to the number of sample data block intervals G, starts a coroutine to read each sample data block and sends it to a channel channel until multiple sample data blocks are sent, starts another coroutine to read the sample data block from the channel channel and update it to the MD5 context until multiple sample data blocks are read and updated; calculates a 32-bit MD5 value for the updated MD5 context; calculates the CRC32 checksum for the 32-bit MD5 value; concatenates the CRC32 checksum after the MD5 value, and fills a fixed string of fixed bits before the MD5 value, thereby forming a checksum K of fixed length.

[0049] S2. The client selects a set of shards in a random data range from the file to be uploaded and calculates a set of shard summary values; S3: The client sends a file upload request message carrying a check value K, a shard set, and a shard summary value set to the server; S4. The server receives the file upload request message and obtains the check value K, the fragment set and the fragment summary value set carried in the message; S5, the server determines whether there is a file with the check value K (obtained in step S4) locally, if so, execute step S6, otherwise execute step S6'; S6. The server determines a set of fragments and a set of fragment summary values ​​thereof from a plurality of data blocks corresponding to the locally existing files with the check value K according to the random data range pre-agreed with the client; and proceeds to step S7. S7. The server compares the fragment summary value set determined by itself with the fragment summary value set obtained in step S4. If they match, steps S8-S9 are executed; otherwise, steps S10-S11 are executed. S8, the server sends a complete upload notification message carrying file storage information to the client; S9, the client receives the complete upload notification message sent by the server, and parses the complete upload notification message to obtain file storage information; S10, the server generates an upload task identifier and a collision detection condition, and sends an incomplete upload notification message carrying the upload task identifier and the collision detection condition to the client; S11, the client receives an incomplete upload notification message sent by the server, and uploads the file to be uploaded according to the upload task identifier and collision detection condition carried in the incomplete upload notification message; S6', the server determines whether there is an unfinished task corresponding to the check value K (obtained in step S4) locally, if yes, execute step S7', otherwise jump to the above step S10; S7', the server generates a collision detection condition, and sends an incomplete upload notification message carrying the upload task identifier of the unfinished task and the collision detection condition to the client; jump to the above step S11.

[0050] As a third aspect of the embodiments of the present application, an electronic device is provided, wherein: Fig. 9 As shown, the electronic device includes: One or more processors 101; The memory 102 stores one or more computer programs. When the one or more computer programs are executed by the one or more processors 101, the one or more processors 101 implement the file uploading method provided by the first aspect or the second aspect of the embodiment of the present application.

[0051] The electronic device may further include one or more I / O interfaces 103 connected between the processor 101 and the memory 102 and configured to implement information interaction between the processor 101 and the memory 102 .

[0052] Among them, the processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU), etc.; the memory 102 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) is connected between the processor and the memory, and can realize information exchange between the processor and the memory, including but not limited to a data bus (Bus), etc.

[0053] In some embodiments, the processor 101 , the memory 102 , and the I / O interface 103 are connected to each other via a bus 104 , and further connected to other components of the computing device.

[0054] As a fourth aspect of the embodiment of the present application, Fig.10 As shown, a computer-readable medium is provided, on which a computer program is stored, wherein when the computer program is executed by a processor, the file uploading method provided by the first aspect or the second aspect of the embodiment of the present application is implemented.

[0055] It can be understood by a person of ordinary skill in the art that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program. Accordingly, the computer program can be stored in a non-volatile computer-readable storage medium, and the computer program can implement the method of any of the above-mentioned embodiments when executed. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the embodiments of the present application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0056] The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Those skilled in the art should understand that the present application includes but is not limited to the contents described in the drawings and the above specific embodiments. Any modification that does not deviate from the functional and structural principles of the present application will be included in the scope of the claims.

Claims

1. A file uploading method, used in a client, characterized in that: The method comprises: Determine the checksum and fragment summary value set of the file to be uploaded according to the preset checksum determination method and the random data range pre-agreed with the server; Sending a file upload start request message carrying the verification value and the fragment summary value set to the server; Upon receiving the incomplete upload notification message sent by the server, uploading the file to be uploaded according to the upload task identifier and the collision detection condition carried in the incomplete upload notification message; wherein the collision detection condition is generated by the server according to the set of fragment summary values ​​carried in the file start upload request message; When receiving a complete upload notification message sent by the server, the complete upload notification message is parsed to obtain file storage information; wherein, the complete upload notification message is sent by the server when it is determined that a file with the verification value exists locally and a set of fragment summary values ​​determined based on the file matches the set of fragment summary values ​​carried in the file start upload request message.

2. The method according to claim 1, characterized in that: The uploading of the to-be-uploaded file according to the upload task identifier and the collision detection condition carried in the incomplete upload notification message includes: In the case that it is determined according to the collision detection condition that the collision detection fails, generating a file normal upload request message according to the file to be uploaded, and sending the file normal upload request message to the server; In the case where it is determined according to the collision detection condition that the collision detection passes, generating a file upload progress request message according to the upload task identifier, and sending the file upload progress request message to the server; Receive a file upload progress response message sent by the server, and upload the file to be uploaded according to the file upload progress response message.

3. The method according to claim 2, characterized in that The uploading of the file to be uploaded according to the file upload progress response message comprises: Obtain the number of uploaded bytes carried in the file upload progress response message; Upload the data in the file to be uploaded to the server from the upload start point in the file to be uploaded that matches the number of bytes uploaded.

4. The method according to claim 1, characterized in that: The method of determining the check value and the fragment summary value set of the file to be uploaded according to the preset check value determination method and the random data range pre-agreed with the server includes: Dividing the file to be uploaded into a starting data block and a plurality of split data blocks according to the size of the file to be uploaded, a preset starting data block size, and a preset split data block size; Determine the check value of the file to be uploaded according to the size of the file to be uploaded, the preset starting data block size, the preset split data block size, the starting data block and the multiple split data blocks, and a preset check value algorithm; According to the random data range pre-agreed with the server, the starting data block and multiple segmented data blocks, a shard set and a shard summary value set thereof are determined; wherein one shard is one data block, and the shard value summary corresponds one-to-one to the shard.

5. The method according to claim 4, characterized in that The step of determining the checksum of the file to be uploaded according to the size of the file to be uploaded, the preset starting data block size, the preset split data block size, the starting data block and the multiple split data blocks, and a preset checksum algorithm includes: Determine the number of sample data block intervals according to the size of the file to be uploaded, the preset starting data block size, and the preset segmented data block size; Determine a plurality of sample data chunks from the plurality of segmented data chunks according to the number of sample data chunk intervals; Determining a summary value of the file to be uploaded according to the size of the file to be uploaded, the starting data block, and the multiple sample data blocks; Determine the checksum of the summary value according to a preset check value algorithm; A checksum value of the file to be uploaded is determined based on the digest value and the checksum.

6. A file uploading method, used in a server, characterized in that: The method comprises: Receive a file upload start request message sent by a client, and obtain a check value and a fragment summary value set of the file to be uploaded carried therein; wherein the check value and the fragment summary value set are determined by the client according to a preset check value determination method and a random data range pre-agreed with the server; When it is determined that a file having the verification value exists locally and the set of fragment digest values ​​determined based on the file matches the set of fragment digest values ​​carried in the file start upload request message, sending a complete upload notification message carrying file storage information to the client; When it is determined that the file to be uploaded is not completely uploaded, an incomplete upload notification message including an upload task identifier and a collision detection condition is sent to the client, so that the client can upload the file to be uploaded according to the upload task identifier and the collision detection condition; wherein the collision detection condition is generated by the server according to the set of fragment summary values ​​carried in the file start upload request message.

7. The method according to claim 6, characterized in that When it is determined that the file to be uploaded is not completely uploaded, sending an incomplete upload notification message including an upload task identifier and a collision detection condition to the client includes: In the case where it is determined that a file with the check value exists locally and a set of shard summary values ​​determined based on the file does not match the set of shard summary values ​​carried in the file start upload request message, and in the case where it is determined that a file with the check value does not exist locally and there is no unfinished task corresponding to the check value, an upload task identifier and a collision detection condition are generated, and an incomplete upload notification message carrying the upload task identifier and the collision detection condition is sent to the client; When it is determined that there is no file with the verification value locally but there is an unfinished task corresponding to the verification value, a collision detection condition is generated, and an incomplete upload notification message carrying the upload task identifier of the unfinished task and the collision detection condition is sent to the client.

8. The method according to claim 6 or 7, characterized in that: In the case where it is determined that a file having the verification value exists locally, the method further includes: According to a random data range pre-agreed with the client, a set of shards and a set of shard summary values ​​thereof are determined from a plurality of data blocks corresponding to the locally existing files having the verification value; wherein one shard is one data block, and the shard value summary corresponds one-to-one to the shard.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A memory having one or more computer programs stored thereon, wherein when the one or more computer programs are executed by the one or more processors, the one or more processors implement the file uploading method according to any one of claims 1-8.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the file uploading method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Mail attachment processing method and mail attachment processing device

    CN103401767A

  • File transfer method, client, server and system

    CN103685332A

  • File uploading verification method and system

    CN103795765A

  • File uploading method and device and file verification method and device

    CN112532740A

  • Large file concurrent transmission method based on file stream in BS mode

    CN114039971A