File fingerprint acquisition method and device, electronic equipment and storage medium

By using a method of segmented processing and incremental calculation of file fingerprints, the problem of excessively long file fingerprint calculation time is solved, thus improving the user experience.

CN111209254BActive Publication Date: 2026-06-16OPPO CHONGQING INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
OPPO CHONGQING INTELLIGENT TECH CO LTD
Filing Date
2020-01-10
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing technologies take too long to calculate file fingerprints, resulting in excessively long waiting times for users and negatively impacting user experience.

Method used

The first hash value is calculated by obtaining the characteristic attributes of the file to be processed, the file is split into pieces, a portion of the sub-files are selected to calculate the second hash value, and incremental calculation is performed to obtain the file fingerprint.

🎯Benefits of technology

It shortens the calculation time for file fingerprints, saves the waiting time for file uploads, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111209254B_ABST
    Figure CN111209254B_ABST
Patent Text Reader

Abstract

The application discloses a file fingerprint acquisition method and device, electronic equipment and a storage medium, and relates to the technical field of electronic equipment. The method comprises the following steps: acquiring a to-be-processed file, acquiring a characteristic attribute of the to-be-processed file, calculating a hash value corresponding to the characteristic attribute as a first hash value, performing fragmentation processing on the to-be-processed file to obtain a first number of subfiles, selecting a second number of subfiles from the first number of subfiles as target subfiles, and calculating a hash value corresponding to the target subfiles as a second hash value, wherein the second number is less than the first number, incrementally calculating the first hash value and the second hash value to obtain a third hash value as a file fingerprint of the to-be-processed file. According to the application, the file fingerprint of the to-be-processed file is obtained through the characteristic attribute of the to-be-processed file and part of the subfiles of the to-be-processed file, so that the calculation time of the file fingerprint is shortened, the waiting time for file uploading is saved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic equipment technology, and more specifically, to a method, apparatus, electronic device, and storage medium for obtaining document fingerprints. Background Technology

[0002] With the development of science and technology, electronic devices are becoming increasingly widespread and multifunctional, becoming an essential part of people's daily lives. Currently, electronic devices can be used to upload files to servers. In this scenario, the electronic device can calculate the file's fingerprint for verification on the server. However, the calculation of the file fingerprint currently takes a long time, resulting in long waiting times and a poor user experience. Summary of the Invention

[0003] In view of the above problems, this application proposes a method, apparatus, electronic device and storage medium for obtaining document fingerprints to solve the above problems.

[0004] In a first aspect, embodiments of this application provide a method for obtaining a file fingerprint, the method comprising: obtaining a file to be processed; obtaining characteristic attributes of the file to be processed and calculating a hash value corresponding to the characteristic attributes as a first hash value; performing fragmentation processing on the file to be processed to obtain a first number of sub-files; selecting a second number of sub-files from the first number of sub-files as target sub-files and calculating a hash value corresponding to the target sub-files as a second hash value, wherein the second number is less than the first number; performing incremental calculation on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed.

[0005] Secondly, embodiments of this application provide a file fingerprint acquisition device, the device comprising: a file to be processed acquisition module, used to acquire a file to be processed; a first hash value acquisition module, used to acquire feature attributes of the file to be processed and calculate the hash value corresponding to the feature attributes as a first hash value; a sub-file acquisition module, used to perform fragmentation processing on the file to be processed to obtain a first number of sub-files; a second hash value acquisition module, used to select a second number of sub-files from the first number of sub-files as target sub-files and calculate the hash value corresponding to the target sub-files as a second hash value, wherein the second number is less than the first number; and a file fingerprint acquisition module, used to perform incremental calculation on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed.

[0006] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor performs the above-described method.

[0007] Fourthly, embodiments of this application provide a computer-readable storage medium storing program code, which can be invoked by a processor to execute the above-described method.

[0008] The file fingerprint acquisition method, apparatus, electronic device, and storage medium provided in this application embodiment acquire a file to be processed, acquire the characteristic attributes of the file to be processed, and calculate the hash value corresponding to the characteristic attributes as a first hash value. The file to be processed is segmented to obtain a first number of sub-files. A second number of sub-files are selected from the first number of sub-files as target sub-files, and the hash value corresponding to the target sub-files is calculated as a second hash value. The second number is less than the first number. The first hash value and the second hash value are incrementally calculated to obtain a third hash value as the file fingerprint of the file to be processed. Thus, the file fingerprint of the file to be processed is obtained through the characteristic attributes of the file to be processed and some sub-files of the file to be processed, thereby shortening the calculation time of the file fingerprint, saving the waiting time for file upload, and improving the user experience. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 A schematic diagram illustrating the application environment in which the document fingerprint acquisition method provided in the embodiments of this application can be used is shown;

