File processing method, device, computer device and storage medium

By scanning the target file to locate resource nodes and update the link address, the problems of slow transmission and high resource occupation caused by large file size are solved, automatic compression and update are achieved, and file processing efficiency is improved.

CN115529305BActive Publication Date: 2025-08-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110711421.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-25
Publication Date
2025-08-01
Estimated Expiration
2041-06-25

AI Technical Summary

Technical Problem

With the increase in the functions of applications and mini-programs, the front-end file size becomes larger, resulting in the problems of long transmission time, high resource usage and slow loading.

Method used

By scanning the target file, locate the resource node and obtain the link address. If it is a local address, search for the original data locally and compress it, and upload it to the server to update the link address.

Benefits of technology

Reduce the volume of resource packages, improve file transfer and loading speed, save storage space and resource usage, and realize automated processing without manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115529305B_ABST
    Figure CN115529305B_ABST
Patent Text Reader

Abstract

This application relates to a file processing method, apparatus, computer device, and storage medium. The method includes: scanning a target file to locate a resource node in the target file that references a resource object; obtaining a link address associated with the resource object referenced at the resource node; if the link address is a local address, searching locally for the original data of the resource object based on the link address, and compressing the found original data to obtain compressed data; determining target data from the original data and the compressed data and uploading and storing the target data in a server to obtain a network address of the target data in the server; and updating the link address in the target file used to reference the resource object based on the network address. By using this method, the volume of the resource package can be effectively reduced, and the target data of the resource object can be read through the network address.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a file processing method, apparatus, computer device, and storage medium. Background Art

[0002] With the development of computer technology, more and more applications or applets need to be installed or used in electronic devices, and the functions of applications or applets are also increasing, which leads to an increasing volume of front-end application files. The larger the volume of the application file, the more time and resources are required for its transmission between different devices, and it is also likely to cause problems such as lag and slow loading speed during the use of the application or applet. Therefore, there is an urgent need for a way to reduce the volume of the front-end resource package to effectively reduce the volume of the resource package. Summary of the Invention

[0003] Based on this, in view of the above technical problems, it is necessary to provide a file processing method, apparatus, computer device, and storage medium that can effectively reduce the volume of the resource package.

[0004] A file processing method, the method comprising:

[0005] Scanning a target file to locate a resource node in the target file that references a resource object;

[0006] Obtaining a link address related to the resource object referenced at the resource node;

[0007] If the link address is a local address, searching locally for the original data of the resource object based on the link address, and compressing the found original data to obtain compressed data;

[0008] Determining target data from the original data and the compressed data and uploading it to a server to obtain a network address of the target data in the server;

[0009] Updating the link address used in the target file to reference the resource object based on the network address.

[0010] A file processing apparatus, the apparatus comprising:

[0011] A resource analysis module, configured to scan a target file to locate a resource node in the target file that references a resource object; and obtain a link address related to the resource object referenced at the resource node;

[0012] A processing module, configured to, if the link address is a local address, search locally for the original data of the resource object based on the link address;

[0013] A resource compression module, which is used to compress the found original data to obtain compressed data;

[0014] A resource upload module, which is used to determine target data from the original data and the compressed data and upload it to the server to obtain the network address of the target data in the server;

[0015] The processing module is further used to update the link address for referencing the resource object in the target file based on the network address.

[0016] In one embodiment, the resource analysis module is further used to obtain the scanning directory in the configuration file and the non-scanning subdirectories in the scanning directory; based on the other subdirectories in the scanning directory except the non-scanning subdirectories, scan the target file; during the process of scanning the target file, find at least one resource node in the target file that includes a referenced resource object.

[0017] In one embodiment, the number of the resource nodes is multiple, and the number of the link addresses corresponding to the resource nodes is also multiple. The processing module is further used to, for each of the multiple resource nodes, encapsulate a first task based on the corresponding link address and store the encapsulated first task in the asynchronous queue; according to the order of the multiple first tasks stored in the asynchronous queue, sequentially take out the currently to-be-processed first task from the asynchronous queue by the task processor; for each taken-out first task, parse it through the task processor, and based on the parsed link address, the resource compression module is further used to locally find the original data of the resource object based on the link address and compress the found original data to obtain compressed data.

[0018] In one embodiment, the processing module is further used to mark the status of the first task as the to-be-processed status when storing the encapsulated first task in the asynchronous queue; when the processing of the first task is completed, mark the status of the processed first task as the completed status and generate a processing result based on the counted number of tasks with the completed status; when a compression failure or upload failure occurs for the first task, re-store the corresponding first task in the asynchronous queue and mark the status of the re-stored first task as the to-be-processed status.

[0019] In one embodiment, the resource upload module is further used to, if the data volume of the compressed data is less than the data volume of the original data, use the compressed data as the target data to overwrite the original data locally and upload the target data to the server; if the data volume of the compressed data is greater than or equal to the data volume of the original data, directly upload the original data as the target data to the server.

[0020] In one embodiment, the number of the resource nodes is multiple, and the number of the link addresses corresponding to the resource nodes is also multiple. The processing module is further configured to, for each of the multiple resource nodes, encapsulate a second task based on the corresponding link address; if there is at least one link address corresponding to at least two resource nodes, merge the second tasks corresponding to the same link address to obtain a corresponding merged task; for the unmerged second tasks and the merged task, search locally for the original data corresponding to each task based on the link addresses that are different from each other among the tasks. The resource compression module is further configured to compress the found original data to obtain compressed data.

[0021] In one embodiment, the second task further includes node position information of the corresponding resource node. The processing module is further configured to, if there is at least one link address corresponding to at least two resource nodes, merge the second tasks corresponding to the same link address based on the node position information of the resource nodes corresponding to the same link address to obtain a corresponding merged task; wherein, one merged task includes one link address and node position information of at least two resource nodes corresponding to the one link address; the processing module is further configured to determine the network addresses corresponding to the multiple tasks respectively; for each task, replace the link address at the resource node specified by the node position information in the corresponding task in the target file with the network address corresponding to the corresponding task.

[0022] In one embodiment, the processing module is further configured to combine the node position information of all the resource nodes corresponding to the same link address in the multiple second tasks to form a target array; generate a merged task according to the target array and the corresponding link address.

[0023] In one embodiment, the number of the resource nodes is multiple, and the number of the link addresses corresponding to the resource nodes is also multiple; for the current resource node among the multiple resource nodes, if the link address corresponding to the current resource node is a local address and appears for the first time, the processing module is further configured to search for the original data of the resource object locally based on the link address, the resource compression module is further configured to compress the found original data to obtain compressed data, and the resource upload module is further configured to determine target data from the original data and the compressed data and upload the target data to the server to obtain the network address of the target data in the server; if the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, the processing module is further configured to directly obtain the network address corresponding to the historical resource node as the network address corresponding to the current resource node; the processing module is further configured to replace the link addresses corresponding to the respective resource nodes in the target file with the network addresses corresponding to the respective resource nodes.

[0024] In one embodiment, the processing module is further configured to obtain an updated file after completely updating the link addresses used to reference the resource object in the target file based on the network address; the resource upload module is further configured to report the updated file; the reported updated file is used to be transmitted to a specified device, so that after receiving the updated file, the specified device downloads the target data from the server based on the network address in the updated file and obtains a complete file matching the target file based on the downloaded target data.

[0025] In one embodiment, the target file includes an application program file; the resource object includes at least one of pictures, videos, audios, and documents; the resource node includes at least one of a picture node, a video node, an audio node, and a document node.

[0026] A computer device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps of the above method are implemented.

[0027] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0028] The above file processing method, device, computer equipment and storage medium scan a target file to locate a target node that references a resource object in the target file. If the link address related to the resource object referenced at the target node is a local address, the original data of the resource object can be searched for locally based on the link address, and the found original data is compressed to obtain compressed data. Then, target data is determined from the original data and the compressed data and uploaded to the server, and based on the network address of the target data in the server, the link address used to reference the resource object in the target file can be updated. In this way, by scanning the file to locate the resource node, the position of the referenced resource object can be accurately found automatically and completely, avoiding omission. Furthermore, after compressing the original data of the resource object, it is uploaded to the server, and the network address in the server is used to replace the local address, so that when the resource object needs to be used later, the target data of the resource object can be found from the network, thus saving the storage space required for local storage of the data and effectively reducing the resource packaging volume. In this way, the updated file obtained after processing the target file as described above has a smaller packaging volume, enabling faster transmission or loading and saving resource occupancy.

