File type identification method and device, storage medium and electronic equipment

By obtaining part of the data according to the file size when identifying the file type, the problem of low recognition efficiency in the prior art is solved and more efficient file type recognition is achieved.

CN120104576APending Publication Date: 2025-06-06BEIJING QINGSONG YIKANG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510284937.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

In the prior art, when using recognition tools to identify file types, it is necessary to process data of the entire file, resulting in low recognition efficiency.

Method used

When obtaining the target file, determine its file size. If the file size is greater than the preset threshold, a part of the data will be obtained from the file. The data size is less than or equal to the preset threshold, and use the recognition tool to identify it to determine the file type.

Benefits of technology

By reducing the amount of data to be identified, the efficiency of file type recognition is improved, especially in the case of large files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104576A_ABST
    Figure CN120104576A_ABST
Patent Text Reader

Abstract

The invention relates to the field of file identification, in particular to a file type identification method and device, a storage medium and electronic equipment. The method comprises the steps that when a target file is obtained, the file size of the target file is determined, and the target file is a file to be subjected to type recognition through a recognition tool; when the file size of the target file is larger than a preset threshold value, a part of data is obtained from the target file, and the data size of the obtained part of data is smaller than or equal to the preset threshold value; identifying the obtained part of data by using an identification tool to obtain a file type of the part of data; and determining the file type as the file type of the target file. The technical problem that the efficiency of recognizing the file type of the to-be-recognized file is low is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of file type identification, and in particular to a file type identification method, device, storage medium and electronic device. Background Art

[0002] In the prior art, when using a recognition tool to identify the file type of a file, the entire file to be identified is usually given to the recognition tool, and the recognition tool identifies the file type of the file to be identified. For example, when using the recognition tool Magika to identify the file type of a file, Magika processes the entire data in the file and gives a recognition result.

[0003] However, if the entire text of the document to be recognized is processed, the amount of data to be processed is large, resulting in a problem of low recognition efficiency. Summary of the invention

[0004] The present application provides a file type identification method, device, storage medium and electronic device to solve the technical problem of low efficiency in identifying the file type of a file to be identified.

[0005] In a first aspect, the present application provides a file type identification method, comprising: when a target file is acquired, determining the file size of the target file, wherein the target file is a file to be type-identified using an identification tool; when the file size of the target file is greater than a preset threshold, acquiring a portion of data from the target file, wherein the data size of the acquired portion of data is less than or equal to the preset threshold; identifying the acquired portion of data using the identification tool to obtain the file type of the portion of data; and determining the file type as the file type of the target file.

[0006] As an optional example, when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: obtaining a portion of data of a preset threshold size starting from the starting data of the target file; or, obtaining a portion of data of a preset threshold size starting from a non-starting data of the target file, wherein the end data of the obtained portion of data is located before the end data of the target file; or, obtaining the last data of the target file of a preset threshold size as the above-mentioned portion of data.

[0007] As an optional example, when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: determining the size of the preset threshold based on the file size of the target file; and obtaining a portion of data from the target file according to the size of the preset threshold.

[0008] As an optional example, when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: determining the size of the preset threshold based on the historical recognition accuracy of the recognition tool; and obtaining a portion of data from the target file according to the size of the preset threshold.

[0009] As an optional example, when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: performing a first round of recognition on the target file, wherein the first round of recognition is used to determine the file class to which the target file belongs; determining the size of the preset threshold based on the file class; and obtaining a portion of data from the target file according to the size of the preset threshold.

[0010] As an optional example, determining the size of the preset threshold based on the file class includes: determining the accuracy of the recognition tool in identifying files to be recognized of different file classes; when the accuracy is less than the accuracy threshold, increasing the size of the preset threshold until the accuracy is not less than the accuracy threshold.

[0011] As an optional example, the method further includes: obtaining data of a preset threshold size multiple times from the target file, using the data obtained each time as the part of the data to determine a file type; when the file types determined multiple times are the same, determining the determined file type as the file type of the target file.