[0011] Figure 2 A flowchart illustrating a document fingerprint acquisition method according to an embodiment of this application is shown;

[0012] Figure 3 A flowchart illustrating a document fingerprint acquisition method according to another embodiment of this application is shown;

[0013] Figure 4 This application shows Figure 3 The flowchart shown is a schematic diagram of step S206 of the file fingerprint acquisition method.

[0014] Figure 5 This application shows Figure 3The flowchart of step S210 of the document fingerprint acquisition method is shown;

[0015] Figure 6 This paper shows a block diagram of a document fingerprint acquisition device provided in an embodiment of this application;

[0016] Figure 7 A block diagram of an electronic device for performing a file fingerprint acquisition method according to an embodiment of this application is shown;

[0017] Figure 8 A storage unit for storing or carrying program code implementing the file fingerprint acquisition method according to an embodiment of this application is shown. Detailed Implementation

[0018] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0019] In file upload scenarios, the common approach is for the browser to read the entire file content and then calculate the corresponding file hash value. When uploading a large file, it can be divided into multiple fragments of a specified size, and each fragment is read sequentially. While reading the fragments, incremental calculation is used to calculate the hash value of the entire file. Incremental calculation allows the browser to calculate the hash value of a large file with less memory overhead, avoiding page lag or crashes caused by excessively large files. The inventors discovered that when selecting a large file, if the browser reads the entire file content and then calculates the file fingerprint, the large file size can lead to excessive memory consumption, causing page lag or even crashes. If the browser uses incremental calculation, the large file size results in a large number of fragments, making the entire calculation process time-consuming. For example, a file larger than 10GB can take several minutes to calculate before uploading to the server. Excessive calculation time reduces productivity and degrades the user experience.

[0020] To address the aforementioned problems, the inventors, through extensive research, discovered and proposed the file fingerprint acquisition method, apparatus, electronic device, and storage medium provided in the embodiments of this application. By utilizing the characteristic attributes of the file to be processed and a portion of its sub-files, the file fingerprint of the file to be processed is obtained, thereby shortening the calculation time for the file fingerprint, saving file upload waiting time, and improving user experience. The specific file fingerprint acquisition method will be described in detail in subsequent embodiments.

[0021] The following describes the application environment for the document fingerprint acquisition method provided in the embodiments of this application.

[0022] Please see Figure 1 , Figure 1 This diagram illustrates an application scenario of the document fingerprint acquisition method provided in this application. It includes an electronic device 100 and a server 200, which are communicatively connected to enable data interaction between them. For example, the electronic device 100 can send request information to the server 200, upload files to the server 200, or receive query information from the server 200, etc., without limitation. Alternatively, the electronic device 100 and the server 200 can be connected to a base station respectively to enable data interaction between them. The electronic device 100 can include smartphones, tablets, wearable electronic devices, or other electronic devices capable of installing a client (browser client). The server 200 can include traditional servers, cloud servers, etc., without limitation.

[0023] Please see Figure 2 , Figure 2 This diagram illustrates a flowchart of a file fingerprint acquisition method according to an embodiment of this application. The file fingerprint acquisition method is used to obtain the file fingerprint of a file to be processed by using its characteristic attributes and some sub-files, thereby shortening the calculation time of the file fingerprint, saving file upload waiting time, and improving user experience. In a specific embodiment, the file fingerprint acquisition method is applied to, for example... Figure 6 The document fingerprint acquisition device 300 and the electronic device 100 equipped with the document fingerprint acquisition device 300 are shown. Figure 7 The following will use an electronic device as an example to illustrate the specific process of this embodiment. Of course, it is understood that the electronic device used in this embodiment may include desktop computers, tablet computers, wearable electronic devices, etc., and is not limited thereto. The following will focus on... Figure 2 The process shown will be described in detail. The file fingerprint acquisition method may specifically include the following steps:

[0024] Step S101: Obtain the file to be processed.

[0025] In this embodiment, the electronic device can acquire files to be processed while browsing files through a browser. These files represent files to be uploaded to the server, and may include all files viewed by the electronic device through the browser, or only a portion of the files viewed by the electronic device through the browser.

[0026] In some implementations, the electronic device can automatically acquire files to be processed. When the electronic device automatically acquires files to be processed, it can do so based on the browser's browsing history or based on pre-set acquisition rules. Specifically, when the electronic device automatically acquires files based on the browser's browsing history, it can acquire the number of times each file in all browsed files has been viewed, and identify files with a viewing count greater than a specified number as files to be processed; it can acquire the browsing duration of each file in all browsed files, and identify files with a browsing duration greater than a specified duration as files to be processed; it can acquire the tagging information of each file in all browsed files, where the tagging information can be added by the user during browsing, and identify files including the tagging information as files to be processed, etc., without limitation. When the electronic device automatically acquires files to be processed based on pre-set acquisition rules, it can acquire all browsed files and identify all browsed files as files to be processed; it can acquire the browsing time of each file in all browsed files and identify files whose browsing time falls within a specified time period, etc., without limitation.

[0027] In some implementations, the electronic device can acquire a file selected by the user through the upload component as a file to be processed. When the electronic device acquires a file selected by the user through the upload component as a file to be processed, the electronic device can output all files viewed through the browser and acquire the file selected by the user from all files viewed through the upload component as a file to be processed; the electronic device can output all files within the browser and acquire the file selected by the user from all files within the browser through the upload component as a file to be processed, etc., without limitation.

[0028] Step S102: Obtain the feature attributes of the file to be processed, and calculate the hash value corresponding to the feature attributes as the first hash value.

[0029] In this embodiment, after acquiring a file to be processed, the electronic device can obtain the file's characteristic attributes and calculate the hash value corresponding to the characteristic attributes. The calculated hash value corresponding to the characteristic attributes is used as the first hash value. The characteristic attributes of the file to be processed can be used to identify the file and distinguish it from other files. In some implementations, the characteristic attributes of the file to be processed may include one or more of the following: last modification time, file size, and file type. It is understood that last modification time, file size, and file type can all be used to identify the file to be processed and distinguish it from other files.

[0030] In some implementations, the electronic device can obtain one or more combinations of the last modification time, file size, and file type of the file to be processed, and calculate the hash value corresponding to the combination of the last modification time, file size, and file type as the first hash value. For example, the electronic device can obtain the last modification time of the file to be processed and calculate the hash value corresponding to the last modification time as the first hash value; the electronic device can obtain the last modification time and file size of the file to be processed and calculate the hash value corresponding to the last modification time and file size as the first hash value, etc., without limitation.

[0031] In some implementations, electronic devices can read file information of a file to be processed using JavaScript, determine the file's characteristic attributes based on this information, and quickly obtain and calculate the hash values ​​of these attributes using JavaScript on the browser side. For example, electronic devices can read file information of a file to be processed using JavaScript and determine its last modification time, file size, file type, and other characteristic attributes based on this information.

[0032] In some implementations, the electronic device can use encryption algorithms such as SHA-x or MD5 to calculate the hash value corresponding to the characteristic attributes of the file to be processed as the first hash value.

[0033] In some implementations, the electronic device can construct a 64-bit (or even longer) code, where the first 32 bits (if MD5 encryption is used) represent the characteristic attributes of the file to be processed, and the remaining bits correspond to the content of the selected file segment, i.e., the content of the target sub-file.

[0034] Step S103: Perform fragmentation on the file to be processed to obtain a first number of sub-files.

[0035] In this embodiment, the electronic device can perform segmentation processing on the file to be processed to obtain a first number of sub-files, the specific value of which is not limited here.

[0036] In some implementations, when processing a file into segments, the electronic device can use the slice method of the browser's File class to segment the file into segments of the size determined by business requirements, thereby obtaining a first number of sub-files.