[0029] Moreover, in the present application, automatic analysis, compression, and link address update of the resource objects in the target file can be achieved. The entire process is automated without manual searching and processing by humans, which can not only avoid omission of resource objects but also save manpower and greatly improve file processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is an application environment diagram of the file processing method in an embodiment;

[0031] Figure 2 It is a flowchart of the file processing method in an embodiment;

[0032] Figure 3 It is a flowchart of the file processing method in another embodiment;

[0033] Figure 4 It is a schematic diagram of the state transition of the first task in an embodiment;

[0034] Figure 5 It is a flowchart of the step of searching for the original data of the resource object locally based on the link address and compressing the found original data to obtain compressed data in an embodiment;

[0035] Figure 6 It is a flowchart of the file processing method in another embodiment;

[0036] Figure 7 It is a timing diagram of the file processing method in an embodiment;

[0037] Figure 8 is a structural block diagram of a file processing device in an embodiment;

[0038] Figure 9 is a structural block diagram of a file processing device in another embodiment;

[0039] Figure 10 is an internal structure diagram of a computer device in an embodiment. Detailed implementation manners

[0040] In order to make the objectives, technical solutions, and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0041] The file processing method provided by the present application can be applied to an application environment as Figure 1 shown. Among them, the terminal 102 communicates with the server 104 through a network. Both the terminal 102 and the server 104 can be separately used to execute the file processing method, and the terminal 102 can also cooperate with the server 104 to execute the file processing method. Taking the cooperation between the terminal 102 and the server 104 to execute the file processing method as an example, the terminal 102 scans the target file 106 to locate the resource node that references the resource object 108 in the target file; obtains the link address related to the resource object 108 referenced at the resource node; if the link address is a local address, searches for the original data of the resource object locally based on the link address, and compresses the found original data to obtain compressed data; uploads the target data with a smaller data volume among the original data and the compressed data to the server 104 to obtain the network address of the target data in the server; updates the link address used to reference the resource object in the target file based on the network address.

[0042] Further, after the terminal 102 completely updates the link address used to reference the resource object in the target file based on the network address, an updated file is obtained, and the updated file is reported to the server 104. The specified device 106 can obtain the updated file from the server, download the target data from the server based on the network address in the updated file, and obtain the complete file 108 that matches the target file based on the downloaded target data.

[0043] The server 104 can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal 102 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted terminal, a smart TV, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication means, and the present application does not limit this.

[0044] It should be noted that the file processing method provided by the present application can run in computer environments such as Windows, Linux, Mac, etc. This file processing method can be parasitized on webpack as a build plugin, and the build plugin can be started by using the npm script. Among them, Webpack is a front-end resource loading / packaging tool. npm is a package management tool installed together with NodeJS. The way of starting with the npm script can be customized by the user and is not limited. The following takes the terminal as an example for illustration.

[0045] In one embodiment, as Figure 2 shown, a file processing method is provided. Taking the method applied to the Figure 1 terminal in it as an example for illustration, the method includes the following steps:

[0046] Step S202, scan the target file to locate the resource node of the resource object referenced in the target file.

[0047] Among them, the target file is the file to be processed, which can specifically be an application file, a document file, a web page file or other functional files, etc. Among them, the application file can specifically be an APP (application) or a mini program.

[0048] The resource object is a media resource that can be inserted into the target file, which can specifically be one of a picture, a video, an audio, and a document. Further, the resource object can be a static resource object. A static resource object refers to a resource object that can be directly opened by a browser. The resource node is the node where the resource object is located in the global structure of the target file, and includes at least one of a picture node, a video node, an audio node, and a document node.

[0049] Specifically, after the terminal obtains the target file to be processed, it can scan the target file. When a resource object reference is scanned in the target file, the resource node of the resource object is located. For example, when the resource object to be compressed is a picture and the target file is an XML document, the terminal scans the XML document. When a picture in the XML document is scanned, the Dom node of the picture is located, and the Dom node of the picture is the resource node in the target file. Another example is that when the resource object to be compressed is an animation and the target file is an application file, the terminal scans the application file. When the startup animation in the application file is scanned, the resource node of the startup animation is located.

[0050] It should be noted that when the terminal scans the target file and locates the resource node, the number of located resource nodes can be one or multiple. For example, when the resource object to be compressed is a picture, during the process of the terminal scanning the target file, as long as the picture Dom node is scanned, the corresponding node position information will be recorded for positioning. When there are multiple pictures in the target file, the number of corresponding located resource nodes is also multiple.

[0051] Optionally, the terminal can scan the entire target file or scan the specified sub - file in the target file. Among them, the specified sub - file can be set as needed, and the embodiments of the present application do not limit this.

[0052] In one embodiment, the terminal obtains the scanning directory configured in the configuration file and scans the target file based on the scanning directory; during the process of scanning the target file, at least one resource node including a reference resource object in the target file is found. Among them, the scanning directory refers to the directory that needs to be scanned. The scanning directory can be set according to user needs.

[0053] Step S204, obtain the link address related to the resource object referred to at the resource node.

[0054] Among them, the link address is an address that can link various network resources with different formats, different attributes, and different locations. The link address can be a local address or a network address. The local address is also the address that links to the local data of the terminal. The network address is the address that links to the data in the server.

[0055] Specifically, after the terminal locates the resource node of the resource object reference in the target file, it can obtain the meta - information related to the resource object referred to at the resource node; the meta - information includes the link address and also includes the node position information. Among them, the node position information can include the number of lines included in the node, the start position and end position of the node, the storage path of the target file where the node is located, etc.

[0056] Further, after the terminal obtains the link address related to the resource object referenced by the resource node, it can analyze that the link address is a local address or a network address. In one embodiment, the terminal matches the starting string of the link address with a preset network string. If the match is successful, it determines that the link address is a network address; if the match is unsuccessful, it determines that the link address is a local address. For example, the terminal can use the first 4 characters of the link address as the starting string, and the preset network string can be http.

[0057] Step S206, if the link address is a local address, based on the link address, search for the original data of the resource object locally, and compress the found original data to obtain compressed data.

[0058] Among them, the original data is the data corresponding to the resource object stored locally. For example, if the resource object in the XML document is a picture, and the link address of the picture is the local address ". / src / static / image / contract / detail_bg.png", then the original data of the picture in the XML document is the picture data stored at the address ". / src / static / image / contract / detail_bg.png". The compressed data is the data obtained by compressing the original data. Generally, the amount of data of the compressed data obtained by the terminal compressing the original data is less than the original data; of course, there is also a case where the amount of data of the compressed data is greater than or equal to the original data.

[0059] If the link address is a local address, it means that the resource object is linked to the original data stored locally by the terminal, and the original data stored locally needs to occupy a large storage space of the terminal. The terminal can search for the original data of the resource object locally according to the path recorded by the local address, and compress the found original data to obtain compressed data.

[0060] If the link address is a network address, the terminal does not process the resource object, obtains the next resource object in the target file, and locates the resource node in the target file that references the resource object.

[0061] Step S208, determine the target data from the original data and the compressed data and upload it to the server to obtain the network address of the target data in the server.

[0062] Among them, the target data is the data determined from the original data and the compressed data. The target data can specifically be the data that meets the preset conditions in the original data and the compressed data. The preset conditions can specifically be that the amount of data is small, or the comprehensive score of data quality and data volume is high, etc. This application does not make a limit on this.

[0063] In one embodiment, the terminal determines the target data with a smaller data volume from the original data and the compressed data and uploads it to the server. Specifically, the terminal calculates the data volume of the original data and the data volume of the compressed data, compares the data volume of the original data with that of the compressed data, takes the one with the smaller data volume as the target data, and uploads the target data to the server.