[0012] In a second aspect, the present application provides a file type identification device, including any one of the above-mentioned file type identification methods.

[0013] In a third aspect, the present application provides an electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the memory stores a computer program, and the processor is configured to implement any one of the above-mentioned file type identification methods when executing the computer program.

[0014] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute any of the above-mentioned file type identification methods of the present application.

[0015] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the solution provided by the embodiment of the present application, by determining the file size of the above target file when the target file is obtained, wherein the above target file is a file to be identified by the identification tool; when the file size of the above target file is greater than a preset threshold, a portion of data is obtained from the above target file, wherein the data size of the obtained portion of data is less than or equal to the above preset threshold; the obtained portion of data is identified by the above identification tool to obtain the file type of the above portion of data; the above file type is determined as the file type of the above target file, so that when the file type identification tool is used to identify the file type of the file to be identified, if the file to be identified is too large, a portion of the data in the file to be identified is selected to identify the file type. The amount of data to be identified is reduced, and the efficiency of identifying the file type of the file to be identified is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0019] Figure 1 A flowchart of a file type identification method provided in an embodiment of the present application;

[0020] Figure 2 A flowchart of another file type identification method provided in an embodiment of the present application;

[0021] Figure 3 A graph showing the relationship between the recognition accuracy and the preset threshold of a file type recognition method provided in an embodiment of the present application;

[0022] Figure 4 A flowchart of another file type identification method provided in an embodiment of the present application;

[0023] Figure 5 A flowchart of another file type identification method provided in an embodiment of the present application;

[0024] Figure 6 A schematic diagram of the structure of a file type identification device provided in an embodiment of the present application;

[0025] Figure 7 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0027] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0028] In order to solve the technical problem of low efficiency in identifying the file type of a file to be identified in the prior art, the present application provides a file type identification method, which can achieve the effect of improving the efficiency of identifying the file to be identified.

[0029] Figure 1 A flowchart of a file type identification method provided in an embodiment of the present application. Figure 1 As shown, the above-mentioned file type identification method includes:

[0030] S102, when a target file is obtained, determining the file size of the target file, wherein the target file is a file to be identified by a recognition tool;

[0031] S104, when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file, wherein the data size of the obtained portion of data is less than or equal to the preset threshold;

[0032] S106, using an identification tool to identify a portion of the acquired data to obtain a file type of the portion of the data;

[0033] S108: Determine the file type as the file type of the target file.

[0034] This application can be applied in the scenario of single file recognition or batch file recognition. For the target file to be recognized, it can be a single file to be recognized, or a file in the batch files to be recognized. For the target file, the file size of the target file can be determined, and the file size of the target file can obtain the properties of the target file, and the properties of the target file include data such as the file name and size of the target file.

[0035] In this embodiment, the target file can be divided into major categories (referring to the major categories to which the file belongs, not the recognition results), such as documents, pictures, audio, video and other formats. Under the major categories of documents, pictures, audio, video and other formats, there are more detailed file types (recognition results given by the recognition tool), such as word documents in the document format, in the format of ".doc", ".docx", etc., PDF documents in the format of ".pdf", and various types of file types such as tables, presentations, rich text formats, etc. (only examples).

[0036] For the target file, after obtaining the file size of the target file, the size relationship between the target file and the preset threshold can be determined. If the file size of the target file is greater than the preset threshold, it means that the file size of the target file is large. If the file type of the file is directly identified by the recognition tool, the amount of identification data is large and time-consuming. Therefore, a portion of the data of the target file is obtained, and the data size of the portion of the data is less than the preset threshold. Then, the portion of the data is submitted to the recognition tool for recognition. The recognition tool then gives the recognition result of the file type of the portion of the data, and the recognition result is used as the file type of the target file.

[0037] The identification tool in this embodiment may be identification software, a web page, or a small program, for example, a TrlDNet tool or a Magika tool.

[0038] For example, taking the identification tool Magika as an example, for a 100MB target file, the preset threshold is 10MB, then 10MB of data can be intercepted from the 100MB target file as a new file, and the new file is given to Magika for type identification, and the type identified by Magika is used as the file type of the 100MB file.