[0037] In some implementations, when performing fragmentation on a file to be processed, the electronic device can perform fragmentation based on the file size of the file to be processed to obtain a first number of sub-files. Specifically, the electronic device can obtain the file size of the file to be processed and determine the fragment size based on the file size, thereby determining the number of sub-files obtained by fragmenting the file to be processed. Wherein, when the file size of the file to be processed is large, the fragment size determined by the electronic device based on the file size of the file to be processed can be large; when the file size of the file to be processed is small, the fragment size determined by the electronic device based on the file size of the file to be processed can be small. In some implementations, if the file size of the file to be processed is A1, the fragment size of the file to be processed can be determined as B1; if the file size of the file to be processed is A2, the fragment size of the file to be processed can be determined as B2, where A1>A2 and B1>B2. For example, if the file size of the file to be processed is 500M, the fragment size of the file to be processed can be determined as 50M; if the file size of the file to be processed is 200M, the fragment size of the file to be processed can be determined as 20M.

[0038] In some implementations, when processing a file into segments, the electronic device can segment the file based on the integrity of the sub-files to obtain a first number of sub-files. For example, assuming the file to be processed includes 10 complete sub-files, and the sizes of the 10 complete sub-files are all appropriate, the file to be processed can be segmented according to the integrity of the sub-files to obtain 10 complete sub-files.

[0039] In some implementations, when processing a file into segments, the file can be evenly divided into segments to obtain a first number of sub-files. For example, assuming the file to be processed is 500MB, it can be evenly divided into 50MB segments, thus obtaining 10 sub-files of 50MB each.

[0040] In some implementations, when processing a file into segments, the file can be unevenly segmented to obtain a first number of sub-files. For example, assuming the file to be processed is 500M in size, it can be unevenly segmented into 50M, 50M, 50M, 100M, 100M, and 150M, thereby obtaining 6 sub-files.

[0041] Step S104: Select a second number of sub-files from the first number of sub-files as target sub-files, and calculate the hash value corresponding to the target sub-files as the second hash value, wherein the second number is less than the first number.

[0042] In this embodiment, after obtaining a first number of sub-files, the electronic device can select a target sub-file from the first number of sub-files. For example, it can select a second number of sub-files (less than the first number) as the target sub-files, calculate the hash value corresponding to the target sub-file, and use the calculated hash value as the second hash value. Specifically, the electronic device can use a FileReader object to select the second number of sub-files as the target sub-files from the first number of sub-files and calculate the hash value corresponding to the target sub-file as the second hash value.

[0043] In this embodiment, the electronic device can determine the number of sub-files to be selected as target sub-files from a first number of sub-files based on its remaining memory. Specifically, if the electronic device has a large amount of remaining memory, more sub-files can be selected as target sub-files from the first number of sub-files, i.e., the larger the second number, the more likely it is to be selected. Conversely, if the electronic device has a small amount of remaining memory, fewer sub-files can be selected as target sub-files from the first number of sub-files, i.e., the smaller the second number, the more likely it is to be selected.

[0044] In some implementations, the electronic device may select one sub-file from a first number of sub-files as the target sub-file. This could include selecting the first sub-file from the first number of sub-files, selecting the last sub-file from the first number of sub-files as the target sub-file, etc., without limitation.

[0045] In some implementations, the electronic device may select two sub-files as target sub-files from a first number of sub-files. Specifically, the electronic device may select the first and last sub-files from the first number of sub-files as target sub-files, select the first and second sub-files from the first number of sub-files as target sub-files, select the last sub-file and the second-to-last sub-file from the first number of sub-files as target sub-files, etc., and this is not limited to these specific implementations.

[0046] In some implementations, the electronic device may select three sub-files as target sub-files from a first number of sub-files. Specifically, the electronic device may select the first sub-file, the last sub-file, and a sub-file between the first and last sub-files from the first number of sub-files; or select the first sub-file, the second sub-file, and the third sub-file from the first number of sub-files; or select the last sub-file, the second-to-last sub-file, and the third-to-last sub-file from the first number of sub-files, etc., without limitation.

[0047] In some implementations, the electronic device can use encryption algorithms such as SHA-x or MD5 to calculate the hash value corresponding to the target sub-file as a second hash value.

[0048] Step S105: Perform incremental calculation on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed.

[0049] In some implementations, after obtaining the first hash value corresponding to the characteristic attributes of the file to be processed and the second hash value corresponding to the target sub-file, the electronic device can incrementally calculate the first hash value and the second hash value to obtain a third hash value. The calculated third hash value is used as the file fingerprint of the file to be processed, so as to uniquely identify the file to be processed with a shorter information.

