Compressed package file processing method, device and system and electronic equipment
By converting compressed file data into editable binary and displaying it as string text in the browser, the problems of low efficiency and high server cost in the existing technology are solved, and efficient data processing and cost savings are achieved.
Patent Information
- Application Number
- CN202410243963.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-04
- Publication Date
- 2025-09-05
AI Technical Summary
The existing technology requires downloading and decompressing the remote compressed package locally when accessing it, which is inefficient and takes up local disk space. At the same time, it relies on the back-end server, resulting in high server costs.
In the browser, the file data of the compressed package is converted into editable binary data, and then into string data. The parsing and display are completed through the processing power of the browser, reducing dependence on the server.
It improves the data processing efficiency of compressed files, saves server costs and reduces the usage of local disk space.
Smart Images

Figure CN120596449A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer communication technology, and in particular to a method, device, system and electronic device for processing compressed files. Background Art
[0002] A compression package is a computer application that reduces the number of bits and bytes in a file, saving disk space and other functions. In many cases, people need to access text files stored in a remote compressed package, but are typically limited to downloading the entire package locally and then decompressing it to their local disk to view and edit the contents. However, this conventional decompression method consumes local disk space and requires the installation of a tool to decompress the compressed package file. This method is particularly inefficient and requires significant storage space when temporarily viewing the contents of a compressed package containing a large number of log files.
[0003] At present, the existing technical solution is to decompress the compressed package only in a dedicated cloud server through server programs such as node / java, and then transmit the data in the compressed package to the user client through HTTP and other methods. Although this technical solution can realize online viewing of the compressed package, it relies on the back-end server, which puts a lot of pressure on the server and consumes a high cost. Summary of the Invention
[0004] The embodiments of the present application provide a method, device, system and electronic device for processing files of a compressed package. By converting the file data in the compressed package into editable binary data in a browser, and then converting the editable binary data into string data, editable string text is obtained. The present application can improve the data processing efficiency of compressed package files and save server costs.
[0005] The embodiments of this application provide the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a method for processing a compressed file, which is applied to a browser. The method for processing a compressed file includes:
[0007] Obtaining a link to a compressed package, wherein the compressed package includes at least one file data;
[0008] Get the file data in the compressed package according to the link of the compressed package;
[0009] Convert file data into read-only binary data;
[0010] By calling the browser's text reading interface, the read-only binary data is converted into editable binary data;
[0011] Parsing the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data;
[0012] Obtaining a first user instruction, wherein the first user instruction includes a location of file data in a file directory tree, and the first user instruction corresponds to an editable binary data;
[0013] Converting the editable binary data corresponding to the first user instruction into character string data;
[0014] By calling the browser's editor, an editable string text is obtained according to the string data.
[0015] In some embodiments, obtaining file data in a compressed package according to a link of the compressed package includes:
[0016] Send a network request to the server based on the link of the compressed package;
[0017] Receive the network response returned by the server and obtain the compressed package file data based on the network response.
[0018] In some embodiments, the editable binary data is parsed to obtain a file directory tree of the compressed package, including:
[0019] Use a third-party library to parse editable binary data and obtain the file directory in the compressed package;
[0020] According to the file directory, get the directory structure of the compressed package;
[0021] According to the directory structure of the compressed package, the file directory tree of the compressed package is obtained.
[0022] In some embodiments, the method further comprises:
[0023] Obtaining a second user instruction;
[0024] According to a second user instruction, the editable string text is converted into binary text;
[0025] Generate a download link for the binary text and download the binary text to a local computer according to the download link.
[0026] In some embodiments, the file data includes an image file, and the method further includes:
[0027] Get the image tag in the editable binary data;
[0028] According to the image tag, set the path of the resource file to the editable binary data corresponding to the image file;
[0029] Get the image corresponding to the image file according to the editable binary data corresponding to the image file.
[0030] In some embodiments, converting the editable binary data corresponding to the first user instruction into string data includes:
[0031] converting the editable binary data corresponding to the first user instruction into uncompressed editable binary data;
[0032] Encodes uncompressed editable binary data into string data.
[0033] In a second aspect, an embodiment of the present application provides a compressed package file processing device, the compressed package file processing device comprising:
[0034] A data acquisition module is used to obtain a link to a compressed package, wherein the compressed package includes at least one file data; and obtain the file data in the compressed package according to the link to the compressed package;
[0035] The data conversion module is used to convert file data into read-only binary data; by calling the text reading interface of the browser, the read-only binary data is converted into editable binary data;
[0036] A data parsing module, configured to parse the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data;
[0037] An instruction execution module is used to obtain a first user instruction, wherein the first user instruction includes the location of file data in a file directory tree, and the first user instruction corresponds to an editable binary data; convert the editable binary data corresponding to the first user instruction into string data; and obtain an editable string text based on the string data by calling a browser editor.
[0038] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0039] at least one processor; and
[0040] a memory communicatively connected to at least one processor; wherein,
[0041] The memory stores instructions that can be executed by at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the file processing method of the compressed package according to the first aspect.
[0042] In a fourth aspect, an embodiment of the present application provides a compressed file processing system, the system comprising:
[0043] The electronic device according to the third aspect is configured to obtain a log directory and package the log directory into a compressed package;
[0044] The server is communicatively connected to the electronic device and is used to obtain the compressed package sent by the electronic device.
[0045] In a fifth aspect, an embodiment of the present application provides a non-volatile computer-readable storage medium, which stores computer-executable instructions. The computer-executable instructions are used to enable an electronic device to execute the file processing method of the compressed package as in the first aspect.
[0046] The beneficial effects of the embodiments of the present application are as follows: different from the prior art, the embodiments of the present application provide a file processing method for a compressed package, which is applied to a browser. The file processing method for a compressed package includes: obtaining a link to a compressed package, wherein the compressed package includes at least one file data; obtaining the file data in the compressed package according to the link to the compressed package; converting the file data into read-only binary data; converting the read-only binary data into editable binary data by calling the text reading interface of the browser; parsing the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data; obtaining a first user instruction, wherein the first user instruction includes the position of the file data in the file directory tree, and the first user instruction corresponds to an editable binary data; converting the editable binary data corresponding to the first user instruction into character string data; obtaining an editable character string text according to the character string data by calling the editor of the browser.
[0047] By converting the file data in the compressed package into editable binary data in the browser, and then converting the editable binary data into string data to obtain editable string text, this application can improve the data processing efficiency of the compressed package file and save server costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] One or more embodiments are exemplarily illustrated by corresponding drawings, which do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings are represented as similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0049] Figure 1 is a schematic diagram of an application environment provided by an embodiment of the present application;
[0050] Figure 2 This is a schematic diagram of a local processing compressed package provided by an embodiment of the present application;
[0051] Figure 3 This is a flowchart of a method for processing compressed files provided in an embodiment of the present application;
[0052] Figure 4 yes Figure 3 A detailed flow chart of step S302 in FIG.
[0053] Figure 5 yes Figure 3 Detailed flow diagram of step S305 in FIG.
[0054] Figure 6 yes Figure 3 Detailed flow chart of step S307 in FIG.
[0055] Figure 7 This is a flowchart of downloading binary text to a local computer, as provided in an embodiment of the present application;
[0056] Figure 8 This is a schematic diagram of a process for obtaining an image corresponding to an image file provided by an embodiment of the present application;
[0057] Figure 9 This is a schematic diagram of the overall process of a compressed file processing method provided by an embodiment of the present application;
[0058] Figure 10 This is a schematic diagram of the structure of a compressed file processing device provided in an embodiment of the present application;
[0059] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0060] Figure 12 It is a structural diagram of a compressed package file processing system provided in an embodiment of the present application.
[0061] Description of Figure Numbers:
[0062] Label name Label name 100 Application Environment 1102 Data conversion module 10 electronic devices 1103 Data analysis module 20 server 1104 Instruction execution module 1000 Compressed file processing system 101 processor 110 Compressed package file processing device 102 Memory 1101 Data acquisition module DETAILED DESCRIPTION
[0063] In order to facilitate understanding of the present application, the present application is described in more detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that when an element is described as "fixed to" another element, it can be directly on the other element, or there can be one or more centered elements therebetween. When an element is described as "connected to" another element, it can be directly connected to the other element, or there can be one or more centered elements therebetween. The terms "vertical", "horizontal", "left", "right" and similar expressions used in this specification are for illustrative purposes only.
[0064] Unless otherwise defined, all technical and scientific terms used in this specification have the same meanings as those commonly understood by those skilled in the art to which this application belongs. The terms used in this specification and in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the relevant listed items.
[0065] At present, the conventional decompression method is that when a user needs to access a text file in a remote compressed package, he can only download the entire compressed package to the local computer and then decompress it to the local disk to view and edit the contents of the compressed package. This conventional decompression method requires local disk space and requires the installation of a tool for decompressing the compressed package file in advance. Therefore, in order to address the defects of low efficiency and large space occupation of the conventional decompression method, the existing technical solution decompresses the compressed package through a server program such as node / java in a dedicated cloud server. For example, the compressed package is decompressed by using the compressing library in the node server program or the ZipOutputStream, ZipInputStream, and ZipEntry under the java.util.zip class library of the java server program, and then the data in the compressed package is transmitted to the user client through http and other methods. Although this technical solution can realize online viewing of the compressed package, it relies on the back-end server, which puts greater pressure on the server and high server cost.
[0066] Based on the shortcomings of the above technical solutions, this application directly utilizes the processing power of the browser to complete the transmission, decompression and decoding of the text file compression package on the client, and finally displays it in the browser in the form of a string. This not only makes it convenient for users to directly view the text files in the compressed package in the browser, but also disperses the computing power locally, greatly reducing the pressure on the back-end server and saving server costs.
[0067] The technical solution of this application is described in detail below with reference to the accompanying drawings:
[0068] See also Figure 1 , Figure 1 is a schematic diagram of an application environment provided by an embodiment of the present application;
[0069] like Figure 1 As shown, the application environment 100 includes: an electronic device 10 and a server 20, wherein the electronic device 10 and the server 20 are connected via a network communication, wherein the network includes a wired network and / or a wireless network. It is understood that the network includes wireless networks such as 2G, 3G, 4G, 5G, wireless LAN, Bluetooth, etc., and may also include wired networks such as serial cables and network cables.
[0070] In an embodiment of the present application, the electronic device 10 is used to send a network request to the server based on the link of the compressed package based on the browser. It is understandable that the electronic device 10 can be an electronic product with communication and networking functions such as a computer and a mobile phone. The electronic device 10 includes a communication module, which is connected to the server 20 for communication, and is used to receive a response sent by the server, for example, receiving a network response returned by the server, and obtaining the compressed package file data based on the network response. In an embodiment of the present application, the communication module can realize communication with the Internet, wherein the communication module includes but is not limited to a WIFI module, a ZigBee module, an NB_IoT module, a 4G module, a 5G module, a Bluetooth module and other communication units.
[0071] In an embodiment of the present application, the electronic device 10 includes a controller, which serves as the control core of the electronic device 10 and is used to control the electronic device 10 to send a network request to the server according to the link of the compressed package. The controller can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RICS Machine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component or any combination of these components. The controller can also be any traditional processor, controller, microcontroller or state machine. The controller can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in combination with a DSP and / or any other such configuration, or one or more combinations of a microcontroller unit (MCU), a field programmable gate array (FPGA), and a system-on-chip (SoC).
[0072] It can be understood that the electronic device 10 in the embodiment of the present application also includes a storage module, which includes but is not limited to: FLASH flash memory, NAND flash memory, vertical NAND flash memory (VNAND), NOR flash memory, resistive random access memory (RRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), spin transfer torque random access memory (STT-RAM) and other devices. One or more.
[0073] In an embodiment of the present application, the server 20 is communicatively connected to the electronic device 10, and is used to receive a network request sent by the electronic device 10 and return a network response to the electronic device 10. There are multiple servers 20, and multiple servers can constitute a server cluster. For example, the server cluster includes: a first server, a second server, ..., an Nth server, or the server cluster can be a cloud computing service center, which includes several servers. The servers in the embodiment of the present application include but are not limited to: tower servers, rack servers, blade servers, and cloud servers. Preferably, the server is a cloud server (Elastic Compute Service, ECS).
[0074] See also Figure 2 , Figure 2 This is a schematic diagram of a local processing compressed package provided by an embodiment of the present application;
[0075] like Figure 2 As shown, when a user needs to access files in a remote compressed package, they first need to download the compressed package to a local disk, then download / install a decompression tool, decompress the compressed package using the decompression tool, and finally open / edit the compressed package files locally. This method is inefficient because the user needs to download / install the decompression tool and perform multiple operations on the compressed package. In addition, both the compressed package and the decompression tool need to be downloaded to the local disk, which takes up a large amount of local disk space.
[0076] In view of this, an embodiment of the present application provides a method for processing compressed package files to improve the data processing efficiency of compressed package files and save server costs.
[0077] For details, please refer to Figure 3 , Figure 3 This is a flowchart of a method for processing compressed files provided in an embodiment of the present application;
[0078] The file processing method of the compressed package is applied to a browser. Specifically, the execution subject of the file processing method of the compressed package is one or at least two processors of an electronic device.
[0079] like Figure 3 As shown, the file processing method of the compressed package includes:
[0080] Step S301: Obtain the link of the compressed package;
[0081] Specifically, a link of the compressed package is obtained in a browser, wherein the link of the compressed package is in a uniform resource locator (URL) format, and the URL is used to indicate a designated information location on a World Wide Web service program on the Internet.
[0082] Step S302: Obtain the file data in the compressed package according to the link of the compressed package;
[0083] Please refer to Figure 4 , Figure 4 yes Figure 3 A detailed flow chart of step S302 in FIG.
[0084] like Figure 4 As shown, step S302: according to the link of the compressed package, obtain the file data in the compressed package, including:
[0085] Step S3021: Send a network request to the server according to the link of the compressed package;
[0086] Specifically, the Fetch method in the browser is an API (Application Programming Interface) for obtaining network data. Its underlying layer is to send an http request to the server through the browser's lower-level XMLHttpRequest object, and the server can return the compressed file data through the http response. Among them, XMLHttpRequest is a browser interface that enables Javascript to perform http communication. The role of the XMLHttpRequest object The XMLHttpRequest object is used to exchange data with the server in the background. Through the Fetch method, according to the URL link of the compressed package, the URL link of the compressed package is used as a parameter of the network request (http request) to send the network request (http request) to the server. It should be noted that the browser includes but is not limited to the Chrome browser.
[0087] Step S3022: receiving a network response returned by the server, and obtaining compressed file data according to the network response;
[0088] Specifically, the network response includes an http response. After the server receives the network request, the server returns the compressed package file data through the http response. The electronic device receives the network response returned by the server through the browser, and obtains the compressed package file data according to the network response through the then method of the Promise instance.
[0089] In an embodiment of the present application, the present application obtains compressed package file data in the browser through the network response returned by the server, rather than storing the compressed package in the local disk and decompressing the compressed package to obtain the compressed package file data. The present application can save space on the local disk.
[0090] Step S303: converting the file data into read-only binary data;
[0091] In the embodiments of the present application, Blob (Binary Large Object) is a read-only binary data type, which usually represents media resources such as binary files, pictures, audio or video. The Blob data type is usually used to store binary data in a database, and can also be used to transmit large binary data, upload files, etc. in the front end (such as a browser). Compared with strings and arrays, the Blob data type is more suitable for processing binary data and provides better performance and scalability. In JavaScript, the Blob data type can be created using the Blob constructor, or it can be converted from other data types (such as strings or ArrayBuffer).
[0092] Specifically, the Response is the byte stream data requested by the Fetch method in the above step, that is, the compressed file data. At this time, it needs to be converted into read-only binary data (data of the Blob data type) before subsequent processing. The Response.blob method provided by the browser parses the compressed file data and converts it into read-only binary data.
[0093] Step S304: converting the read-only binary data into editable binary data by calling the text reading interface of the browser;
[0094] In the embodiments of the present application, a Blob is read-only binary data that can be stored on disk. To operate on Blob-type data, the Blob-type data must be converted into an editable binary ArrayBuffer for storage in the memory of an electronic device. Read-only binary data and editable binary data can be directly converted to each other. For example, the const arrayBuffer = await blob.arrayBuffer() method and the new Blob([new Uint8Array(data)]) method can be used to implement conversion between Blob-type data and ArrayBuffer-type data.
[0095] Specifically, FileReader is used to read files from the user's computer. The FileReader object allows web applications to asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using a Blob object to specify the data to be read. By calling the browser's text reading interface, the FileReader API, and using the const arrayBuffer = await blob.arrayBuffer() method, read-only binary data (Blob type data) is converted into editable binary data (ArrayBuffer type data).
[0096] Step S305: Parse the editable binary data to obtain a file directory tree of the compressed package;
[0097] Please refer to Figure 5 , Figure 5 yes Figure 3 Detailed flow diagram of step S305 in FIG.
[0098] like Figure 5 As shown, step S305: parsing the editable binary data to obtain the file directory tree of the compressed package, including:
[0099] Step S3051: Parse the editable binary data through a third-party library to obtain the file directory in the compressed package;
[0100] Specifically, the third-party library includes jsZip, a JavaScript library for creating, reading, and editing compressed files. Through the third-party library jsZip, the decompression algorithm in the third-party library jsZip is called to parse the editable binary data and obtain the file directory in the compressed file.
[0101] Step S3052: Obtain the directory structure of the compressed package according to the file directory;
[0102] Specifically, since the compressed file format stores the internal file directory of the compressed file at the end of the file, it is only necessary to read the data at the end of the compressed file to obtain the directory structure of the entire compressed file, that is, to obtain the directory structure of the compressed file based on the file directory.
[0103] Step S3053: Obtain the file directory tree of the compressed package according to the directory structure of the compressed package;
[0104] Specifically, a file directory tree of the compressed package is generated according to the directory structure of the compressed package, and the file directory tree is displayed in a browser (Web side), wherein the file directory tree includes at least one editable binary data.
[0105] In an embodiment of the present application, editable binary data is parsed through a third-party library to obtain the file directory in the compressed package, and finally a file directory tree of the compressed package is generated, which is equivalent to providing a visual compressed package file directory in the browser, making it easier for users to find files in the compressed package and improving the user's processing efficiency of file data in the compressed package.
[0106] Step S306: Obtaining a first user instruction;
[0107] Specifically, the user finds the file data that needs to be opened according to the file directory tree in the browser, and clicks on the location of the file data in the file directory tree, that is, issues a first user instruction, and then the electronic device obtains the first user instruction, wherein the first user instruction includes the location of the file data in the file directory tree, and each first user instruction corresponds to an editable binary data.
[0108] Step S307: converting the editable binary data corresponding to the first user instruction into character string data;
[0109] Please refer to Figure 6 , Figure 6 yes Figure 3 Detailed flow chart of step S307 in FIG.
[0110] like Figure 6 As shown, step S307: converting the editable binary data corresponding to the first user instruction into character string data includes:
[0111] Step S3071: converting the editable binary data corresponding to the first user instruction into uncompressed editable binary data;
[0112] Specifically, the third-party library jsZip converts the editable binary data corresponding to the first user instruction into uncompressed editable binary data using a compression algorithm defined in a compression package specification.
[0113] Step S3072: Encode the uncompressed editable binary data to obtain character string data;
[0114] It is understood that string data itself is also composed of binary data. The uncompressed editable binary data is only encoded and displayed as string data when it is displayed in a browser. Specifically, converting the uncompressed editable binary data into string data includes converting the uncompressed editable binary data into string data using UTF-8 in a browser editor, such as Monaco Editor, to display the string data.
[0115] In the embodiment of the present application, Monaco Editor is a web-based code editor open sourced by Microsoft. Monaco Editor is a code editor that provides support for VS Code. The Monaco Editor runs in a browser environment and supports functions such as smart prompts, code highlighting, and code formatting.
[0116] Step S308: Obtain an editable string text based on the string data by calling the browser's editor;
[0117] Specifically, the editor of the browser includes a MonacoEditor editor, which loads the parsed string in the compressed package file through the MonacoEditor editor to obtain an editable string text, and then the MonacoEditor editor copies the editable string text into the memory for the user to edit.
[0118] It is understandable that by calling the browser's editor, the user can not only view the file data in the compressed package in the browser, but also convert the file data in the compressed package into editable string text and edit the editable string text.
[0119] Please refer to Figure 7 , Figure 7 This is a flowchart of downloading binary text to a local computer, as provided in an embodiment of the present application;
[0120] like Figure 7 As shown in the figure, the process of downloading binary text to the local computer includes:
[0121] Step S701: Obtain a second user instruction;
[0122] Specifically, the electronic device obtains a second user instruction issued by the user, wherein the second user instruction is used to download the editable character string text to the local device, that is, the electronic device.
[0123] Step S702: Convert the editable string text into binary text according to the second user instruction;
[0124] Specifically, according to the second user instruction, the editable string text is converted into binary text of the Blob data type through the Blob constructor of the browser.
[0125] Step S703: Generate a download link for the binary text, and download the binary text to a local computer according to the download link;
[0126] Specifically, a download link is generated for the binary text through the window.URL.createObjectURL method of the browser, and then the download method of the browser is called to download the binary text to the local computer.
[0127] It is understandable that the user can selectively download the editable string text corresponding to the second user instruction to the local computer instead of downloading all the file data in the compressed package to the local computer. This application can save space on the local disk.
[0128] Please refer to Figure 8 , Figure 8 This is a schematic diagram of a process for obtaining an image corresponding to an image file provided by an embodiment of the present application;
[0129] In the embodiment of the present application, the file data includes a picture file.
[0130] like Figure 8 As shown, the process of obtaining the image corresponding to the image file includes:
[0131] Step S801: Obtaining an image tag in editable binary data;
[0132] Specifically, the editable binary data includes an image tag (img tag), which corresponds to a section of code. The code corresponding to the image tag in the editable binary data is read to obtain the image tag in the editable binary data.
[0133] Step S802: according to the image tag, the path of the resource file is set to the editable binary data corresponding to the image file;
[0134] Specifically, according to the image tag (img tag), the image file can be identified and the path of the resource file is set to the editable binary data corresponding to the image file. For example, through the img tag of the browser, the src field is set to the base64 encoding of the image file.
[0135] Step S803: Obtaining the image corresponding to the image file according to the editable binary data corresponding to the image file;
[0136] Specifically, after setting the path of the resource file to the editable binary data corresponding to the image file, the image corresponding to the image file can be found according to the editable binary data corresponding to the image file, so as to display the image in the compressed package online in the browser.
[0137] Please refer to Figure 9 , Figure 9 This is a schematic diagram of the overall process of a compressed file processing method provided by an embodiment of the present application;
[0138] like Figure 9 As shown, the file processing method of the compressed package in the present application is applied to the browser, and the overall process of the file processing method of the compressed package includes: obtaining the file data in the compressed package, converting the file data into read-only binary data, calling the text reading interface of the browser, converting the read-only binary data into editable binary data, parsing the editable binary data through a third-party library, obtaining the file directory tree of the compressed package, obtaining the first user instruction, converting the editable binary data into string data, and obtaining editable string text.
[0139] In summary, the inventive concept of this application is to directly utilize the browser's processing power to complete the transmission, decompression, and decoding of compressed packages on the client side, and ultimately display them in the browser as a string of text for the user to view and edit. This method not only facilitates user operation, allowing users to directly view the file data in the compressed package in the browser without multiple manual operations, but also can disperse computing power to the local area, greatly reducing the pressure on the backend server and saving server costs.
[0140] In an embodiment of the present application, a file processing method for a compressed package is provided and applied to a browser. The file processing method for a compressed package includes: obtaining a link to a compressed package, wherein the compressed package includes at least one file data; obtaining the file data in the compressed package according to the link to the compressed package; converting the file data into read-only binary data; converting the read-only binary data into editable binary data by calling a text reading interface of the browser; parsing the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data; obtaining a first user instruction, wherein the first user instruction includes the position of the file data in the file directory tree, and the first user instruction corresponds to an editable binary data; converting the editable binary data corresponding to the first user instruction into string data; and obtaining an editable string text according to the string data by calling an editor of the browser.
[0141] By converting the file data in the compressed package into editable binary data in the browser, and then converting the editable binary data into string data to obtain editable string text, this application can improve the data processing efficiency of the compressed package file and save server costs.
[0142] Please refer to Figure 10 , Figure 10 This is a schematic diagram of the structure of a compressed file processing device provided in an embodiment of the present application;
[0143] The file processing device of the compressed package is applied to an electronic device. Specifically, the file processing device of the compressed package is applied to one or at least two processors of the electronic device.
[0144] like Figure 10 As shown, the compressed file processing device 110 includes:
[0145] The data acquisition module 1101 is configured to acquire a link to a compressed package, wherein the compressed package includes at least one file data; and acquire the file data in the compressed package according to the link to the compressed package;
[0146] The data conversion module 1102 is used to convert the file data into read-only binary data; by calling the reader interface, the read-only binary data is converted into editable binary data;
[0147] The data parsing module 1103 is configured to parse the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data;
[0148] The instruction execution module 1104 is used to obtain a first user instruction, wherein the first user instruction includes the location of the file in the file directory tree, and each first user instruction corresponds to an editable binary data; convert the editable binary data corresponding to the first user instruction into string data; and obtain an editable string text according to the string data by calling a browser editor.
[0149] In the embodiment of the present application, the data acquisition module 1101 is specifically used to:
[0150] Send a network request to the server based on the link of the compressed package;
[0151] Receive the network response returned by the server and obtain the compressed package file data based on the network response.
[0152] In the embodiment of the present application, the data parsing module 1103 is specifically used to:
[0153] Use a third-party library to parse editable binary data and obtain the file directory in the compressed package;
[0154] According to the file directory, get the directory structure of the compressed package;
[0155] According to the directory structure of the compressed package, the file directory tree of the compressed package is obtained.
[0156] In the embodiment of the present application, the instruction execution module 1104 is specifically used to:
[0157] converting the editable binary data corresponding to the first user instruction into uncompressed editable binary data;
[0158] Encodes uncompressed editable binary data into string data.
[0159] In the embodiment of the present application, the instruction execution module 1104 is further configured to:
[0160] Obtaining a second user instruction;
[0161] According to a second user instruction, the editable string text is converted into binary text;
[0162] Generate a download link for the binary text and download the binary text to the local computer according to the download link;
[0163] Get the image tag in the editable binary data;
[0164] According to the image tag, set the path of the resource file to the editable binary data corresponding to the image file;
[0165] Get the image corresponding to the image file according to the editable binary data corresponding to the image file.
[0166] In the embodiments of the present application, the file processing device of the compressed package can also be constructed by hardware devices. For example, the file processing device of the compressed package can be constructed by one or more chips, and the chips can work in coordination with each other to complete the file processing method of the compressed package described in the above embodiments. For another example, the file processing device of the compressed package can also be constructed by various logic devices, such as a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0167] The compressed package file processing device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc., and the embodiment of the present application does not specifically limit this.
[0168] The compressed file processing device in the embodiment of the present application can be a device having an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0169] The compressed package file processing device provided in the embodiment of the present application can achieve Figure 3 To avoid repetition, the various implementation processes will not be described here.
[0170] It should be noted that the aforementioned compressed package file processing device can execute the compressed package file processing method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in the compressed package file processing device embodiment, reference can be made to the compressed package file processing method provided in the aforementioned embodiment.
[0171] In an embodiment of the present application, a file processing device for a compressed package is provided and applied to a browser. The file processing device for the compressed package includes: a data acquisition module for acquiring a link of a compressed package, wherein the compressed package includes at least one file data; acquiring the file data in the compressed package according to the link of the compressed package; a data conversion module for converting the file data into read-only binary data; converting the read-only binary data into editable binary data by calling an interface of a reader; a data parsing module for parsing the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data; an instruction execution module for acquiring a first user instruction, wherein the first user instruction includes the position of the file in the file directory tree, and each first user instruction corresponds to an editable binary data; converting the editable binary data corresponding to the first user instruction into string data; and obtaining an editable string text according to the string data by calling a browser editor.
[0172] By converting the file data in the compressed package into editable binary data in the browser, and then converting the editable binary data into string data to obtain editable string text, this application can improve the data processing efficiency of the compressed package file and save server costs.
[0173] Please refer to Figure 11 , Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0174] like Figure 11 As shown, the electronic device 10 includes one or more processors 101 and a memory 102. Figure 11 A processor 101 is taken as an example.
[0175] The processor 101 and the memory 102 may be connected via a bus or other means. Figure 11 The bus connection is taken as an example.
[0176] The processor 101 is used to provide computing and control capabilities to control the electronic device 10 to perform corresponding tasks, for example, to control the electronic device 10 to perform the file processing method of the compressed package in any of the above-mentioned method embodiments, including: obtaining a link to the compressed package, wherein the compressed package includes at least one file data; obtaining the file data in the compressed package according to the link to the compressed package; converting the file data into read-only binary data; converting the read-only binary data into editable binary data by calling the text reading interface of the browser; parsing the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data; obtaining a first user instruction, wherein the first user instruction includes the position of the file data in the file directory tree, and the first user instruction corresponds to an editable binary data; converting the editable binary data corresponding to the first user instruction into string data; and obtaining an editable string text according to the string data by calling the editor of the browser.
[0177] By converting the file data in the compressed package into editable binary data in the browser, and then converting the editable binary data into string data to obtain editable string text, this application can improve the data processing efficiency of the compressed package file and save server costs.
[0178] The processor 101 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or any combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0179] The memory 102 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the file processing method of the compressed package in the embodiment of the present application. The processor 101 can implement the file processing method of the compressed package in any of the following method embodiments by running the non-transient software programs, instructions and modules stored in the memory 102. Specifically, the memory 102 may include a volatile memory (VM), such as a random access memory (RAM); the memory 102 may also include a non-volatile memory (NVM), such as a read-only memory (ROM), a flash memory (flash memory), a hard disk drive (HDD) or a solid-state drive (SSD) or other non-transient solid-state storage device; the memory 102 may also include a combination of the above-mentioned types of memories.
[0180] The memory 102 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 102 may optionally include a memory remotely located relative to the processor 101, and such remote memory may be connected to the processor 101 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0181] One or more modules are stored in the memory 102, and when executed by one or more processors 101, the compressed file processing method in any of the above method embodiments is executed, for example, the above described Figure 3 The steps shown can also be implemented Figure 10 The functions of each module or unit.
[0182] In the embodiment of the present application, the electronic device 10 may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input and output. The electronic device 10 may also include other components for realizing device functions, which will not be described in detail here.
[0183] Please refer to Figure 12 , Figure 12 This is a structural diagram of a compressed file processing system provided by an embodiment of the present application;
[0184] like Figure 12As shown, the compressed file processing system 1000 includes an electronic device 10 and a server 20.
[0185] The electronic device 10 is configured to obtain a log directory and package the log directory into a compressed package;
[0186] The server 20 is communicatively connected to the electronic device and is used to obtain the compressed package sent by the electronic device.
[0187] In an embodiment of the present application, in an application scenario where a user needs to view the log content and analyze the cause of a fault based on the log content, the electronic device first obtains the log directory, then packages the log directory into a compressed package, and sends it to the server; after the server obtains the compressed package, the user can view the log directory in the compressed package in the browser according to the above-mentioned file processing method of the compressed package. Therefore, the present application can improve the data processing efficiency in actual application scenarios by improving the processing efficiency of the compressed package.
[0188] The present application also provides a non-volatile computer-readable storage medium, such as a memory including program code, wherein the program code can be executed by a processor to implement the compressed file processing method of the above embodiment. For example, the non-volatile computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CDROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0189] The present application also provides a computer program product comprising one or more program codes stored in a non-volatile computer-readable storage medium. A processor of an electronic device reads the program code from the non-volatile computer-readable storage medium and executes the program code to complete the steps of the compressed package file processing method provided in the above embodiment.
[0190] Those skilled in the art will understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or by hardware related to program code, and the program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc.
[0191] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course, can also be implemented by hardware. Those skilled in the art can understand that all or part of the processes in the above embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the non-volatile computer-readable storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0192] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Based on the idea of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the present application as mentioned above. For the sake of simplicity, they are not provided in detail. Although the present application has been described in detail with reference to the aforementioned embodiments, ordinary technicians in this field should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for processing compressed files, characterized in that: Applied to a browser, the method includes: Obtaining a link to the compressed package, wherein the compressed package includes at least one file data; According to the link of the compressed package, obtaining the file data in the compressed package; Converting the file data into read-only binary data; Converting the read-only binary data into editable binary data by calling the text reading interface of the browser; Parsing the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data; Obtaining a first user instruction, wherein the first user instruction includes a location of the file data in a file directory tree, and the first user instruction corresponds to one of the editable binary data; Converting the editable binary data corresponding to the first user instruction into character string data; By calling the editor of the browser, an editable string text is obtained according to the string data.
2. The method according to claim 1, characterized in that The step of obtaining the file data in the compressed package according to the link of the compressed package includes: Sending a network request to the server according to the link of the compressed package; Receive a network response returned by the server, and obtain the compressed package file data according to the network response.
3. The method according to claim 1, characterized in that The step of parsing the editable binary data to obtain a file directory tree of the compressed package includes: Parsing the editable binary data through a third-party library to obtain the file directory in the compressed package; According to the file directory, obtain the directory structure of the compressed package; According to the directory structure of the compressed package, a file directory tree of the compressed package is obtained.
4. The method according to claim 1, wherein The method further comprises: Obtaining a second user instruction; According to the second user instruction, convert the editable string text into binary text; A download link is generated for the binary text, and the binary text is downloaded to a local computer according to the download link.
5. The method according to claim 1, wherein The file data includes a picture file, and the method further includes: Obtaining an image tag in the editable binary data; According to the image tag, the path of the resource file is set to the editable binary data corresponding to the image file; According to the editable binary data corresponding to the picture file, the picture corresponding to the picture file is obtained.
6. The method according to any one of claims 1 to 5, characterized in that The converting the editable binary data corresponding to the first user instruction into character string data includes: converting the editable binary data corresponding to the first user instruction into uncompressed editable binary data; The uncompressed editable binary data is encoded to obtain the character string data.
7. A compressed file processing device, characterized in that: Applied to a browser, the device includes: A data acquisition module, configured to acquire a link to the compressed package, wherein the compressed package includes at least one file data; and acquire the file data in the compressed package according to the link to the compressed package; A data conversion module is used to convert the file data into read-only binary data; by calling the text reading interface of the browser, the read-only binary data is converted into editable binary data; a data parsing module, configured to parse the editable binary data to obtain a file directory tree of the compressed package, wherein the file directory tree includes at least one editable binary data; An instruction execution module is used to obtain a first user instruction, wherein the first user instruction includes the location of the file data in the file directory tree, and the first user instruction corresponds to an editable binary data; convert the editable binary data corresponding to the first user instruction into string data; and obtain an editable string text according to the string data by calling a browser editor.
8. An electronic device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the file processing method of the compressed package according to any one of claims 1 to 6.
9. A compressed file processing system, characterized in that: The system comprises: The electronic device according to claim 8, configured to obtain a log directory and package the log directory into a compressed package; The server is communicatively connected to the electronic device and is used to obtain the compressed package sent by the electronic device.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer storage medium stores a computer program or instruction. When the computer program or instruction is executed, the compressed package file processing method according to any one of claims 1 to 6 is implemented.