[0064] In another embodiment, the terminal determines the target data with higher quality from the original data and the compressed data and uploads it to the server. Specifically, the terminal calculates the quality of the original data and the compressed data respectively from each preset dimension, takes the one with higher quality as the target data, and uploads the target data to the server. Among them, the preset dimension can be set as needed. For example, if both the original data and the compressed data are pictures, the preset dimension can be the clarity of the picture, the brightness of the picture, the resolution of the picture, etc. If both the original data and the compressed data are videos, the preset dimension can be the clarity of the video, the smoothness of video playback, the frame rate of the video, etc.

[0065] In another embodiment, the terminal can also determine the target data from the original data and the compressed data based on the data volume and quality of the original data, and the data volume and quality of the compressed data, and upload it to the server. The terminal multiplies the data volume of the original data by a preset data volume weight, multiplies the quality of the original data by a preset quality weight, and then adds the two products to obtain the score of the original data; multiplies the data volume of the compressed data by a preset data volume weight, multiplies the quality of the compressed data by a preset quality weight, and then adds the two products to obtain the score of the compressed data; determines the target data with a higher score from the score of the original data and the score of the compressed data and uploads it to the server.

[0066] It should be noted that the method for determining the target data from the original data and the compressed data is not limited and can be set as needed.

[0067] In one of the embodiments, the server receives and stores the target data, and returns the network address of the target data in the server to the terminal. The terminal receives the network address returned by the server.

[0068] Step S210, update the link address for referencing the resource object in the target file based on the network address.

[0069] In one embodiment, the terminal replaces the local address for referencing the resource object in the target file with the network address to update the link address of the resource object. In another embodiment, the terminal adds the network address to the link address of the resource object to update the link address of the resource object.

[0070] Furthermore, the terminal can delete the original data of the resource object locally to save the storage space of the terminal local.

[0071] If the target data is compressed data, the terminal can also update the resource object referenced in the target file based on the compressed data. For example, if the resource object in the target file is a picture, the terminal compresses the original data of the picture to obtain compressed data. If the data volume of the compressed data is smaller than that of the original data, the target data is uploaded to the server to obtain the network address of the target data in the server, and the link address of the picture in the target file is updated based on the network address. Moreover, based on the compressed data, the picture in the target file is updated to the picture corresponding to the compressed data.

[0072] For example, the link address of the resource object is a local address, the original data of the resource object locally is / Users / mac / mini / ess / src / static / detail_rounder.png, and the data volume of the original data is 5.1k; after the terminal compresses the original data and updates the link address of the resource object based on the network address, the data volume of the compressed data is 4.3k, and the link address of the resource object is https:cloudcache.tencent-cloud.com / qcloud / tsign-static / detail_rounder.png.

[0073] If the target data is original data, the data content of the resource object referenced in the target file can remain unchanged.

[0074] For the above file processing method, scan the target file to locate the target node that references the resource object in the target file. If the link address related to the resource object referenced at the target node is a local address, the original data of the resource object can be found locally based on the link address, and the found original data is compressed to obtain compressed data. Then, the target data is determined from the original data and the compressed data and uploaded to the server, so that the link address used to reference the resource object in the target file can be updated based on the network address of the target data in the server. In this way, by scanning the file to locate the resource node, the position of the referenced resource object can be accurately found automatically and completely, and omission is avoided; furthermore, after the original data of the resource object is compressed and uploaded to the server, the network address in the server is used to replace the local address, so that when the resource object needs to be used subsequently, the target data of the resource object can be found from the network, thus saving the storage space required for local storage of the data and effectively reducing the resource packaging volume. In this way, the updated file obtained after processing the target file as described above has a smaller packaging volume, making it faster and more resource-saving during transmission or loading.

[0075] Moreover, in this application, it is possible to automatically analyze, compress, and update the link addresses of resource objects in the target file. The entire process is automated without the need for manual searching and processing by humans, which can not only avoid omissions of resource objects but also save manpower and greatly improve the file processing efficiency.

[0076] In one embodiment, the target file is scanned to locate the resource nodes in the target file that reference resource objects, including: obtaining the scan directories in the configuration file and the non-scanned subdirectories in the scan directories; scanning the target file based on the other subdirectories in the scan directories except the non-scanned subdirectories; and during the process of scanning the target file, finding at least one resource node in the target file that includes a reference to a resource object.

[0077] Among them, the configuration file refers to a file configured with scan information. The scan information may include directories to be scanned and directories to be excluded from scanning, or may also be file identifiers to be scanned, and is not limited thereto. The scan directory refers to the directory that needs to be scanned. The non-scanned subdirectory refers to the subdirectory in the scan directory that does not need to be scanned. Both the scan directory and the non-scanned subdirectory can be personalized according to user needs.

[0078] The scan directories in the configuration file can be represented by a first array, and each element in the first array represents a scan directory. The non-scanned subdirectories can also be represented by a second array, and each element in the second array represents a non-scanned subdirectory.

[0079] The configuration file can use a regular expression to represent the scan directories and the non-scanned subdirectories in the scan directories. A regular expression is a logical formula for string operations, that is, using some predefined specific characters and combinations of these specific characters to form a "rule string", and this "rule string" is used to express a filtering logic for strings.

[0080] In one of the embodiments, the terminal can analyze according to the rules defined by the regular expression, remove the non-scanned subdirectories from the scan directories to obtain other subdirectories, scan the files included in the other subdirectories, and during the process of scanning the target file, find at least one resource node in the target file that includes a reference to a resource object.

[0081] The terminal scans the target file in the following specific way: the terminal uses the fs module in node to read the code file of the target file into memory; uses a regular expression to match the code file in memory, and when they match, it locates to the resource node in the target file, and obtains the code line of the resource object where the resource node is located, as well as data such as meta information.

[0082] For example, if the scanned directories configured in the configuration file are the array [".src / pages / *", ".src / compontents / *"], and the non-scanned subdirectories configured are the array [".src / pages / about / *", ".src / compontents / tea-mp / *"], then the terminal scans the files in other subdirectories in the src / pages directory except the src / pages / about subdirectory, and scans the files in other subdirectories in the src / compontents directory except the src / compontents / tea-mp subdirectory.

[0083] In the above embodiment, by obtaining the scanned directories in the configuration file and the non-scanned subdirectories in the scanned directories, and combining the two strategies of forward inclusion and reverse exclusion, the files in the non-scanned subdirectories can be accurately excluded, so that the files in other subdirectories except the non-scanned subdirectories can be scanned quickly and accurately.

[0084] In one embodiment, as Figure 3 shown, the number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple. Before locally searching for the original data of the resource object based on the link address and compressing the found original data to obtain compressed data, the above method further includes:

[0085] Step S302, for each of the multiple resource nodes, encapsulate a first task based on the corresponding link address, and store the encapsulated first task in the asynchronous queue.

[0086] Among them, the first task is the task used to be stored in the asynchronous queue after encapsulation. The asynchronous queue refers to the queue for asynchronous processing of tasks. Asynchronous means that after actively requesting data, other tasks can be continued to be processed, and then wait for the notification of the completion of the IO (Input / Output) operation. After receiving the notification, then select to operate on this data.

[0087] The resource nodes and the link addresses are in one-to-one correspondence, that is, one resource corresponds to one link address.

[0088] In one of the embodiments, the terminal can obtain the link address related to the resource object referenced by the resource node, and can also obtain the node position information related to the resource object referenced by the resource node, assemble the link address and the node position information into a structured object, and then encapsulate it into a first task based on the structured object.

[0089] Step S304, according to the order of the multiple first tasks stored in the asynchronous queue, the task processor sequentially takes out the currently to-be-processed first task from the asynchronous queue.

[0090] Among them, the task processor is a module for parsing tasks.

[0091] Specifically, when the terminal receives a processing instruction for the first task in the asynchronous queue or the task processor detects that there is a task in the asynchronous queue, according to the order of the multiple first tasks stored in the asynchronous queue, the task processor takes out the currently to-be-processed first task from the asynchronous queue in the first-in-first-out order.

[0092] Step S306: For each taken-out first task, it is parsed by the task processor. Based on the parsed link address, the original data of the resource object is searched locally based on the link address, and the found original data is compressed to obtain compressed data.