[0050] One embodiment of this application provides a file fingerprint acquisition method, which involves acquiring a file to be processed, acquiring the characteristic attributes of the file to be processed, calculating the hash value corresponding to the characteristic attributes as a first hash value, performing fragment processing on the file to be processed to obtain a first number of sub-files, selecting a second number of sub-files from the first number of sub-files as target sub-files, and calculating the hash value corresponding to the target sub-files as a second hash value, wherein the second number is less than the first number, performing incremental calculation on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed. Thus, the file fingerprint of the file to be processed is obtained through the characteristic attributes of the file to be processed and some sub-files of the file to be processed, thereby shortening the calculation time of the file fingerprint, saving the waiting time for file upload, and improving the user experience.

[0051] Please see Figure 3 , Figure 3 A flowchart illustrating a document fingerprint acquisition method according to another embodiment of this application is shown. This method is applied to the aforementioned electronic device, and will be discussed below. Figure 3 The process shown will be described in detail. The file fingerprint acquisition method may specifically include the following steps:

[0052] Step S201: Obtain the file to be processed.

[0053] Step S202: Read the file information of the file to be processed using JavaScript.

[0054] Step S203: Determine the characteristic attributes of the file to be processed based on the file information, and calculate the hash value corresponding to the characteristic attributes as the first hash value.

[0055] For a detailed description of steps S201-S203, please refer to steps S101-S102, which will not be repeated here.

[0056] Step S204: Obtain the file size of the file to be processed.

[0057] In some implementations, the electronic device can obtain the file size of the file to be processed. Specifically, the electronic device can read the file information of the file to be processed using JavaScript and obtain the file size based on that information.

[0058] Step S205: When the file size is greater than the specified size, the file to be processed is split into segments to obtain the first number of sub-files.

[0059] In some implementations, the electronic device pre-sets and stores a specified size, which is used as a basis for determining the file size of the file to be processed. Therefore, in this embodiment, after obtaining the file size of the file to be processed, the file size of the file to be processed can be compared with the specified size to determine whether the file size of the file to be processed is greater than the specified size.

[0060] When the judgment result indicates that the file size of the file to be processed is greater than the specified size, it means that the file to be processed is large. If the entire content of the file to be processed is read before calculating its file fingerprint, the large size of the file will cause excessive memory consumption, leading to page lag or even crash. Therefore, the file to be processed can be segmented to obtain a first number of sub-files to avoid page lag or crash. Conversely, when the judgment result indicates that the file size of the file to be processed is not greater than the specified size, it means that the file to be processed is small. If the entire content of the file to be processed is read before calculating its file fingerprint, the large size of the file will not cause excessive memory consumption, leading to page lag or even crash. Therefore, segmenting the file to be processed is not necessary.

[0061] Step S206: Select a second number of sub-files from the first number of sub-files as target sub-files, and calculate the hash value corresponding to the target sub-files as the second hash value, wherein the second number is less than the first number.

[0062] For a detailed description of step S206, please refer to step S104, which will not be repeated here.

[0063] Please see Figure 4 , Figure 4 This application shows Figure 3 The flowchart shown illustrates step S206 of the file fingerprint acquisition method. The following will focus on... Figure 4 The process shown will be described in detail, and the method may specifically include the following steps:

[0064] Step S2061: Select the first sub-file arranged in the first number of sub-files as the target sub-file.

[0065] In some implementations, when the electronic device selects a subfile as the target subfile from a first number of subfiles, the first subfile in the first number of subfiles can be selected as the target subfile. For example, if the first number of subfiles includes a first subfile, a second subfile, a third subfile, and a fourth subfile in sequence, then the first subfile can be selected as the target subfile.

[0066] Step S2062: Select the first and last sub-files arranged in the first number of sub-files as the target sub-files.

[0067] In some implementations, when the electronic device selects two sub-files as target sub-files from a first number of sub-files, the first and last sub-files arranged in the first number of sub-files can be selected as target sub-files. For example, if the first number of sub-files includes a first sub-file, a second sub-file, a third sub-file, and a fourth sub-file in sequence, then the first sub-file and the fourth sub-file can be selected as target sub-files.

[0068] Step S2063: Select the first sub-file, the last sub-file, and any sub-file between the first and last sub-files arranged in the first number of sub-files as the target sub-file.