[0039] The solution provided by the embodiment of the present application determines the file size of the target file when the target file is obtained, wherein the target file is a file to be identified by the identification tool; when the file size of the target file is greater than a preset threshold, a portion of data is obtained from the target file, wherein the data size of the obtained portion of data is less than or equal to the preset threshold; the obtained portion of data is identified by the identification tool to obtain the file type of the portion of data; the file type is determined as the file type of the target file, so that when the file type identification tool is used to identify the file type of the file to be identified, if the file to be identified is too large, a portion of the data in the file to be identified is selected to identify the file type. The amount of data to be identified is reduced, and the efficiency of identifying the file type of the file to be identified is improved.

[0040] As an alternative example, Figure 2 As shown, when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes:

[0041] S201 starts from the starting data of the target file and obtains a part of data of a preset threshold size; or, starts from a non-starting data of the target file and obtains a part of data of a preset threshold size, wherein the end data of the obtained part of data is located before the end data of the target file; or, obtains the last data of the preset threshold size of the target file as a part of data.

[0042] In this embodiment, for a target file whose file size is greater than a preset threshold, when obtaining a portion of data of a preset threshold size from the target file, it is possible to select which portion of data to obtain. For one case, data of the target file before the preset threshold size can be obtained. If the data before the preset threshold size is obtained, the idea is that the information related to the file type of the target file may exist in the previous portion of the data of the target file. Therefore, obtaining a portion of data from the beginning can effectively obtain data useful for identifying the file type. Another case is not to obtain data from the beginning of the target file, but to obtain the data of the preset threshold of the target file from a non-starting position, so as to avoid obtaining the data of the starting part of the target file. The idea is that the data in the starting part of the file may be a relatively redundant preamble, so removing this part of the data can reduce the influence of the useless part on the identification of the file type, for example, obtaining the data in the middle part of the file to identify the file type. The last idea is to obtain the data of the preset threshold size at the end of the target file. The idea of ​​obtaining the data at the end is that there is generally a summary or induction of the file at the end, so obtaining the data at the end can improve the accuracy of identifying the file type.

[0043] For example, if you intercept from the beginning, for a 5MB target file, the preset threshold is 1MB, and 1MB of data is intercepted from the beginning for type identification. If you intercept from a non-starting point, you can intercept 1MB of data starting from 2MB of the file for type identification. If you intercept from the end, for a 5MB file, the last 1MB of data is intercepted from the end.

[0044] In this embodiment, the preset threshold used above can be an empirical value, or can be determined according to other conditions. The following proposes multiple methods for determining the preset threshold, which can be used alone or in combination.

[0045] An example is that when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: determining the size of the preset threshold according to the file size of the target file; and obtaining a portion of data from the target file according to the size of the preset threshold.

[0046] In this embodiment, when determining the size of the preset threshold, the size of the preset threshold is determined according to the file size of the target file. After obtaining the target file, the size of the target file is obtained. If the size of the target file is less than a value, such as a 100kb agreed upon, if the size of the target file is less than 100kb, the preset threshold can be set to 100kb, and the preset threshold can be set to one tenth of the size of the target file. If the file size of the target file is greater than 1MB, the preset threshold will also increase as the target file increases. For example, if the target file is 100KB, the preset threshold is 10MB. In this way, for target files of 1MB and below, the preset threshold is 100KB, and if for target files above 1MB, the preset threshold is one tenth of the size of the target file. In this way, the size of the target file can be used to dynamically adjust the preset threshold. Files of different file sizes can be set with reasonable preset thresholds for type identification.

[0047] Another example is that when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: determining the size of the preset threshold based on the historical recognition accuracy of the recognition tool; and obtaining a portion of data from the target file according to the size of the preset threshold.