[0093] Specifically, for each taken-out first task, the terminal parses it through the task processor to obtain the local address of the resource object corresponding to each first task, and then searches for the original data of the resource object based on the local path recorded in the link address, and compresses the found original data to obtain compressed data.

[0094] In the above embodiment, for each resource node among the multiple resource nodes, it is encapsulated into a first task based on the corresponding link address and stored in the asynchronous queue. Then the task processor can asynchronously process the first tasks in the asynchronous queue, which can disperse the processing pressure of the task processor.

[0095] In one embodiment, the above method further includes a step of marking the status of the first task, and this step specifically includes: when the encapsulated first task is stored in the asynchronous queue, the status of the first task is marked as the to-be-processed status; when the processing of the first task is completed, the status of the processed first task is marked as the completed status, and a processing result is generated based on the counted number of tasks with the completed status; when a compression failure or upload failure occurs for the first task, the corresponding first task is re-stored in the asynchronous queue, and the status of the re-stored first task is marked as the to-be-processed status.

[0096] Among them, the to-be-processed status is the status of not being processed. The successfully completed status is the status where the task has been processed.

[0097] Specifically, when the link address used to reference a resource object in a target file is updated based on a network address, the processing of the first task corresponding to the resource object is completed. If the status of the first task is the completed status, indicating that the first task has been processed, then the first task can be added to the completed queue, the number of tasks in the completed queue is counted, and a processing result is generated. The processing result can at least include the identifier of the first task in the completed status, the local address of the resource object processed by the completed first task, the updated network address, the data volume size of the compressed data of the resource object, the data volume size of the original data of the resource object, etc.

[0098] The situation of compression failure can be one of the following, such as unable to compress or the data volume of the compressed data being greater than or equal to the data volume of the original data. The situation of upload failure can be one of the following, such as unable to upload, unable to obtain a network address after upload, or the obtained network address being invalid after upload.

[0099] In one embodiment, when a compression failure or an upload failure occurs for the first task, the terminal can re-deposit the corresponding first task into the asynchronous queue and mark the status of the re-deposited first task as the to-be-processed status, that is, re-process the first task.

[0100] Further, if the number of times of compression failure or upload failure for the first task reaches a threshold number of times, a prompt message is generated to prompt the user to manually perform compression processing or upload processing. Among them, the threshold number of times can be set as needed.

[0101] In the above embodiment, marking the status of the first task at each stage can accurately perform corresponding processing on the first task in this status, improving the accuracy of file processing.

[0102] Figure 4 It is a schematic diagram of the status transition of the first task in one embodiment. The terminal scans the target file to locate the resource node that references the resource object in the target file, obtains the link address related to the resource object referenced at the resource node, encapsulates it into the first task based on the corresponding link address, and deposits the encapsulated first task into the asynchronous queue. Then the status of the first task is the to-be-processed status 402. When the first task is parsed by the task processor, the status of the first task is switched to the processing status 404. When the processing of the first task is completed, the status of the first task is switched to the completed status 406. When a compression failure or an upload failure occurs for the first task, the status of the first task is switched to the failure status 406. When the status of the first task is the completed status 406 or the failure status 408, the process of processing the first task can be ended.

[0103] In one embodiment, determining target data from the original data and the compressed data and uploading it to the server includes: if the data volume of the compressed data is less than that of the original data, using the compressed data as the target data to overwrite the original data locally, and uploading the target data to the server; if the data volume of the compressed data is greater than or equal to that of the original data, directly uploading the original data as the target data to the server.

[0104] Specifically, if the data volume of the compressed data is less than that of the original data, it means that the terminal has successfully compressed the original data. The terminal can then use the compressed data as the target data to overwrite the original data locally, that is, replace the original data with the compressed data, which can save the storage space of the terminal locally.

[0105] Further, if the data volume of the compressed data is less than that of the original data, the terminal can also overwrite the resource object in the target file with the compressed resource object. It can be understood that after the terminal overwrites the resource object in the target file with the compressed resource object, when the terminal subsequently loads the target file or the compressed resource object, since the data volume of the target file or the compressed resource object is smaller, the target file or the compressed resource object can be loaded more quickly.

[0106] In one of the embodiments, if the data volume of the compressed data is greater than or equal to that of the original data, the terminal can directly upload the original data as the target data to the server.

[0107] In the above embodiments, if the data volume of the compressed data is less than that of the original data, using the compressed data as the target data to overwrite the original data locally, and uploading the target data to the server; if the data volume of the compressed data is greater than or equal to that of the original data, directly uploading the original data as the target data to the server, can upload the data with the smaller data volume among the compressed data and the original data to the server, so that the resource object can be loaded more quickly subsequently.

[0108] In one embodiment, as Figure 5 shown, the number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple. Finding the original data of the resource object locally based on the link address and compressing the found original data to obtain compressed data includes:

[0109] Step S502, for each of the multiple resource nodes, encapsulating a second task based on the corresponding link address. The second task refers to the task for determining whether there is the same link address.

[0110] Step S504, if there is at least two resource nodes corresponding to the same link address, then merging the second tasks corresponding to the same link address to obtain the corresponding merged task.

[0111] The merged task refers to the task obtained by merging the second tasks corresponding to the same link address. Among them, the number of the second tasks corresponding to the same link address is at least two.

[0112] If there are at least two resource nodes corresponding to the same link address, it means that the resource objects of at least two resource nodes are all linked to the same address, and the original data of the resource objects of at least two resource nodes is the same data, then the second tasks corresponding to the same link address are merged to obtain the corresponding merged task.

[0113] Step S506, for the unmerged second tasks and the merged task, based on the mutually different link addresses between each task, locally search for the original data corresponding to each task respectively, and compress the found original data to obtain compressed data.

[0114] If the link addresses corresponding to the second task are not the same as the link addresses corresponding to other second tasks, it means that the resource object corresponding to this second task is different from the resource objects of other second tasks, and this second task does not need to be merged with other second tasks.

[0115] For the unmerged second tasks and the merged task, based on the mutually different link addresses between each task, locally search for the original data corresponding to each task respectively, and compress the found original data to obtain compressed data. Among them, the unmerged second tasks and the merged task both belong to one task.

[0116] For the merged task, locally search for the original data corresponding to this merged task, compress the found original data to obtain compressed data, and then execute uploading the target data with a smaller data volume among the original data and the compressed data to the server to obtain the network address of the target data in the server; based on the network address, update the link address used to reference the resource object in the target file, which can quickly process multiple same tasks, avoid repeatedly uploading the same target data, and can also save computer resources.

[0117] For example, both the contract details page and the receipt details page in the target file reference the picture resource object with the same link address. If the picture resource object in the contract details page is processed and the target data is finally uploaded to the server, and the picture resource object in the receipt details page is also processed and the same target data is finally uploaded to the server, then there will be a situation of uploading the same target data multiple times, resulting in a waste of resources.

[0118] In the above embodiments, if there are at least two resource nodes corresponding to the same link address, the second tasks corresponding to the same link address are merged to obtain the corresponding merged task, and then the merged task is processed, which can avoid repeated uploading of the same target data and improve the file processing efficiency.

[0119] In one embodiment, as Figure 6 shown, another file processing method is provided. The number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple. The second task further includes node position information corresponding to the resource nodes. The file processing method includes the following steps:

[0120] Step S602: Scan the target file to locate the resource nodes that reference the resource objects in the target file.

[0121] Step S604: Obtain the link address related to the resource object referenced at the resource node.

[0122] Step S606: If the link address is a local address, for each of the multiple resource nodes, a second task is encapsulated based on the corresponding link address.

[0123] Step S608: If there are at least two resource nodes corresponding to the same link address, based on the node position information of the resource nodes corresponding to the same link address, the second tasks corresponding to the same link address are merged to obtain the corresponding merged task; wherein, one merged task includes one link address and the node position information of at least two resource nodes corresponding to one link address.

[0124] The node position information is the relevant information about the location where the resource node is located. The node position information may include the number of lines included in the node, the start position and end position of the node, the storage path of the target file where the node is located, etc.

[0125] If there are at least two resource nodes corresponding to the same link address, the node position information of the resource nodes corresponding to the same link address is merged, so as to merge the second tasks corresponding to the same link address to obtain the corresponding merged task.