[0069] In some implementations, when the electronic device selects three sub-files as target sub-files from a first number of sub-files, it can select the first sub-file, the last sub-file, or any one of the first and last sub-files arranged in the first number of sub-files as target sub-files. For example, if the first number of sub-files includes a first sub-file, a second sub-file, a third sub-file, and a fourth sub-file in sequence, then the first sub-file, the second sub-file, and the fourth sub-file can be selected as target sub-files; alternatively, the first sub-file, the third sub-file, and the fourth sub-file can be selected as target sub-files.

[0070] Step S207: Perform incremental calculation on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed.

[0071] For a detailed description of step S207, please refer to step S105, which will not be repeated here.

[0072] Step S208: Send a request message carrying the file fingerprint to the server. The request message is used to request the server to query the upload information of the file to be processed based on the file fingerprint.

[0073] In this embodiment, after acquiring the file fingerprint of the file to be processed, the electronic device can send a request message carrying the file fingerprint to the server, requesting the server to query the upload information of the file to be processed based on the file fingerprint. The electronic device can send the request message carrying the file fingerprint to the server via a wireless network, a data network, etc., and this is not limited to any particular method. In some implementations, after receiving the request message, the server can respond by querying and confirming whether the file to be processed corresponding to the file fingerprint has been completely uploaded, that is, whether the file to be processed corresponding to the file fingerprint has been fully uploaded, partially uploaded, or not uploaded at all.

[0074] Step S209: Receive the query results of the upload information of the file to be processed from the server.

[0075] In some implementations, after querying the upload information of the file to be processed based on the file fingerprint and obtaining the query result, the server can send the query result back to the electronic device. Correspondingly, the electronic device can receive the query result from the server regarding the upload information of the file to be processed. As one approach, the query result may include "fully uploaded," "partially uploaded," or "not uploaded at all." Alternatively, if the server finds that the file to be processed corresponding to the file fingerprint has been fully uploaded, it may not send the query result back to the electronic device; in this case, the query result may include "partially uploaded" or "not uploaded at all." The specific method is not limited here.

[0076] Step S210: Process the file to be processed based on the query results.

[0077] In some implementations, after receiving the query result, the electronic device can process the file to be processed based on the query result.

[0078] Please see Figure 5 , Figure 5 This application shows Figure 3 The flowchart shown illustrates step S210 of the file fingerprint acquisition method. The following will focus on... Figure 5 The process shown will be described in detail, and the method may specifically include the following steps:

[0079] Step S211: When the query result indicates that the file to be processed has not been uploaded, upload the file to be processed to the server.

[0080] In some implementations, when the query result indicates that the electronic device has not uploaded the file to be processed, that is, when the query result indicates that the file to be processed has not been uploaded at all, the electronic device can upload the file to be processed to the server.

[0081] Step S212: When the query result indicates that some sub-files of the file to be processed have been uploaded, upload the other sub-files of the file to be processed, excluding the aforementioned sub-files, to the server.

[0082] In some implementations, when the query result indicates that the electronic device has already uploaded a portion of the sub-files in the file to be processed, the electronic device can upload the remaining sub-files to the server without re-uploading the entire file to be processed, thus achieving resumed and instant upload of the file to be processed. For example, assuming the file to be processed includes a first sub-file, a second sub-file, a third sub-file, and a fourth sub-file, and the query result indicates that the first and second sub-files have already been uploaded to the server, the electronic device can upload the third and fourth sub-files to the server.

[0083] Another embodiment of this application provides a file fingerprint acquisition method, which involves acquiring a file to be processed, reading the file information of the file to be processed using JavaScript, determining the characteristic attributes of the file to be processed based on the file information, calculating the hash value corresponding to the characteristic attributes as a first hash value, obtaining the file size of the file to be processed, and when the file size is greater than a specified size, performing fragment processing on the file to be processed to obtain a first number of sub-files, selecting a second number of sub-files from the first number of sub-files as target sub-files, and calculating the hash value corresponding to the target sub-files as a second hash value, wherein the second number is less than the first number, incrementally calculating the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed. A request message carrying the file fingerprint is sent to the server to request the server to query the upload information of the file to be processed based on the file fingerprint, receiving the query results of the upload information of the file to be processed from the server, and processing the file to be processed based on the query results. Compared to... Figure 2 The file fingerprint acquisition method shown in this embodiment also uses JavaScript to quickly obtain the characteristic attributes of the file to be processed, improving the speed of characteristic attribute acquisition. Furthermore, when the file size of the file to be processed exceeds a specified size, the file is segmented to improve the rationality of the segmentation. In addition, this embodiment also uploads the file fingerprint to the server to query the upload information of the file to be processed, and processes the file based on the query results returned by the server, thereby improving the efficiency of file upload verification, shortening waiting time, and enhancing user experience.