[0048] In this embodiment, for the recognition tool, the recognition accuracy of the historical recognition file type is recorded. If the recognition accuracy of the recognition tool is not 100%, the accuracy will be high or low as the recognition process progresses. An accuracy threshold can be set, and when the recognition accuracy of the recognition tool is greater than the accuracy threshold, the preset threshold is not adjusted. If the recognition accuracy is less than the preset threshold, as the recognition accuracy decreases, the preset threshold is increased, so as to obtain more data from the target file for file type recognition.

[0049] The relationship between the recognition accuracy and the preset threshold can be a descending function, that is, the higher the recognition accuracy, the smaller the preset threshold, and when the recognition accuracy exceeds the accuracy threshold, the preset threshold remains unchanged. In order to make the preset threshold more accurately adjusted as the recognition accuracy changes, the slope of the descending function can become smaller and smaller in absolute value as the recognition accuracy increases. In this way, when the recognition accuracy is low, the preset threshold can change more significantly. Figure 3 The following is a schematic diagram of an exemplary relationship between recognition accuracy and a preset threshold. The smaller the recognition accuracy, the larger the absolute value of the slope, which means that the change range of the preset threshold is larger.

[0050] Another example is that when the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: performing a first round of identification on the target file, wherein the first round of identification is used to determine the file class to which the target file belongs; determining the size of a preset threshold based on the file class; and obtaining a portion of data from the target file according to the size of the preset threshold.

[0051] In this embodiment, the file class can be document, picture, voice, and video, that is, the files to be identified are divided into four major categories, and the major category can be obtained according to the file header or file attribute of the target file. Then, for different major categories, when identifying the file type, that is, the specific ".pdf" and other types, different preset thresholds are set. The preset threshold for video is relatively larger, the preset threshold for voice is relatively smaller, the preset threshold for picture is relatively smaller, and the preset threshold for document is relatively the smallest. By setting different preset thresholds for different major categories, the preset thresholds can be more consistent with the types of major file categories, thereby improving recognition accuracy.

[0052] In this embodiment, in the process of determining the size of the preset threshold according to the file class, the accuracy of the recognition tool in identifying the files to be recognized of different file classes can also be determined; when the accuracy is less than the accuracy threshold, the size of the preset threshold is increased until the accuracy is not less than the accuracy threshold. In other words, for different major categories, the recognition tool has different recognition accuracy. For the change of recognition accuracy, the size of the corresponding preset threshold is adjusted under the major category. For example, for the major category of documents, the major category of documents corresponds to a preset threshold. When the recognition tool has low recognition accuracy for this major category, the preset threshold of this major category is adjusted.

[0053] For the three situations of adjusting the preset threshold mentioned above, any one of them can be adopted, or they can be shared. The shared order is to adjust the preset threshold according to the major category first, and then adjust the preset threshold according to the file size and recognition accuracy. File size and recognition accuracy are parallel, and the weighted sum of the two can be calculated to adjust the preset threshold. For example, set the initial preset threshold, and then adjust the preset threshold according to the major category. The file category multiplies the preset threshold with a smaller weight, and the video category multiplies the preset threshold with a larger weight. The order of weights is document category < picture category < voice category < video category. After the initial adjustment, the first weight for adjustment is determined according to the file size. The larger the file, the larger the weight. The second weight for adjustment is determined according to the recognition accuracy. The lower the recognition accuracy, the larger the weight. The two weights are weighted and summed, and the result is used to adjust the preset threshold after the above weight adjustment.

[0054] In the above example, by identifying partial data, the impact on recognition accuracy is small, which improves recognition efficiency. In addition to the above methods, such as Figure 4 As shown, a solution is also proposed to ensure the recognition accuracy as much as possible, including:

[0055] S402, obtaining data of a preset threshold size multiple times from the target file, using the data obtained each time as part of the data to determine a file type;

[0056] S404: When the file types determined multiple times are the same, the determined file type is determined as the file type of the target file.