[0126] Specifically, the terminal combines the node position information of all the resource nodes corresponding to the same link address in the multiple second tasks to form a target array; a merged task is generated according to the target array and the corresponding link address.

[0127] Among them, an array is an ordered sequence of elements. An array is a collection used to store multiple data of the same type. The target array refers to a collection containing multiple elements representing node position information.

[0128] For example, if the two resource objects corresponding to the two second tasks correspond to the same link address, and the node position information of the resource nodes corresponding to the same link address is ". / stc / pages / contract / detail.vue" and ". / src / pages / contract / detail-demo.vue" respectively, then these two node position information are combined to form a target array [". / stc / pages / contract / detail.vue", ". / src / pages / contract / detail-demo.vue"].

[0129] Specifically, the terminal encapsulates the target array and the corresponding link address into a merging task. Further, the terminal can also encapsulate the target array, the corresponding link address, and other meta-information into a merging task. The other meta-information can include the data type of the original data of the resource object, the status of each second task, etc.

[0130] Step S610, for the unmerged second tasks and the merging task, based on the link addresses that are different from each other among the tasks, locally search for the original data corresponding to each task, and compress the found original data to obtain compressed data.

[0131] Step S612, determine the target data from the original data and the compressed data and upload it to the server to obtain the network address of the target data in the server.

[0132] Step S614, determine the network addresses corresponding to the multiple tasks.

[0133] The multiple tasks can include at least one of the unmerged second tasks and the merging task, that is, the multiple tasks can all be unmerged second tasks, can all be merging tasks, or can also include unmerged second tasks and merging tasks.

[0134] Step S616, for each task, replace the link address at the resource node specified by the node position information in the corresponding task with the network address corresponding to the corresponding task in the target file.

[0135] For the merging task, the terminal replaces the link addresses at the resource nodes respectively specified by the multiple node position information in the merging task with the network address corresponding to the merging task in the target file. For example, if the merging task is obtained by merging three second tasks corresponding to the same link address, after the terminal determines the network address corresponding to the merging task, it replaces the link addresses at the resource nodes specified by the node position information in the three second tasks with this network address.

[0136] For an unmerged second task, the terminal replaces the link address at the resource node specified by the node position information in the unmerged second task with the network address corresponding to the unmerged second task in the target file.

[0137] The terminal can also, based on the target array, replace the resource objects where each node position information in the target array is located with the compressed resource objects respectively, and replace the resource objects where each node position information in the target array is located together, improving the efficiency of file processing, and enabling the target file or the compressed resource objects to be loaded more quickly subsequently.

[0138] For the above file processing method, if there are at least two resource nodes corresponding to the same link address, then based on the node position information of the resource nodes corresponding to the same link address, the second tasks corresponding to the same link address are merged to obtain the corresponding merged task; by processing the merged task, it is possible to avoid uploading the original data of at least two resource nodes with the same link address to the server multiple times, thereby saving computer resources and improving the efficiency of file processing. Further, the node position information of all the resource nodes corresponding to the same link address in the second task can be combined to form a target array. Through the target array, the node position information of multiple resource nodes with the same link address can be accurately stored, and when replacing the local address with the network address, the node position information of the resource node can be accurately and quickly found through the target array.

[0139] In one embodiment, another file processing method is provided. The number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple; the file processing method includes: scanning the target file to locate the resource nodes in the target file that reference the resource objects; obtaining the link addresses related to the resource objects referenced at the resource nodes; for the current resource node among the multiple resource nodes, if the link address corresponding to the current resource node is a local address and appears for the first time, then search for the original data of the resource object locally based on the link address, compress the found original data to obtain compressed data, determine the target data from the original data and the compressed data and upload it to the server to obtain the network address of the target data in the server; if the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, then directly obtain the network address corresponding to the historical resource node as the network address corresponding to the current resource node; replace the link addresses corresponding to the respective resource nodes in the target file with the network addresses corresponding to the multiple resource nodes.

[0140] For the current resource node among multiple resource nodes, if the link address corresponding to the current resource node is a local address and it appears for the first time, indicating that the original data of the link address corresponding to the current resource node has not been uploaded to the server, then search for the original data of the resource object locally according to the local path recorded in the link address, and compress the found original data to obtain compressed data. Upload the target data with a smaller data volume among the original data and the compressed data to the server, obtain the network address of the target data in the server, and then replace the link address corresponding to the corresponding resource node in the target file with this network address.

[0141] If the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, indicating that the original data of the link address corresponding to the current resource node has been uploaded to the server during the processing of the historical task, then the network address corresponding to the historical resource node can be directly obtained as the network address corresponding to the current resource node, and then replace the link address corresponding to the corresponding resource node in the target file with this network address. Among them, the historical resource node refers to the resource node processed before the processing time of the current resource node.

[0142] For the above file processing method, if the link address corresponding to the current resource node is a local address and it appears for the first time, then compress the original data corresponding to the current resource node to obtain compressed data, and then determine the target data from the original data and the compressed data and upload it to the server; if the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, indicating that the original data of the link address corresponding to this resource node has been uploaded to the server, then there is no need to process this original data anymore. Directly obtain the network address corresponding to the historical resource node as the network address corresponding to the current resource node, and then replace the link address of the current resource node, which can avoid uploading the same original data to the server multiple times and improve the efficiency of file processing.

[0143] In one embodiment, the above method further includes the step of reporting the updated file, and this step specifically includes: after all the link addresses used to reference the resource object in the target file are updated based on the network address, obtain the updated file; report the updated file; the reported updated file is used to be transmitted to the specified device, so that after receiving the updated file, the specified device downloads the target data from the server based on the network address in the updated file, and obtains a complete file matching the target file based on the downloaded target data.

[0144] The updated file is obtained by completely updating the link addresses of all resource objects in the target file. Similarly, the updated file includes application files. The application file can specifically be an APP (application) or a mini-program. The updated file can also include document files, web page files, etc.

[0145] The terminal reports the updated file to the target device. The target device can be a server, a relay device, or other terminals, etc., and is not limited thereto.

[0146] After the specified device receives the updated file, it can download the corresponding target data from the server respectively from the network addresses of the various resource objects in the updated file, so as to load a complete file that matches the target file.

[0147] In the above embodiments, after completely updating the link addresses used to reference resource objects in the target file based on the network addresses, an updated file is obtained and the updated file is reported. Then the updated file can be used to be transmitted to the specified device, and a complete file that matches the target file can be loaded in the specified device, realizing that the specified device can also load the complete target file.

[0148] In a specific embodiment, another file processing method is provided, which is applied to a terminal and includes the following steps:

[0149] Step 1: Obtain the scanning directory in the configuration file and the non-scanning subdirectories in the scanning directory; based on the other subdirectories in the scanning directory except the non-scanning subdirectories, scan the target file; during the process of scanning the target file, find at least one resource node in the target file that includes a referenced resource object; the target file includes application files; the resource object includes at least one of pictures, videos, audios, and documents; the resource node includes at least one of a picture node, a video node, an audio node, and a document node.

[0150] Step 2: Obtain the link addresses related to the resource objects referenced at the resource nodes; the number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple.

[0151] Step 3: If the link address is a local address, for each of the multiple resource nodes, a task is encapsulated based on the corresponding link address and the encapsulated task is stored in the asynchronous queue, and the status of the task is marked as the to-be-processed status; the task also includes the node position information of the corresponding resource node.

[0152] Step 4: When storing the encapsulated tasks into the asynchronous queue, according to the sequence of the multiple tasks stored in the asynchronous queue, the task processor sequentially retrieves the currently pending task from the asynchronous queue; for each retrieved task, the task processor parses it to obtain the link address.

[0153] The terminal executes Step 5 to Step 7, or executes Step 8, to implement the steps of finding the original data of the resource object locally based on the link address, compressing the found original data to obtain compressed data, determining the target data from the original data and the compressed data, and uploading it to the server to obtain the network address of the target data in the server.

[0154] Step 6: If there are at least two resource nodes corresponding to the same link address, combine the node position information of all resource nodes corresponding to the same link address in the multiple tasks to form a target array; generate a merge task according to the target array and the corresponding link address; where a merge task includes a link address and the node position information of at least two resource nodes corresponding to a link address.