[0084] Please see Figure 6 , Figure 6 A block diagram of a document fingerprint acquisition device 300 provided in an embodiment of this application is shown. This document fingerprint acquisition device 300 is applied to the aforementioned electronic device, and will be discussed below regarding... Figure 6The block diagram shown illustrates that the file fingerprint acquisition device 300 includes: a file acquisition module 310, a first hash value acquisition module 320, a sub-file acquisition module 330, a second hash value acquisition module 340, and a file fingerprint acquisition module 350, wherein:

[0085] The file acquisition module 310 is used to acquire files to be processed.

[0086] The first hash value acquisition module 320 is used to acquire the feature attributes of the file to be processed and calculate the hash value corresponding to the feature attributes as the first hash value.

[0087] Furthermore, the first hash value acquisition module 320 includes: a file information reading submodule and a feature information determination submodule, wherein:

[0088] The file information reading submodule is used to read the file information of the file to be processed via JavaScript.

[0089] The feature information determination submodule is used to determine the feature attributes of the file to be processed based on the file information.

[0090] The sub-file acquisition module 330 is used to perform segmentation processing on the file to be processed to obtain a first number of sub-files.

[0091] Furthermore, the sub-file acquisition module 330 includes: a file size acquisition sub-module and a sub-file acquisition sub-module, wherein:

[0092] The file size acquisition submodule is used to obtain the file size of the file to be processed.

[0093] The sub-file acquisition submodule is used to perform segmentation processing on the file to be processed when the file size is greater than a specified size, so as to obtain the first number of sub-files.

[0094] The second hash value acquisition module 340 is used to select a second number of sub-files from the first number of sub-files as target sub-files, and calculate the hash value corresponding to the target sub-files as the second hash value, wherein the second number is less than the first number.

[0095] Further, the second hash value acquisition module 340 includes: a first target sub-file acquisition module, a second target sub-file acquisition module, and a third target sub-file acquisition module, wherein:

[0096] The first target sub-file acquisition module is used to select the first sub-file among the first number of sub-files as the target sub-file.

[0097] The second target sub-file acquisition module is used to select the first and last sub-files arranged in the first number of sub-files as the target sub-files.

[0098] The third target sub-file acquisition module is used to select the first sub-file, the last sub-file, and any sub-file between the first and last sub-files arranged in the first number of sub-files as the target sub-file.

[0099] The file fingerprint acquisition module 350 is used to perform incremental calculations on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed.

[0100] Furthermore, the file fingerprint acquisition device 300 also includes: a request information sending module, a query result receiving module, and a file processing module, wherein:

[0101] The request information sending module is used to send request information carrying the file fingerprint to the server. The request information is used to request the server to query the upload information of the file to be processed based on the file fingerprint.

[0102] The query result receiving module is used to receive the query results of the upload information of the file to be processed from the server.

[0103] The pending file processing module is used to process the pending file based on the query results.

[0104] Furthermore, the file processing module includes: a first upload submodule and a second upload submodule, wherein:

[0105] The first upload submodule is used to upload the file to be processed to the server when the query result indicates that the file to be processed has not been uploaded.

[0106] The second upload submodule is used to upload the remaining subfiles of the file to be processed, excluding the already uploaded subfiles, to the server when the query result indicates that a portion of the subfiles in the file to be processed have been uploaded.

[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0108] In the several embodiments provided in this application, the coupling between modules can be electrical, mechanical, or other forms of coupling.

[0109] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0110] Please see Figure 7 This diagram illustrates a structural block diagram of an electronic device 100 provided in an embodiment of this application. The electronic device 100 can be a smartphone, tablet computer, e-reader, or other electronic device capable of running applications. The electronic device 100 in this application may include one or more of the following components: a processor 110, a memory 120, a touchscreen 130, and one or more applications. The one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110. The one or more applications are configured to perform the methods described in the foregoing method embodiments.