[0057] That is to say, in this embodiment, in order to ensure the recognition accuracy of the target file as much as possible, different data of the target file can be obtained multiple times, and the size of the preset threshold is obtained each time, and the file type is determined by the data obtained multiple times. If the file type determined separately meets the conditions, for example, the proportion of the same file type is greater than the required proportion, it can be determined as the file type of the target file. In this way, after multiple recognitions, the accuracy of identifying the target file can be improved. If two recognitions are adopted, the data of the preset threshold size is obtained twice from different positions of the target file respectively. If 10 recognitions are adopted, the data of the preset threshold size is obtained 10 times from different positions of the target file respectively, and the type of the target file is determined according to the recognition results of two or 10 times. And the preset threshold in this embodiment can also be adjusted in the above-mentioned manner. In order to avoid obtaining data for recognition multiple times in a small file, the data of the preset threshold size can be obtained twice for recognition when the size of the target file is greater than twice the preset threshold, and so on. When the size of the target file is greater than 10 times the preset threshold, the data of the preset threshold size is obtained 10 times for recognition.

[0058] Figure 5This is a flow chart of this embodiment. Users can upload target files through the front-end page, and the Hypertext Markup Language (html) tag of the front-end page <input type="file"> Execute the operation and complete the upload of the target file by clicking on the local file. The callback parameter carries the data object file of the uploaded file. After uploading the file, the background determines whether the file size is greater than the preset threshold. The change of the preset threshold has been explained in the above case and will not be repeated here. For example, the preset threshold is 100kb. If the file size is greater than 100kb, the first 100kb of the uint8 array data of the file is intercepted. If the file size is not greater than 100kb, all the uint8 array data in the file is obtained. The obtained data is converted into a raw binary data buffer by the arrayBuffer() function, and then the Uint8Array is converted into an 8-bit unsigned integer array. The converted data is handed over to Magika's identifyBytes method for execution, and the corresponding prediction parameters are generated asynchronously. The Prediction parameter contains the parameters of the file type. If it is recognized, the parameter type of the file type will display the corresponding content. If it is not recognized, it returns unknow. So far, the file type recognition is completed. After testing, this solution can accurately return the corresponding results within a limited millisecond level. After testing, for files of hundreds of MB or GB, the recognition rate can be increased from more than 800 milliseconds or even seconds (for very large files, the memory limit may be exceeded and an error message may be reported as a result of failure) to more than 100 milliseconds.

[0059] The present application also provides a file type identification device, which can be a mobile terminal, a computer terminal, a server, etc. Figure 6 As shown, the device includes an acquisition module, an identification module and a determination module, which are used to execute the steps of the above-mentioned file type identification method.

[0060] For example, the following steps may be performed: when a target file is acquired, determining the file size of the target file, wherein the target file is a file to be type-identified using an identification tool; when the file size of the target file is greater than a preset threshold, acquiring a portion of data from the target file, wherein the data size of the acquired portion of data is less than or equal to the preset threshold; identifying the acquired portion of data using an identification tool to obtain a file type of the portion of data; and determining the file type as the file type of the target file.

[0061] The recognition module may be a recognition tool or a module that calls a recognition tool for recognition.

[0062] This application can be applied in the scenario of single file recognition or batch file recognition. For the target file to be recognized, it can be a single file to be recognized, or a file in the batch files to be recognized. For the target file, the file size of the target file can be determined, and the file size of the target file can obtain the properties of the target file, and the properties of the target file include data such as the file name and size of the target file.

[0063] In this embodiment, the target file can be divided into major categories (referring to the major categories to which the file belongs, not the recognition results), such as documents, pictures, audio, video and other formats. Under the major categories of documents, pictures, audio, video and other formats, there are more detailed file types (recognition results given by the recognition tool), such as word documents in the document format, in the format of ".doc", ".docx", etc., PDF documents in the format of ".pdf", and various types of file types such as tables, presentations, rich text formats, etc. (only examples).

[0064] For the target file, after obtaining the file size of the target file, the size relationship between the target file and the preset threshold can be determined. If the file size of the target file is greater than the preset threshold, it means that the file size of the target file is large. If the file type of the file is directly identified by the recognition tool, the amount of identification data is large and time-consuming. Therefore, a portion of the data of the target file is obtained, and the data size of the portion of the data is less than the preset threshold. Then, the portion of the data is submitted to the recognition tool for recognition. The recognition tool then gives the recognition result of the file type of the portion of the data, and the recognition result is used as the file type of the target file.