[0155] Step 9: For the unmerged tasks and the merge task, based on the mutually different link addresses between each task, find the original data corresponding to each task locally, and compress the found original data to obtain compressed data.

[0156] Step 10: If the data volume of the compressed data is less than the data volume of the original data, use the compressed data as the target data to overwrite the original data locally, and upload the target data to the server; if the data volume of the compressed data is greater than or equal to the data volume of the original data, directly upload the original data as the target data to the server to obtain the network address of the target data in the server.

[0157] Step 11: For the current resource node among the multiple resource nodes, if the link address corresponding to the current resource node is a local address and appears for the first time, find the original data of the resource object locally based on the link address, compress the found original data to obtain compressed data, determine the target data from the original data and the compressed data, and upload it to the server to obtain the network address of the target data in the server; if the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, directly obtain the network address corresponding to the historical resource node as the network address corresponding to the current resource node.

[0158] Step 9: Determine the network addresses corresponding to multiple tasks respectively; for each task, replace the link address at the resource node specified by the node position information in the corresponding task in the target file with the network address corresponding to the corresponding task.

[0159] Step 10: After all the link addresses for referencing resource objects in the target file are updated based on the network addresses, an updated file is obtained; report the updated file; the reported updated file is used to be transmitted to a specified device so that after receiving the updated file, the specified device downloads the target data from the server based on the network addresses in the updated file and obtains a complete file that matches the target file based on the downloaded target data.

[0160] For the above file processing method, scan the target file to locate the target nodes that reference resource objects in the target file. If the link address related to the resource object referenced at the target node is a local address, the original data of the resource object can be searched locally based on the link address, and the searched original data is compressed to obtain compressed data. Then, the target data is determined from the original data and the compressed data and uploaded to the server, so that the link addresses for referencing resource objects in the target file can be updated based on the network addresses of the target data in the server. In this way, by scanning the file to locate the resource nodes, the position of the referenced resource object can be found automatically and accurately, and omissions can be avoided; furthermore, after the original data of the resource object is compressed and uploaded to the server, the network address in the server is used to replace the local address, so that when the resource object needs to be used later, the target data of the resource object can be found from the network, thus saving the storage space required for local storage of the data and effectively reducing the resource packaging volume. In this way, the updated file obtained after processing the target file as described above has a smaller packaging volume, making it faster and more resource-saving during transmission or loading.

[0161] Moreover, in this application, automatic analysis, compression, and updating of link addresses for resource objects in the target file can be achieved. The whole process is automated without manual searching and processing by humans, which can not only avoid omissions of resource objects but also save manpower and greatly improve the file processing efficiency.

[0162] Figure 7 Is a timing diagram of the file processing method in an embodiment. Refer to Figure 7, the resource analysis module requests a configuration file from the configuration module and receives the configuration file returned by the configuration module; obtains the configuration path from the configuration file and scans the configuration path; during the process of scanning the target files in the configuration path, locates at least one resource node in the target files that includes a referenced resource object, and obtains the meta-information of the resource object where the resource node is located, and the meta-information contains the link address of the resource object; if the link address is a local address, assembles the meta-information of the resource object into a structured object; sends the structured object to the processing module.

[0163] The processing module encapsulates the structured object into a task and stores it in the asynchronous queue; the task processor included in the processing module takes out the task for parsing to obtain the link address, locates the original data of the resource object locally based on the link address, and sends the original data to the resource compression module for compression, and receives the compressed data returned by the resource compression module; the processing module determines the target data from the original data and the compressed data and sends it to the resource upload module.

[0164] The resource upload module uploads the target data to the server, receives the network address returned by the server, and sends the network address to the processing module.

[0165] The processing module receives the network address sent by the resource upload module, updates the link address of the resource object based on the network address, and marks the task status as the completed status.

[0166] This application also provides an application scenario that applies the above file processing method. Specifically, the application of the file processing method in this application scenario is as follows:

[0167] The terminal scans the applet to locate the dom node in the applet that references the startup animation; obtains the link address related to the startup animation referenced at the dom node; if the link address is a local address, locates the original data of the startup animation locally based on the link address, and compresses the found original data to obtain the compressed startup animation data; determines the target data from the original data of the startup animation and the compressed startup animation data and uploads it to the server to obtain the network address of the target data in the server; updates the link address of the startup animation in the applet based on the network address.

[0168] This application also provides another application scenario that applies the above file processing method. Specifically, the application of the file processing method in this application scenario is as follows:

[0169] The terminal scans the front-end web page to locate the DOM node that references the image in the front-end web page; obtains the link address related to the image referenced at the DOM node; if the link address is a local address, searches for the original data of the image locally based on the link address, and compresses the found original data to obtain compressed image data; determines the target data from the original data of the image and the compressed image and uploads it to the server to obtain the network address of the target data in the server; updates the link address of the image in the front-end web page based on the network address.

[0170] It should be understood that although Figure 2 , Figure 3 , Figure 5 and Figure 6 in the flowchart are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 , Figure 3 , Figure 5 and Figure 6 at least a part of the steps in

[0171] In one embodiment, as Figure 8 shown, a file processing device is provided. This device can be a software module or a hardware module, or a combination of both to become a part of a computer device. Specifically, the device includes: a resource analysis module 802, a processing module 804, a resource compression module 806, and a resource upload module 808, where:

[0172] The resource analysis module 802 is used to scan the target file to locate the resource node that references the resource object in the target file; obtain the link address related to the resource object referenced at the resource node.

[0173] The processing module 804 is used to, if the link address is a local address, search for the original data of the resource object locally based on the link address.

[0174] The resource compression module 806 is used to compress the found original data to obtain compressed data.

[0175] The resource upload module 808 is used to determine the target data from the original data and the compressed data and upload it to the server to obtain the network address of the target data in the server.

[0176] The processing module 804 is further configured to update the link address for referencing the resource object in the target file based on the network address.

[0177] The above file processing device scans the target file to locate the target node in the target file that references the resource object. If the link address related to the resource object referenced at the target node is a local address, the original data of the resource object can be found locally based on the link address, and the found original data is compressed to obtain compressed data. Then, the target data is determined from the original data and the compressed data and uploaded to the server, so that the link address for referencing the resource object in the target file can be updated based on the network address of the target data in the server. In this way, by scanning the file to locate the resource node, the position of the referenced resource object can be accurately found automatically and completely, avoiding omission. Furthermore, after compressing the original data of the resource object, it is uploaded to the server, and the network address in the server is used to replace the local address, so that when the resource object needs to be used later, the target data of the resource object can be found from the network, thus saving the storage space required for local storage of the data and effectively reducing the resource packaging volume. In this way, the updated file obtained after the above processing of the target file has a smaller packaging volume, making it faster and more resource-saving during transmission or loading.

[0178] Moreover, in the present application, automatic analysis, compression, and update of the link address of the resource object in the target file can be realized. The whole process is automatic and does not require manual search and processing by humans, which can not only avoid omission of resource objects but also save manpower and greatly improve the file processing efficiency.

[0179] In one embodiment, the above resource analysis module 802 is further configured to obtain the scan directory in the configuration file and the non-scan subdirectories in the scan directory; scan the target file based on the other subdirectories in the scan directory except the non-scan subdirectories; and during the process of scanning the target file, find at least one resource node in the target file that includes a referenced resource object.

[0180] In one embodiment, the number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple. The above processing module 804 is further configured to, for each of the multiple resource nodes, encapsulate a first task based on the corresponding link address and store the encapsulated first task in the asynchronous queue; according to the order of the multiple first tasks stored in the asynchronous queue, the task processor sequentially takes out the currently to-be-processed first task from the asynchronous queue; for each taken-out first task, the task processor parses it, and based on the parsed link address, the resource compression module 806 finds the original data of the resource object locally based on the link address and compresses the found original data to obtain compressed data.

[0181] In one embodiment, the above-mentioned processing module 804 is further configured to mark the status of the first task as a to-be-processed status when the encapsulated first task is stored in the asynchronous queue; when the processing of the first task is completed, mark the status of the processed first task as a completed status, and generate a processing result based on the counted number of tasks with a completed status; when a compression failure or upload failure occurs for the first task, re-store the corresponding first task in the asynchronous queue and mark the status of the re-stored first task as a to-be-processed status.