[0111] The processor 110 may include one or more processing cores. The processor 110 connects to various parts within the electronic device 100 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 120, and by calling data stored in the memory 120. Optionally, the processor 110 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 110 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 110 and may be implemented separately using a communication chip.

[0112] The memory 120 may include random access memory (RAM) or read-only memory (ROM). The memory 120 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described below. The data storage area may also store data created by the electronic device 100 during use (such as phonebook data, audio and video data, chat log data, etc.).

[0113] Please see Figure 8 This diagram illustrates a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. The computer-readable medium 400 stores program code that can be called by a processor to execute the methods described in the above method embodiments.

[0114] The computer-readable storage medium 400 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 400 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 400 has storage space for program code 410 that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code 410 may be compressed, for example, in a suitable form.

[0115] In summary, the file fingerprint acquisition method, apparatus, electronic device, and storage medium provided in this application embodiment acquire a file to be processed, acquire the characteristic attributes of the file to be processed, calculate the hash value corresponding to the characteristic attributes as a first hash value, perform fragment processing on the file to be processed to obtain a first number of sub-files, select a second number of sub-files from the first number of sub-files as target sub-files, and calculate the hash value corresponding to the target sub-files as a second hash value, wherein the second number is less than the first number, perform incremental calculation on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed. Thus, by using the characteristic attributes of the file to be processed and some sub-files of the file to be processed, the file fingerprint of the file to be processed can be obtained, thereby shortening the calculation time of the file fingerprint, saving the waiting time for file upload, and improving the user experience.

[0116] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for obtaining a file fingerprint, characterized in that, The method includes: Get the file to be processed; Obtain the characteristic attributes of the file to be processed, and calculate the hash value corresponding to the characteristic attributes as the first hash value. The characteristic attributes include one or more of the following: last modification time, file size, and file type. The file to be processed is segmented to obtain a first number of sub-files; Select the first and last sub-files from the first number of sub-files as target sub-files, and calculate the hash value corresponding to the target sub-files as the second hash value; Incremental calculations are performed on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed.

2. The method according to claim 1, characterized in that, After incrementally calculating the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed, the method further includes: Send a request message carrying the file fingerprint to the server, the request message being used to request the server to query the upload information of the file to be processed based on the file fingerprint; Receive the query results from the server regarding the upload information of the file to be processed; The file to be processed is processed based on the query results.

3. The method according to claim 2, characterized in that, The processing of the file to be processed based on the query results includes: When the query result indicates that the file to be processed has not been uploaded, the file to be processed will be uploaded to the server. When the query result indicates that a portion of the sub-files in the file to be processed has been uploaded, the remaining sub-files in the file to be processed, excluding the aforementioned sub-files, are uploaded to the server.

4. The method according to claim 1, characterized in that, The step of segmenting the file to be processed to obtain a first number of sub-files includes: Obtain the file size of the file to be processed; When the file size is greater than the specified size, the file to be processed is split into segments to obtain the first number of sub-files.

5. The method according to any one of claims 1-3, characterized in that, The step of obtaining the characteristic attributes of the file to be processed includes: The file information of the file to be processed is read using JavaScript; The characteristic attributes of the file to be processed are determined based on the file information.

6. A document fingerprint acquisition device, characterized in that, The device includes: The module for obtaining files to be processed is used to obtain files to be processed. The first hash value acquisition module is used to acquire the characteristic attributes of the file to be processed and calculate the hash value corresponding to the characteristic attributes as the first hash value. The characteristic attributes include one or more of the following: last modification time, file size, and file type. The sub-file acquisition module is used to perform segmentation processing on the file to be processed to obtain a first number of sub-files; The second hash value acquisition module is used to select the first and last sub-files from the first number of sub-files as target sub-files, and calculate the hash value corresponding to the target sub-files as the second hash value; The file fingerprint acquisition module is used to perform incremental calculations on the first hash value and the second hash value to obtain a third hash value as the file fingerprint of the file to be processed.

7. An electronic device, characterized in that, The method includes a memory and a processor, the memory being coupled to the processor, the memory storing instructions, and the processor performing the method as described in any one of claims 1-5 when the instructions are executed by the processor.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains program code that can be invoked by a processor to execute the method as described in any one of claims 1-5.