[0065] The identification tool in this embodiment may be identification software, a web page, or a small program, for example, a TrlDNet tool or a Magika tool.

[0066] For example, taking the identification tool Magika as an example, for a 100MB target file, the preset threshold is 10MB, then 10MB of data can be intercepted from the 100MB target file as a new file, and the new file is given to Magika for type identification, and the type identified by Magika is used as the file type of the 100MB file.

[0067] The solution provided by the embodiment of the present application determines the file size of the target file when the target file is obtained, wherein the target file is a file to be identified by the identification tool; when the file size of the target file is greater than a preset threshold, a portion of data is obtained from the target file, wherein the data size of the obtained portion of data is less than or equal to the preset threshold; the obtained portion of data is identified by the identification tool to obtain the file type of the portion of data; the file type is determined as the file type of the target file, so that when the file type identification tool is used to identify the file type of the file to be identified, if the file to be identified is too large, a portion of the data in the file to be identified is selected to identify the file type. The amount of data to be identified is reduced, and the efficiency of identifying the file type of the file to be identified is improved.

[0068] For other examples of this embodiment, please refer to the above examples and will not be described in detail here.

[0069] like Figure 7 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0070] Memory 113, used for storing computer programs;

[0071] In one embodiment of the present application, the processor 111 is used to implement the file type identification method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113.

[0072] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, a file type identification method as provided in any of the aforementioned method embodiments is implemented.

[0073] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0074] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0075] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive and therefore specify the presence of stated features, steps, operations, elements and / or parts, but do not exclude the presence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0076] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for identifying a file type, characterized in that: include: When a target file is obtained, determining the file size of the target file, wherein the target file is a file to be identified by a recognition tool; When the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file, wherein the data size of the obtained portion of data is less than or equal to the preset threshold; Using the identification tool to identify a portion of the acquired data to obtain a file type of the portion of the data; The file type is determined as the file type of the target file.

2. The method according to claim 1, characterized in that When the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: Starting from the starting data of the target file, a portion of data of a preset threshold size is obtained; or, Starting from a certain non-starting data of the target file, a portion of data of a preset threshold size is obtained, wherein the end data of the obtained portion of data is located before the end data of the target file; or The data of the target file having a final preset threshold size is obtained as the part of data.

3. The method according to claim 1, characterized in that When the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: Determine the size of the preset threshold according to the file size of the target file; According to the size of the preset threshold, a portion of data is obtained from the target file.

4. The method according to claim 1, characterized in that: When the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: Determining the value of the preset threshold according to the historical recognition accuracy of the recognition tool; According to the size of the preset threshold, a portion of data is obtained from the target file.

5. The method according to claim 1, characterized in that When the file size of the target file is greater than a preset threshold, obtaining a portion of data from the target file includes: Performing a first round of identification on the target file, wherein the first round of identification is used to determine the file class to which the target file belongs; Determining the size of the preset threshold according to the file type; According to the size of the preset threshold, a portion of data is obtained from the target file.

6. The method according to claim 5, characterized in that Determining the size of the preset threshold according to the file type includes: Determining the accuracy of the recognition tool in recognizing different types of files to be recognized; When the accuracy is less than the accuracy threshold, the preset threshold is increased until the accuracy is not less than the accuracy threshold.

7. The method according to claim 1, characterized in that The method further comprises: Acquire data of a preset threshold size multiple times from the target file, use the data acquired each time as the part of data, and determine a file type; When the file types determined multiple times are the same, the determined file types are determined as the file types of the target file.

8. A file type identification device, characterized in that: The method comprising any one of claims 1 to 7.

9. An electronic device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein the memory stores a computer program, and the processor implements the file type identification method described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the file type identification method according to any one of claims 1 to 7 of the present application.