[0182] In one embodiment, the above-mentioned resource upload module 808 is further configured to, if the data volume of the compressed data is smaller than that of the original data, use the compressed data as the target data to overwrite the original data locally and upload the target data to the server; if the data volume of the compressed data is greater than or equal to that of the original data, directly upload the original data as the target data to the server.

[0183] In one embodiment, the number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple. The above-mentioned processing module 804 is further configured to, for each resource node among the multiple resource nodes, encapsulate a second task based on the corresponding link address; if there is at least one link address corresponding to at least two resource nodes, merge the second tasks corresponding to the same link address to obtain a corresponding merged task; for the unmerged second tasks and the merged tasks, based on the link addresses that are different from each other among the tasks, search locally for the original data corresponding to each task respectively, and the resource compression module 806 compresses the found original data to obtain compressed data.

[0184] In one embodiment, the second task further includes the node location information of the corresponding resource node. The above-mentioned processing module 804 is further configured to, if there is at least one link address corresponding to at least two resource nodes, merge the second tasks corresponding to the resource nodes with the same link address based on the node location information of the resource nodes to obtain a corresponding merged task; wherein, a merged task includes a link address and the node location information of at least two resource nodes corresponding to one link address; the above-mentioned processing module 804 is further configured to determine the network addresses corresponding to the multiple tasks respectively; for each task, replace the link address at the resource node specified by the node location information in the target file with the network address corresponding to the corresponding task.

[0185] In one embodiment, the above-mentioned processing module 804 is further configured to combine the node location information of all the resource nodes corresponding to the same link address in the multiple second tasks to form a target array; generate a merged task according to the target array and the corresponding link address.

[0186] In one embodiment, the above processing module 804 is further configured such that the number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple; for the current resource node among the multiple resource nodes, if the link address corresponding to the current resource node is a local address and appears for the first time, the above processing module 804 is further configured to search for the original data of the resource object locally based on the link address, the above resource compression module 806 is further configured to compress the found original data to obtain compressed data, and the above resource upload module 808 is further configured to determine target data from the original data and the compressed data and upload the target data to the server to obtain the network address of the target data in the server; if the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, the above processing module 804 is further configured to directly obtain the network address corresponding to the historical resource node as the network address corresponding to the current resource node; the above processing module 804 is further configured to replace the link addresses corresponding to the respective resource nodes in the target file with the network addresses corresponding to the respective resource nodes.

[0187] In one embodiment, the above processing module 804 is further configured to obtain an updated file after completely updating the link addresses used to reference resource objects in the target file based on the network addresses; the above resource upload module 808 is further configured to report the updated file; the reported updated file is used to be transmitted to a specified device, so that after receiving the updated file, the specified device downloads the target data from the server based on the network addresses in the updated file and obtains a complete file that matches the target file based on the downloaded target data.

[0188] In one embodiment, the target file includes an application program file; the resource object includes at least one of a picture, a video, an audio, and a document; the resource node includes at least one of a picture node, a video node, an audio node, and a document node.

[0189] In another embodiment, as Figure 9 shown, a file processing device is provided. The device can be a software module, a hardware module, or a combination of both to form a part of a computer device. The device specifically includes: a resource analysis module 802, a processing module 804, a resource compression module 806, a resource upload module 808, and a configuration module 810, where:

[0190] The configuration module 810 is configured to configure a scan directory and non-scan subdirectories in the scan directory to obtain a configuration file.

[0191] A resource analysis module 802 is configured to obtain a scanning directory in a configuration file and non-scanning subdirectories in the scanning directory; scan target files based on other subdirectories in the scanning directory except for the non-scanning subdirectories; during the process of scanning the target files, find at least one resource node in the target files that includes a referenced resource object; and obtain a link address related to the resource object referenced at the resource node.

[0192] A processing module 804 is configured to, if the link address is a local address, find the original data of the resource object locally based on the link address.

[0193] A resource compression module 806 is configured to compress the found original data to obtain compressed data.

[0194] A resource upload module 808 is configured to determine target data from the original data and the compressed data and upload it to a server to obtain a network address of the target data in the server.

[0195] The processing module 804 is further configured to update the link address used to reference the resource object in the target file based on the network address.

[0196] For specific limitations on the file processing device, reference may be made to the limitations on the file processing method in the foregoing text, which will not be elaborated here. Each module in the foregoing file processing device may be implemented in whole or in part by software, hardware, and their combination. The foregoing modules may be embedded in a processor in a computer device in hardware form or independent of the processor, or may be stored in a memory in the computer device in software form, so as to facilitate the processor to call and execute the operations corresponding to the foregoing modules.

[0197] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as Figure 10 shown. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner. The wireless manner may be implemented through WIFI, a carrier network, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a file processing method. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device may be a touch layer covering the display screen, or may be a button, a trackball, or a touchpad provided on the housing of the computer device, or may also be an external keyboard, a touchpad, or a mouse, etc.

[0198] Those skilled in the art can understand that Figure 10 the structure shown in Figure 10 is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0199] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.

[0200] In one embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0201] In one embodiment, a computer program product or a computer program is provided. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps in the above method embodiments.

[0202] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it may include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided in this application may include at least one of non-volatile and volatile memories. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0203] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.

[0204] The above-described embodiments merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.

Claims

1. A file processing method, characterized in that, The method includes: Scanning application files based on the scanning directory configured in the configuration file and non-scanning subdirectories in the scanning directory to locate resource nodes in the application files that reference resource objects; Obtaining a link address related to the resource object referenced at the resource node; If the link address is a local address, through task asynchronous processing and merging multiple tasks with the same link address, searching for the original data of the resource object locally based on different link addresses, and compressing the found original data to obtain compressed data; Multiplying the data volume of the original data by a first preset data volume weight, multiplying the quality of the original data by a first preset quality weight, and then adding the two products to obtain a score for the original data; Multiplying the data volume of the compressed data by a second preset data volume weight, multiplying the quality of the compressed data by a second preset quality weight, and then adding the two products to obtain a score for the compressed data; Determining target data with a higher score from the original data and the compressed data and uploading it to the server to obtain a network address of the target data in the server; Updating the link address used in the application file to reference the resource object based on the network address.

2. The method according to claim 1, wherein The scanning of the application files based on the scanning directory configured in the configuration file and non-scanning subdirectories in the scanning directory to locate resource nodes in the application files that reference resource objects includes: Obtaining the scanning directory in the configuration file and non-scanning subdirectories in the scanning directory; Scanning the application files based on other subdirectories in the scanning directory except the non-scanning subdirectories; During the process of scanning the application files, searching for at least one resource node in the application files that includes a reference to a resource object.

3. The method according to claim 1, characterized in that The number of the resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple. Before searching for the original data of the resource object locally based on different link addresses through task asynchronous processing and merging multiple tasks with the same link address, and compressing the found original data to obtain compressed data, the method further includes: For each of the multiple resource nodes, encapsulating a first task based on the corresponding link address and storing the encapsulated first task in an asynchronous queue; According to the order of the multiple first tasks stored in the asynchronous queue, sequentially taking out the currently pending first task from the asynchronous queue through a task processor; For each taken-out first task, parsing it through the task processor, and based on the parsed link address, performing searching for the original data of the resource object locally based on different link addresses, and compressing the found original data to obtain compressed data.

4. The method according to claim 3, wherein The method further includes: When storing the encapsulated first task in the asynchronous queue, marking the status of the first task as the pending status; When the processing of the first task is completed, mark the status of the completed first task as the completed status, and generate a processing result based on the counted number of tasks in the completed status; When a compression failure or upload failure occurs for the first task, re-deposit the corresponding first task into the asynchronous queue, and mark the status of the re-deposited first task as the to-be-processed status.

5. The method according to claim 1, wherein The number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple. The asynchronous processing and merging of tasks corresponding to the same link address, locally searching for the original data of the resource object based on different link addresses, and compressing the found original data to obtain compressed data, include: For each resource node among the multiple resource nodes, encapsulate a second task based on the corresponding link address; If there are at least two resource nodes corresponding to the same link address, merge the second tasks corresponding to the same link address to obtain the corresponding merged task; For the unmerged second tasks and the merged tasks, locally search for the original data corresponding to each task based on the link addresses that are different from each other among the tasks, and compress the found original data to obtain compressed data.

6. The method according to claim 5, wherein The second task further includes the node position information of the corresponding resource node. The step of, if there are at least two resource nodes corresponding to the same link address, merging the second tasks corresponding to the same link address to obtain the corresponding merged task, includes: If there are at least two resource nodes corresponding to the same link address, merge the second tasks corresponding to the same link address based on the node position information of the resource nodes corresponding to the same link address to obtain the corresponding merged task; wherein, a merged task includes a link address and the node position information of at least two resource nodes corresponding to the link address; The step of updating the link address for referencing the resource object in the application program file based on the network address includes: Determine the network addresses corresponding to the multiple tasks respectively; For each task, replace the link address at the resource node specified by the node position information in the corresponding task in the application program file with the network address corresponding to the corresponding task.

7. The method according to claim 6, characterized in that, The step of merging the second tasks corresponding to the same link address based on the node position information of the resource nodes corresponding to the same link address to obtain the corresponding merged task includes: Combine the node position information of all the resource nodes corresponding to the same link address in the multiple second tasks to form a target array; Generate a merged task according to the target array and the corresponding link address.

8. The method according to claim 1, wherein The number of resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple; If the link address is a local address, the asynchronous processing and merging of tasks corresponding to the same link address, locally searching for the original data of the resource object based on different link addresses, and compressing the found original data to obtain compressed data, include: For the current resource node among multiple resource nodes, if the link address corresponding to the current resource node is a local address and it appears for the first time, search for the original data of the resource object locally based on the link address, and compress the found original data to obtain compressed data; If the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, directly obtain the network address corresponding to the historical resource node as the network address corresponding to the current resource node; The updating the link address for referencing the resource object in the application program file based on the network address includes: Replacing the link address corresponding to the corresponding resource node in the application program file with the network addresses of the multiple resource nodes respectively.

9. The method according to claim 1, wherein The method further includes: After completely updating the link address for referencing the resource object in the application program file based on the network address, an updated file is obtained; Report the updated file; the reported updated file is used to be transmitted to a specified device, so that after receiving the updated file, the specified device downloads the target data from the server based on the network address in the updated file, and obtains a complete file matching the application program file based on the downloaded target data.

10. The method according to any one of claims 1 to 9, characterized in that, The resource object includes at least one of pictures, videos, audios, and documents; the resource node includes at least one of a picture node, a video node, an audio node, and a document node.

11. A file processing device, characterized in that, The apparatus includes: A resource analysis module, configured to scan the application program file based on the scan directory configured in the configuration file and the non-scanned subdirectories in the scan directory to locate the resource nodes that reference the resource object in the application program file; obtain the link address related to the resource object referenced at the resource node; A processing module, configured to, if the link address is a local address, asynchronously process tasks and merge multiple tasks with the same link address through tasks, and search for the original data of the resource object locally based on different link addresses; A resource compression module, configured to compress the found original data to obtain compressed data; A scoring module, configured to multiply the data volume of the original data by a first preset data volume weight, multiply the quality of the original data by a first preset quality weight, and then add the two products to obtain the score of the original data; multiply the data volume of the compressed data by a second preset data volume weight, multiply the quality of the compressed data by a second preset quality weight, and then add the two products to obtain the score of the compressed data; A resource upload module, configured to determine the target data with a higher score from the original data and the compressed data and upload it to the server to obtain the network address of the target data in the server; The processing module is further configured to update the link address for referencing the resource object in the application program file based on the network address.

12. The device according to claim 11, characterized in that, The resource analysis module is further configured to obtain the scanning directory in the configuration file and the non-scanning subdirectories in the scanning directory; scan the application program files based on the other subdirectories in the scanning directory except the non-scanning subdirectories; and during the process of scanning the application program files, find at least one resource node in the application program files that includes a referenced resource object.

13. The device according to claim 11, characterized in that, The number of the resource nodes is multiple, and the number of the link addresses corresponding to the resource nodes is also multiple. The processing module is further configured to, for each of the multiple resource nodes, encapsulate a first task based on the corresponding link address, and store the encapsulated first task into the asynchronous queue. According to the sequence of the multiple first tasks stored in the asynchronous queue, the task processor sequentially takes out the currently to-be-processed first task from the asynchronous queue; for each taken-out first task, the task processor parses it. Based on the parsed link address, the resource compression module is further configured to locally find the original data of the resource object based on different link addresses, and compress the found original data to obtain compressed data.

14. The device according to claim 13, wherein, The processing module is further configured to, when storing the encapsulated first task into the asynchronous queue, mark the status of the first task as the to-be-processed status; when the processing of the first task is completed, mark the status of the processed first task as the completed status, and generate a processing result based on the counted number of tasks with the completed status. When a compression failure or an upload failure occurs for the first task, the corresponding first task is re-stored into the asynchronous queue, and the status of the re-stored first task is marked as the to-be-processed status.

15. The device according to claim 11, characterized in that, The number of the resource nodes is multiple, and the number of the link addresses corresponding to the resource nodes is also multiple. The processing module is further configured to, for each of the multiple resource nodes, encapsulate a second task based on the corresponding link address; if there are at least two resource nodes corresponding to the same link address, merge the second tasks corresponding to the same link address to obtain a corresponding merged task; for the unmerged second tasks and the merged task, locally find the original data corresponding to each task based on the link addresses that are different from each other among the tasks, and the resource compression module is further configured to compress the found original data to obtain compressed data.

16. The device according to claim 15, characterized in that, The second task further includes node location information of corresponding resource nodes. The processing module is further configured to, if there are at least two resource nodes corresponding to the same link address, merge the second tasks corresponding to the same link address based on the node location information of the resource nodes corresponding to the same link address, to obtain a corresponding merged task; wherein, a merged task includes a link address and node location information of at least two resource nodes corresponding to the one link address; the processing module is further configured to determine network addresses corresponding to multiple tasks respectively; for each task, the network address corresponding to the corresponding task is used to replace the link address at the resource node specified by the node location information in the application program file.

17. The device according to claim 16, characterized in that, The processing module is further configured to combine the node location information of all resource nodes corresponding to the same link address in multiple second tasks to form a target array; and generate a merged task according to the target array and the corresponding link address.

18. The device according to claim 11, wherein The number of the resource nodes is multiple, and the number of link addresses corresponding to the resource nodes is also multiple; for the current resource node among the multiple resource nodes, if the link address corresponding to the current resource node is a local address and appears for the first time, the processing module is further configured to search for the original data of the resource object locally based on the link address, and the resource compression module is further configured to compress the found original data to obtain compressed data; If the link address corresponding to the current resource node is a local address and points to the same original data as the link address of the historical resource node processed before the current resource node, the processing module is further configured to directly obtain the network address corresponding to the historical resource node as the network address corresponding to the current resource node; the processing module is further configured to use the network addresses corresponding to the multiple resource nodes respectively to replace the link addresses corresponding to the respective resource nodes in the application program file.

19. The device according to claim 11, characterized in that, The processing module is further configured to obtain an updated file after all link addresses for referencing the resource object in the application program file are updated based on the network address; the resource upload module is further configured to report the updated file; the reported updated file is used to be transmitted to a specified device, so that after receiving the updated file, the specified device downloads target data from the server based on the network address in the updated file, and obtains a complete file matching the application program file based on the downloaded target data.

20. The device according to any one of claims 11 to 19, characterized in that The resource object includes at least one of pictures, videos, audios, and documents; the resource node includes at least one of a picture node, a video node, an audio node, and a document node.

21. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the method according to any one of claims 1 to 10 is implemented.

22. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1 to 10 is implemented.

23. A computer program product comprising computer instructions, characterized in that, When the computer instruction is executed by the processor, the method according to any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Webpage resource bundle uploading method and device

    CN105530297A

  • Method and system for documentation generation

    CN1959680A