CN114422499B - File downloading method, system and device - Google Patents

File downloading method, system and device Download PDF

Info

Publication number
CN114422499B
CN114422499B CN202111613886.3A CN202111613886A CN114422499B CN 114422499 B CN114422499 B CN 114422499B CN 202111613886 A CN202111613886 A CN 202111613886A CN 114422499 B CN114422499 B CN 114422499B
Authority
CN
China
Prior art keywords
file
data
target
target file
compressed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111613886.3A
Other languages
Chinese (zh)
Other versions
CN114422499A (en
Inventor
唐汇波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202111613886.3A priority Critical patent/CN114422499B/en
Publication of CN114422499A publication Critical patent/CN114422499A/en
Application granted granted Critical
Publication of CN114422499B publication Critical patent/CN114422499B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/04Protocols for data compression, e.g. ROHC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a file downloading method, a system and a device, which relate to the technical field of data transmission, wherein the method comprises the following steps: after a first file request which is sent by a user side and is used for requesting to download a target file is obtained, predicting a second data amount of a compressed file to be generated and offset of each target file in the compressed file according to the first data amount of the target file and the file name length of the target file; sending a second data quantity to the user terminal; acquiring data of a target file from a file server storing the file in the form of a file stream; generating file fragments of the compressed file based on the first data volume, the file name length and the offset, and sending data of the file fragments and the target file to the user side so that the user side generates the compressed file containing the target file based on the received file fragments and the data to complete the downloading process of the target file. By applying the embodiment of the invention, the waste of storage resources of the application server can be reduced in the process of downloading the file at the user side.

Description

File downloading method, system and device
Technical Field
The present invention relates to the field of data transmission technologies, and in particular, to a method, a system, and an apparatus for downloading a file.
Background
A user can initiate a file downloading request to an application server through a browser installed at the user side, and the application server can assist the user side in downloading files from a file server, but the browser often has a limit on the number of synchronously downloaded files, and is difficult to synchronously download a plurality of files.
In the prior art, when a user downloads a plurality of files synchronously through a browser, an application server can acquire a file requested by the user from a file server after receiving a file request sent by the browser, compress the file to generate a compressed file, and then send the compressed file to the user. Therefore, under the condition that the browser has a limit on the number of synchronously downloaded files, the user side can download each file at one time through the browser. However, before the application server sends the files to the user side, each file needs to be compressed to obtain a compressed file, and the compressed file occupies the storage resources of the application server, so that the storage resources are wasted.
Disclosure of Invention
The embodiment of the invention aims to provide a file downloading method, a file downloading system and a file downloading device so as to reduce the waste of storage resources of an application server. The specific technical scheme is as follows:
In a first aspect of the embodiment of the present invention, there is first provided a file downloading method, applied to an application server, the method including:
after a first file request which is sent by a user side and is used for requesting to download a target file is acquired, predicting second data quantity of a compressed file to be generated and offset of each target file in the compressed file according to first data quantity of the target file and file name length of the target file, wherein the compressed file is as follows: and compressing the target file with the compression level of 0, wherein the offset is as follows: the position of the first byte of the target file in the compressed file;
the second data volume is sent to the user side, so that the user side determines the second data volume of the obtained compressed file;
acquiring data of a target file from a file server storing the file in the form of a file stream;
generating a file fragment of the compressed file based on the first data amount, the file name length, and the offset, the file fragment comprising: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
And sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file containing the target file based on the received file fragments and the data to finish the downloading process of the target file.
In a second aspect, an embodiment of the present invention provides a file downloading method, applied to a user side, where the method includes:
sending a first file request for requesting to download a target file to an application server;
obtaining a second data amount of the predicted compressed file to be obtained, wherein the second data amount is sent by the application server, and the compressed file is: compressing the target file with the compression grade of 0;
receiving data of a target file and a file fragment sent by the application server, wherein the file fragment comprises: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
and generating a compressed file containing the target file based on the received data and the file fragment, and completing the downloading process of the target file.
In a third aspect, an embodiment of the present invention provides a file downloading system, where the system includes a user side and an application server;
The user terminal is used for sending a first file request for requesting to download the target file to the application server;
the application server is used for predicting the second data amount of the compressed file to be generated and the offset of each target file in the compressed file according to the first data amount of the target file and the file name length of the target file; transmitting the second data amount to the user terminal; acquiring data of a target file from a file server storing the file in the form of a file stream; generating a file fragment of the compressed file based on the first data amount, the file name length, and the offset; and sending the data of the file fragments and the target file to the user side, wherein the compressed file is: and compressing the target file with the compression level of 0, wherein the offset is as follows: the first byte of the target file is located in the compressed file, and the file fragment comprises: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
the user side is used for generating a compressed file containing the target file based on the received data and the file fragments, and completing the downloading process of the target file.
In a fourth aspect, an embodiment of the present invention provides a file downloading device, applied to an application server, where the device includes:
the data quantity prediction module is used for predicting second data quantity of a compressed file to be generated and offset of each target file in the compressed file according to the first data quantity of the target file and the file name length of the target file after acquiring a first file request which is sent by a user and is used for requesting to download the target file, wherein the compressed file is: and compressing the target file with the compression level of 0, wherein the offset is as follows: the position of the first byte of the target file in the compressed file;
the data volume sending module is used for sending the second data volume to the user side so that the user side can determine the second data volume of the obtained compressed file;
a first data acquisition module for acquiring data of a target file from a file server storing the file in the form of a file stream;
a first segment generation module, configured to generate a file segment of the compressed file based on the first data amount, a file name length, and the offset, where the file segment includes: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
And the first data sending module is used for sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file containing the target file based on the received file fragments and the data and finishes the downloading process of the target file.
In a fifth aspect, an embodiment of the present invention provides a file downloading device, applied to a user side, where the device includes:
the first request sending module is used for sending a first file request for requesting to download the target file to the application server;
the data volume obtaining module is used for obtaining a second data volume of the predicted compressed file to be obtained, which is sent by the application server, wherein the compressed file is: compressing the target file with the compression grade of 0;
the first data receiving module is configured to receive data of a target file and a file fragment sent by the application server, where the file fragment includes: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
and the first file generation module is used for generating a compressed file containing the target file based on the received data and the file fragments.
In a sixth aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor configured to implement the method steps of any one of the first or second aspects when executing a program stored on a memory.
In a seventh aspect, embodiments of the present invention provide a computer readable storage medium having a computer program stored therein, which when executed by a processor, implements the method steps of any of the first or second aspects.
In an eighth aspect, in a further aspect of embodiments of the present invention, there is also provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method steps of any of the first or second aspects described above.
The file downloading method provided by the embodiment of the invention is applied to an application server, and after a first file request which is sent by a user side and requests to download a target file is obtained, the second data amount of the compressed file which is obtained by compressing the target file with the compression level of 0 and is to be generated is predicted according to the first data amount of the target file and the file name length of the target file, and the position of the first byte of each target file in the compressed file. And transmitting the second data amount to the client so that the client determines the second data amount of the compressed file to be downloaded. And acquiring data of the target file from a file server storing the file in a file stream form, generating file fragments of the compressed file based on the first data amount, the file name length and the offset, and transmitting the file fragments and the data of the target file to a user side so that the user side generates the compressed file containing the target file based on the received file fragments and the data to complete the downloading process of the target file.
As can be seen from the above, the compressed file includes the data obtained by compressing the target file and the file fragment, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the present invention, the data obtained by compressing the target file and included in the finally obtained compressed file is the same as the data originally included in the target file, and the application server does not need to compress and encode the target file after obtaining the target file from the file server, only needs to generate the file fragment included in the compressed file, and sends the file fragment and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragment to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. Furthermore, if the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1 is a flowchart of a first method for downloading files according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a data structure of a compressed file according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a second method for downloading files according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a third method for downloading files according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating a fourth method for downloading files according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a file downloading system according to an embodiment of the present invention;
FIG. 7 is a flowchart illustrating a fifth method for downloading files according to an embodiment of the present invention;
FIG. 8 is a flowchart illustrating a sixth file downloading method according to an embodiment of the present invention;
FIG. 9 is a schematic structural diagram of a first file downloading device according to an embodiment of the present invention;
FIG. 10 is a schematic structural diagram of a second file downloading device according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
Fig. 12 is a schematic structural diagram of another electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. Based on the embodiments of the present application, all other embodiments obtained by the person skilled in the art based on the present application are included in the scope of protection of the present application.
In the prior art, a large amount of storage resources of an application server are wasted in the process that the application server transmits files to a user side, and in order to solve the problem, the embodiment of the application provides a file downloading method, a file downloading system and a file downloading device.
The embodiment of the application provides a file downloading method which is applied to an application server and comprises the following steps:
after a first file request which is sent by a user side and is used for requesting to download a target file is acquired, predicting second data quantity of a compressed file to be generated and offset of each target file in the compressed file according to the first data quantity of the target file and the file name length of the target file, wherein the compressed file is as follows: the target file is compressed to obtain a target file with a compression level of 0, and the offset is as follows: the position of the first byte of the target file in the compressed file;
Transmitting the second data amount to the client so that the client determines the second data amount of the obtained compressed file;
acquiring data of a target file from a file server storing the file in the form of a file stream;
generating a file fragment of the compressed file based on the first data amount, the file name length, and the offset, the file fragment comprising: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
and sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file containing the target file based on the received file fragments and the data to finish the downloading process of the target file.
As can be seen from the above, the compressed file includes the data obtained by compressing the target file and the file fragment, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the present invention, the data obtained by compressing the target file and included in the finally obtained compressed file is the same as the data originally included in the target file, and the application server does not need to compress and encode the target file after obtaining the target file from the file server, only needs to generate the file fragment included in the compressed file, and sends the file fragment and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragment to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
Referring to fig. 1, a flowchart of a first file downloading method according to an embodiment of the present invention is applied to an application server, and the method includes the following steps S101 to S105.
S101: after a first file request which is sent by a user side and is used for requesting to download a target file is acquired, predicting second data quantity of a compressed file to be generated and offset of each target file in the compressed file according to the first data quantity of the target file and the file name length of the target file.
Wherein, the compressed file is: the target file is compressed to obtain a target file with a compression level of 0, and the offset is as follows: the first byte of the target file is located in the compressed file.
Specifically, the user side may send the first file request to the application server through a browser application program installed in the user side. The first file request may include a number of the target file, and the application server may obtain, from the file server, file information of the target file according to the number of the target file after obtaining the first file request sent by the user side, where the file information includes a first data amount of the target file and a file name length of the target file.
The compressed file is obtained by compressing the target file with a compression level of 0, and corresponds to the data of the target file contained in the compressed file as the uncompressed data of the target file. The compressed file may be any file in any format in the prior art, for example, the compressed file may be a file in ZIP format.
In addition, the file segment includes: file end for describing the position of the target file in the compressed file, file head for describing different target files respectively. The file headers are in one-to-one correspondence with the target files, and each file header contains the compression grade of the corresponding target file, the target file generation time, a compression algorithm used when the target file is compressed, the target file name length, the data volume of the target file before compression, the data volume of the target file after compression, the file name of the target file and the like. The file name information contained in the file header is information of a fixed length except the file name of the target file, the file name information contained in the file header is information of a variable length related to the actual file name of the target file, and the specific value is the length of the file name. For each target file, the data amount of the file header of the target file can be determined based on the data amount of each piece of information in the file header, and the sum of the data of the target file and the data amount occupied by the file header corresponding to the target file in the compressed file can be obtained by adding the data amount to the first data amount, so that the data amount of the target file in the compressed file can be obtained.
In addition, the file tail of the compressed file is recorded with information such as the file name length of each target file, the file name of each target file, the offset of each target file in the compressed file and the like, and the information except the file name of the target file is information with fixed length, so that the data volume of the file tail can be calculated based on the file name length and the fixed length of each item of information.
The second data volume of the compressed file can be predicted by adding the data volume of the file tail to the data volume of each target file in the compressed file.
In another embodiment of the present invention, the header of each object file is adjacent to the data of the object file in the compressed file, the header is at the front end of the object file, the header corresponding to each object file and the data of the object file may be collectively referred to as a data combination, the data combinations of the respective object files are sequentially arranged adjacent to each other in the compressed file, and the file tail is located after the file combinations of all the object files. Based on this, the offset of each target file in the compressed file can be determined. The offset may be in bytes.
Referring to fig. 2, a schematic diagram of a data structure of a compressed file according to an embodiment of the present invention is provided.
As can be seen from the figure, the compressed file includes n target files, each of which includes a header corresponding to the target file before the data of the target file, and a tail at the tail of the compressed file. The header contains information such as the file name length of the target file, the file name of the target file, the compression level of the target file, the target file generation time, the compression algorithm used when compressing the target file, the data volume of the target file before compression, the data volume of the target file after compression, and the like.
In the embodiment of the invention, since the compression level of the compressed file is 0, the data volume of the target file before compression is equal to the data volume of the target file, which is the first data volume of the target file.
The data of the target file is divided into different data groups, each data group corresponds to a compression head, and the data groups and the compression heads are stored in the compressed file together. As shown, the data of the 1 st object file is divided into m different data sets.
The file tail contains information such as the file name length, the file name, the offset and the like of each target file.
In fig. 2, only the header of the 1 st object file and the data structure of the 1 st object file in the compressed file are shown in detail, and the data structures of other object files may refer to the data structure of the 1 st object file, which is not shown in detail in the figure.
Specifically, according to the arrangement sequence, the offset of the first target file is the byte number of the header corresponding to the first target file, the offset of the second target file is the sum of the byte number of the data combination of the first target file and the byte number of the header corresponding to the second target file, and so on.
In addition, in the compressed file, the data of each target file may be stored separately in a plurality of data groups, the data amount of the data contained in each data group is the same, each data group is preceded by a compression header corresponding to the data group, the compression header is information of a fixed length, so that when calculating the data amount of each target file in the compressed file, the data amount of the compression header needs to be added, for example, in the compressed file of the ZIP format, the data amount of the data contained in each data group is 65531 bytes, and the data amount of the compression header is 5 bytes.
S102: and transmitting the second data amount to the user side so that the user side determines the second data amount of the obtained compressed file.
Specifically, after the user side obtains the second data amount, the user side may determine that the storage space of the user side may completely store the compressed file, and if the user side may store the compressed file, the storage space with the second data amount may be reserved to store the compressed file.
In addition, the application server may send the binary file type to the client.
S103: the data of the target file is obtained from a file server storing the file in the form of a file stream.
Specifically, the application server may send a request for acquiring the target file to the file server, and the file server may feed back data of the target file to the application server in a form of a file stream. The data is sent to the application server in the form of file stream, the application server processes the data of the target file in the form of file stream, and a large amount of data is not required to be stored at one time, so that the consumption of memory and hard disk resources of the application server can be reduced.
The file stream is a file channel for transmitting data contained in the file in a first-in first-out manner, the file server can sequentially read bytes contained in the target file according to the front-back sequence of each byte in the target file in the form of an input stream, and send the read bytes to the application server according to the first-in first-out sequence, namely, the first-out sequence, and the application server can forward the acquired bytes to the user side after acquiring the bytes sent by the file server.
In one embodiment of the present invention, for each target file, the file server may send data to the application server from the data located in the header of the target file in the order of the data from front to back.
In another embodiment of the present invention, for each target file, the file server may segment the target file, that is, divide the target file into different pieces of data, and for each piece of data, send data to the application server from the first data in the piece of data according to the order of the data from front to back, where the data of the different pieces of data of the target file may be transmitted synchronously.
In addition, the data of each target file can be synchronously transmitted.
S104: and generating a file fragment of the compressed file based on the first data amount, the file name length and the offset.
Specifically, the file segments include a header and a tail, and the information included in the header and the tail may be referred to the content shown in step S101 and will not be described herein.
S105: and sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file containing the target file based on the received file fragments and the data to finish the downloading process of the target file.
Specifically, the application server may also send the data of the file segment and the target file to the user end in a file stream form. After receiving the data of the file fragments and the target files, the user side can determine the positions of the data of each target file in the compressed package to be generated based on the information contained in the file heads and the file tails in the file fragments, and write the received data of the target files into the compressed message according to the positions, so as to generate the compressed file. The user side can decompress the compressed file to obtain the target file, that is, the user side obtains the compressed file, which is equivalent to completing the downloading process of the target file.
In addition, the application server does not process the data of the target file, which is equivalent to directly forwarding the data of the target file to the user side. Therefore, if the file server fragments the target file and transmits the data for each target file, the file server transmits the data to the client in a fragmented manner.
In addition, when the compressed file is a file in a ZIP format, an RAR format or the like, the compressed file includes, for each target file, a check code of the target file in addition to the data and the file fragment of the target file, so that the device may check the data of the target file included in the compressed file based on the check code before decompressing the compressed file in the ZIP format, and decompress the compressed file when determining that the data of the target file has no loss or error. Therefore, in order to enable the client to generate the compressed file, the check code needs to be sent to the client. Step a also needs to be performed before step S105 described above.
Specifically, the check codes included in the compressed files in the ZIP format and the RAR format are both CRC32 (Cyclic Redundancy Check, cyclic redundancy check 32) check codes.
Step A: and acquiring the check code of the target file from the file server.
Specifically, the file server may calculate the target file by using a manner for calculating the CRC32 check code in the prior art, so as to obtain the check code of the target file.
The file server may regenerate and feed back the check code of the target file to the application server after receiving the file request for the target file sent by the application server. The check codes of the files stored in the application server can be calculated in advance, the calculated check codes are stored in the storage space of the application server, and after the file request for the target file sent by the application server is received, the check codes of the target file can be directly fed back to the application program.
After receiving the check code, the above-described step S105 may be implemented by the following step B.
And (B) step (B): and sending the data, the file fragments and the check codes of the target file to the user side, so that the user side generates a compressed file containing the target file based on the received data, the file fragments and the check codes, and the downloading process of the target file is completed.
As can be seen from the above, the compressed file includes the data obtained by compressing the target file and the file fragment, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the present invention, the data obtained by compressing the target file and included in the finally obtained compressed file is the same as the data originally included in the target file, and the application server does not need to compress and encode the target file after obtaining the target file from the file server, only needs to generate the file fragment included in the compressed file, and sends the file fragment and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragment to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
Referring to fig. 3, a flow chart of a second file downloading method according to an embodiment of the present invention is shown, and compared with the embodiment shown in fig. 1, after the interruption of the process of sending the file segments and the data of the target file to the client by the application server, the method further includes the following steps S106 to S110.
Specifically, the interruption of the process may be caused by the user end suspending downloading data, the network connection between the user end and the application server being disconnected, and so on.
S106: and receiving a second file request sent by the user side and representing that the target file is continuously downloaded.
The second file request carries a third data amount of the data received by the user terminal.
Specifically, for each target file, the second file request may carry the sub-data amount of the data of the target file received by the user side. If the application server sends the data of the target file to the user terminal in the form of fragments, the second file request may carry, for each target file, the data of each fragment received by the user terminal.
S107: and determining the position of the data received by the user side in the compressed file based on the third data amount, the first data amount and the file name length.
Wherein, for each target file, the above position may be expressed in terms of an offset of the last byte in the compressed file in the received data of the target file.
In one embodiment of the present invention, based on the file name length, the length of the header corresponding to each target file may be calculated, and based on the first data amount of each target file, the offset of the data of each target file in the compressed file may be determined.
Under the condition that the application server does not segment the data of the target files, calculating the sum of the offset of each target file and the data quantity of the target file received by the user side for each target file to obtain the position of the data received by the user side in the compressed file.
Under the condition that the application server segments the data of the target files, for each target file, the position of the start byte of each data segment in the compressed file can be calculated based on the offset of the target file and the data amount of each data segment, and then the position of the data received by the user terminal in the compressed file can be obtained based on the data amount of the target file which is received by the user segment and belongs to the data segment.
S108: and acquiring data which is contained in the target file and is not acquired by the user side from the file server in the form of a file stream based on the determined position.
Specifically, in the target file, other bytes before the bytes at the determined position in the compressed file are data acquired by the user terminal, and other bytes after the bytes at the determined position in the compressed file are data not acquired by the user terminal. After determining the data acquired by the user side, the application server may send an acquisition request carrying the position of the byte located at the tail end in the data acquired by the user side in the target file to the file server, and the file server may feed back the byte located after the position to the application server after receiving the acquisition request.
S109: and generating file fragments of the compressed file, which are not obtained by the user side, based on the first data amount, the file name length and the offset.
Specifically, the manner of generating the file segments is similar to the embodiment shown in the aforementioned step S104, and will not be described again.
S110: and sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file based on the file fragments and the data received before and after the interruption to finish the downloading process of the target file.
Specifically, the manner of generating the compressed file by the client is similar to the embodiment shown in the aforementioned step S105, which is not described herein.
From the above, in the prior art, the compression of the target file with the compression level not being 0 is difficult for the application server to predict various information contained in the compressed file, so after the process of sending data to the user terminal by the application server is interrupted, it is difficult for the application server to determine the data of the target file received by the user terminal based on the information, and thus it is difficult to continue sending the data which is not obtained yet to the user terminal. The compressed file generated in the embodiment of the invention is generated after the target file is compressed with the compression level of 0, so that after the compressed file is generated by compression, the data volume of the target file contained in the compressed file is equal to the original data volume of the target file, and before the target file is compressed, the application server can directly predict and obtain the information such as the offset of each target file in the compressed file, the data volume of each target file in the compressed file, and the like. Therefore, after the process of sending data to the user terminal by the application server is interrupted, based on the predicted various information and the third data amount fed back by the user terminal, the application server can determine the data of the target file received by the user terminal, so that the data which is not obtained yet can be continuously sent to the user terminal, and the embodiment of the invention supports continuous downloading after the interruption of the file downloading process.
In addition, since the present embodiment supports the continuous transmission after the file transmission is interrupted, when the application server executes step S102 to send the second data amount to the user terminal, the information supporting the breakpoint continuous transmission itself may also be fed back to the user terminal.
In one embodiment of the present invention, taking the example that the compressed file is a ZIP-format file, the process of downloading the file is briefly described.
After receiving the first file request sent by the user side, the application server can predict the second data amount of the compressed file to be generated based on the first data amount of the target file requested by the first file request and the file name length of the target file. In addition to storing the data of the file header and the target file, a check code for checking whether the target file is complete or not during decompression is stored for each target file in the compressed file in the ZIP format. For each target file, the check code of the target file is stored after the data of the target file and before the file header of the next target file. The length of each check code in the compressed file in the ZIP format is 4 bytes, and the length of the check code needs to be considered when predicting the second data amount of the compressed file.
For example, the second data size of the compressed file predicted in this embodiment may be 4GB, where two target files are included, the total data size occupied by the target file 1 is 1GB, and the total data size occupied by the target file 2 is 3GB.
The application server firstly acquires the data of the target file 1 from the file server in the form of a file stream, then acquires the data of the target file 2, and acquires the acquired data, the generated file fragments and the check code of the target file.
If an interruption occurs in the process that the application server sends the file fragments, the data of the target file and the check code to the user terminal, the application server sends 2GB of data to the user terminal before the interruption, which indicates that the related data of the target file 1 is transmitted, including the data of the target file 1, the file header and the check code, and the related data of the target file 2 is transmitted by 1GB.
After the transmission process is interrupted, the terminal may send a second file request again to the application server to continue to acquire the target file, where the second file request carries a third data size, i.e. 2GB, of the data received by the user terminal.
After receiving the second file request, the application server may determine that the related data of the target file 1 has been transmitted, and that the related data of the target file 2 has been transmitted by 1GB, and the application server may determine that the data amount of the header of the target file 2, for example, the data amount of the header of the target file 2 may be 2MB, which indicates that the data of the target file 2 itself that has been transmitted is 1022MB in total from the header of the target file 2, and the application server needs to continuously acquire the remaining data in the target file 2 from one byte after the data of 1022MB that has been transmitted in the target file 2, and forward the remaining data to the user side, thereby completing the process of breakpoint continuous transmission of the target file 1 and the target file 2.
Corresponding to the file downloading method applied to the application server, the embodiment of the invention also provides a file downloading method applied to the user side.
Referring to fig. 4, a flow chart of a third file downloading method according to an embodiment of the present invention is applied to a user terminal, and the method includes the following steps S401 to S404.
S401: a first file request is sent to an application server requesting a download of a target file.
S402: and obtaining the second data quantity of the predicted compressed file to be obtained, which is sent by the application server.
Wherein, the compressed file is: and compressing the target file with the compression grade of 0.
S403: and receiving the data of the target file and the file fragments sent by the application server.
Wherein, the file fragment comprises: file end for describing the position of the target file in the compressed file, file head for describing different target files respectively.
S404: and generating a compressed file containing the target file based on the received data and the file fragment, and completing the downloading of the target file.
As can be seen from the above, the compressed file includes the data obtained by compressing the target file and the file fragment, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the present invention, the data obtained by compressing the target file and included in the finally obtained compressed file is the same as the data originally included in the target file, and the application server does not need to compress and encode the target file after obtaining the target file from the file server, only needs to generate the file fragment included in the compressed file, and sends the file fragment and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragment to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
Referring to fig. 5, a flowchart of a fourth file downloading method according to an embodiment of the present invention is shown, and compared with the embodiment shown in fig. 4, after the process of receiving the data of the target file and the file fragment sent by the application server is interrupted, the method further includes the following steps S405 to S407.
S405: and sending a second file request for continuing to download the target file to the application server.
The second file request carries a third data amount of the data received by the user terminal.
S406: and receiving the data of the target file which is not obtained yet and is sent by the application server.
S407: and generating a compressed file containing the target file based on the data and the file fragments received before and after the interruption, and completing the downloading process of the target file.
From the above, in the prior art, the compression of the target file with the compression level not being 0 is difficult for the application server to predict various information contained in the compressed file, so after the process of sending data to the user terminal by the application server is interrupted, it is difficult for the application server to determine the data of the target file received by the user terminal based on the information, and thus it is difficult to continue sending the data which is not obtained yet to the user terminal. The compressed file generated in the embodiment of the invention is generated after the target file is compressed with the compression level of 0, so that after the compressed file is generated by compression, the data volume of the target file contained in the compressed file is equal to the original data volume of the target file, and before the target file is compressed, the application server can directly predict and obtain the information such as the offset of each target file in the compressed file, the data volume of each target file in the compressed file, and the like. Therefore, after the process of sending data to the user terminal by the application server is interrupted, based on the predicted various information and the third data amount fed back by the user terminal, the application server can determine the data of the target file received by the user terminal, so that the data which is not obtained yet can be continuously sent to the user terminal, and the embodiment of the invention supports continuous downloading after the interruption of the file downloading process.
In one embodiment of the present invention, the above step S404 may be implemented by the following step C.
Step C: and receiving the data of the target file, the file fragments and the check codes of the target file, which are sent by the application server.
The above step S404 may be implemented by the following step D.
Step D: and generating a compressed file containing the target file based on the received data, the file fragment and the check code, and completing the downloading process of the target file.
Specifically, in the file downloading method applied to the user side provided by the embodiment of the present invention, the steps executed by the user side and the application server may refer to the embodiments shown in the file downloading method applied to the application server, which are not described herein again.
Corresponding to the file downloading method, the embodiment of the invention also provides a file downloading system.
Referring to fig. 6, a schematic structure diagram of a file downloading system according to an embodiment of the present invention is provided, where the system includes a client 601 and an application server 602.
Referring to fig. 7, a flowchart of a fifth file downloading method according to an embodiment of the present invention is shown, where the method includes the following steps S701-S707.
S701: the client 601 sends a first file request to the application server 602, where the first file request requests to download the target file.
S702: the application server 602 predicts a second data amount of the compressed file to be generated and an offset of each target file in the compressed file according to the first data amount of the target file and the file name length of the target file.
Wherein, the compressed file is: the target file is compressed to obtain a target file with a compression level of 0, and the offset is as follows: the first byte of the target file is located in the compressed file.
S703: the application server 602 sends the second data amount to the client 601.
S704: the application server 602 obtains the data of the target file from the file server storing the file in the form of a file stream.
S705: the application server 602 generates a file fragment of the compressed file based on the first data amount, the file name length, and the offset.
Wherein, the file fragment comprises: file end for describing the position of the target file in the compressed file, file head for describing different target files respectively.
S706: the application server 602 sends the file fragment and the data of the target file to the client 601.
S707: the client 601 generates a compressed file containing the target file based on the received data and the file fragment, thereby completing the downloading process of the target file.
As can be seen from the above, the compressed file includes the data obtained by compressing the target file and the file fragment, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the present invention, the data obtained by compressing the target file and included in the finally obtained compressed file is the same as the data originally included in the target file, and the application server does not need to compress and encode the target file after obtaining the target file from the file server, only needs to generate the file fragment included in the compressed file, and sends the file fragment and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragment to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
Referring to fig. 8, a flowchart of a sixth file downloading method according to an embodiment of the present invention further includes the following steps S708-S713 compared with the embodiment shown in fig. 7 after the transmission process of the data and the file fragments of the target file between the application server 602 and the client 601 is interrupted.
S708: the client 601 sends a second file request to the application server 602, wherein the second file request indicates that the target file is to be continuously downloaded.
The second file request carries a third data amount of the data received by the user terminal.
S709: the application server 602 determines a location of the data received by the client in the compressed file based on the third data amount, the first data amount, and a file name length.
S710: the application server 602 obtains data included in the target file and not obtained by the client 601 from the file server in the form of a file stream based on the determined location.
S711: the application server 602 generates a file fragment of the compressed file, which is not obtained by the client 601, based on the first data amount, the file name length, and the offset.
S712: the application server 602 sends the file fragment and the data of the target file to the client 601.
S713: the client 601 generates a compressed file containing the target file based on the data and the file fragments received before and after the interruption, and completes the downloading process of the target file.
From the above, in the prior art, the compression of the target file with the compression level not being 0 is difficult for the application server to predict various information contained in the compressed file, so after the process of sending data to the user terminal by the application server is interrupted, it is difficult for the application server to determine the data of the target file received by the user terminal based on the information, and thus it is difficult to continue sending the data which is not obtained yet to the user terminal. The compressed file generated in the embodiment of the invention is generated after the target file is compressed with the compression level of 0, so that after the compressed file is generated by compression, the data volume of the target file contained in the compressed file is equal to the original data volume of the target file, and before the target file is compressed, the application server can directly predict and obtain the information such as the offset of each target file in the compressed file, the data volume of each target file in the compressed file, and the like. Therefore, after the process of sending data to the user terminal by the application server is interrupted, based on the predicted various information and the third data amount fed back by the user terminal, the application server can determine the data of the target file received by the user terminal, so that the data which is not obtained yet can be continuously sent to the user terminal, and the embodiment of the invention supports continuous downloading after the interruption of the file downloading process.
In one embodiment of the present invention, the application server 602 is further configured to:
acquiring a check code of the target file from the file server;
the application server 602 is specifically configured to send, to the client 601, the data of the target file, the file fragment, and the check code;
the client 601 is specifically configured to generate a compressed file including the target file based on the received data, the file fragment and the check code, thereby completing the downloading process of the target file.
Corresponding to the file downloading method applied to the application server, the embodiment of the invention also provides a file downloading device applied to the application server.
Referring to fig. 9, a schematic structural diagram of a first file downloading device according to an embodiment of the present invention is applied to an application server, where the device includes:
the data amount prediction module 901 is configured to predict, after obtaining a first file request sent by a user side and requesting to download a target file, a second data amount of a compressed file to be generated and an offset of each target file in the compressed file according to the first data amount of the target file and a file name length of the target file, where the compressed file is: and compressing the target file with the compression level of 0, wherein the offset is as follows: the position of the first byte of the target file in the compressed file;
A data amount sending module 902, configured to send the second data amount to the client, so that the client determines the second data amount of the compressed file to be obtained;
a first data obtaining module 903, configured to obtain data of a target file from a file server storing the file in a file stream form;
a first segment generating module 904, configured to generate a file segment of the compressed file based on the first data amount, the file name length, and the offset, where the file segment includes: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
the first data sending module 905 is configured to send the file segment and the data of the target file to the user side, so that the user side generates a compressed file containing the target file based on the received file segment and the data, and completes the downloading process of the target file.
As can be seen from the above, the compressed file includes the data obtained by compressing the target file and the file fragment, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the present invention, the data obtained by compressing the target file and included in the finally obtained compressed file is the same as the data originally included in the target file, and the application server does not need to compress and encode the target file after obtaining the target file from the file server, only needs to generate the file fragment included in the compressed file, and sends the file fragment and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragment to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
In one embodiment of the present invention, after the process of sending the file segment and the data of the target file to the user end is interrupted, the apparatus further includes:
the request receiving module is used for receiving a second file request which is downloaded by the user side and used for representing the continuous acquisition of the target file, wherein the second file request carries a third data volume of the data received by the user side;
the position determining module is used for determining the position of the data received by the user side in the compressed file based on the third data volume, the first data volume and the file name length;
the second data acquisition module is used for acquiring data which are contained in the target file and are not acquired by the user side from the file server in the form of a file stream based on the determined position;
the second segment generation module is used for generating a file segment of the compressed file, which is not obtained by the user side, based on the first data volume, the file name length and the offset;
and the second data sending module is used for sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file based on the file fragments and the data received before and after the interruption to finish the downloading process of the target file.
From the above, in the prior art, the compression of the target file with the compression level not being 0 is difficult for the application server to predict various information contained in the compressed file, so after the process of sending data to the user terminal by the application server is interrupted, it is difficult for the application server to determine the data of the target file received by the user terminal based on the information, and thus it is difficult to continue sending the data which is not obtained yet to the user terminal. The compressed file generated in the embodiment of the invention is generated after the target file is compressed with the compression level of 0, so that after the compressed file is generated by compression, the data volume of the target file contained in the compressed file is equal to the original data volume of the target file, and before the target file is compressed, the application server can directly predict and obtain the information such as the offset of each target file in the compressed file, the data volume of each target file in the compressed file, and the like. Therefore, after the process of sending data to the user terminal by the application server is interrupted, based on the predicted various information and the third data amount fed back by the user terminal, the application server can determine the data of the target file received by the user terminal, so that the data which is not obtained yet can be continuously sent to the user terminal, and the embodiment of the invention supports continuous downloading after the interruption of the file downloading process.
In one embodiment of the invention, the apparatus further comprises:
the verification code obtaining module is used for obtaining the verification code of the target file from the file server;
the first data sending module 905 is specifically configured to:
and sending the data, the file fragments and the check codes of the target file to the user side so that the user side generates a compressed file containing the target file based on the received data, the file fragments and the check codes to finish the downloading process of the target file.
Corresponding to the file downloading method applied to the user side, the embodiment of the invention also provides a file downloading device applied to the user side.
Referring to fig. 10, a schematic structural diagram of a second file downloading device according to an embodiment of the present invention is applied to a user terminal, where the device includes:
a first request sending module 1001, configured to send a first file request for requesting to download a target file to an application server;
a data amount obtaining module 1002, configured to obtain a second data amount of a predicted compressed file to be obtained, where the second data amount is sent by the application server, and the compressed file is: compressing the target file with the compression grade of 0;
A first data receiving module 1003, configured to receive data of a target file and a file segment sent by the application server, where the file segment includes: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
the file generating module 1004 is configured to generate a compressed file including the target file based on the received data and the file fragment, and complete the downloading process of the target file.
As can be seen from the above, the compressed file includes the data obtained by compressing the target file and the file fragment, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the present invention, the data obtained by compressing the target file and included in the finally obtained compressed file is the same as the data originally included in the target file, and the application server does not need to compress and encode the target file after obtaining the target file from the file server, only needs to generate the file fragment included in the compressed file, and sends the file fragment and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragment to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
In one embodiment of the present invention, after the process of receiving the data and the file fragments of the target file sent by the application server is interrupted, the apparatus further includes:
the second request sending module sends a second file request for indicating to continue to download the target file to the application server, wherein the second file request carries a third data volume of the data received by the user terminal;
the second data receiving module is used for receiving the data of the target file which is sent by the application server and is not obtained yet and the file fragments;
and the second file generation module is used for generating a compressed file containing the target file based on the data and the file fragments received before and after the interruption, and completing the downloading process of the target file.
From the above, in the prior art, the compression of the target file with the compression level not being 0 is difficult for the application server to predict various information contained in the compressed file, so after the process of sending data to the user terminal by the application server is interrupted, it is difficult for the application server to determine the data of the target file received by the user terminal based on the information, and thus it is difficult to continue sending the data which is not obtained yet to the user terminal. The compressed file generated in the embodiment of the invention is generated after the target file is compressed with the compression level of 0, so that after the compressed file is generated by compression, the data volume of the target file contained in the compressed file is equal to the original data volume of the target file, and before the target file is compressed, the application server can directly predict and obtain the information such as the offset of each target file in the compressed file, the data volume of each target file in the compressed file, and the like. Therefore, after the process of sending data to the user terminal by the application server is interrupted, based on the predicted various information and the third data amount fed back by the user terminal, the application server can determine the data of the target file received by the user terminal, so that the data which is not obtained yet can be continuously sent to the user terminal, and the embodiment of the invention supports continuous downloading after the interruption of the file downloading process.
In one embodiment of the present invention, the first data receiving module is specifically configured to:
receiving data of a target file, a file fragment and a check code of the target file, which are sent by the application server;
the first file generation module is specifically configured to:
and generating a compressed file containing the target file based on the received data, the file fragments and the check code, and completing the downloading process of the target file.
The embodiment of the present invention further provides an electronic device, as shown in fig. 11, including a processor 1101, a communication interface 1102, a memory 1103 and a communication bus 1104, where the processor 1101, the communication interface 1102 and the memory 1103 complete communication with each other through the communication bus 1104,
a memory 1103 for storing a computer program;
the processor 1101 is configured to implement method steps of a file downloading method applied to an application server when executing a program stored in the memory 1103.
When the electronic device provided by the embodiment of the invention is applied to downloading files, the compressed files comprise data obtained by compressing the target files and file fragments, and because the compressed files are obtained by compressing the target files with the compression level of 0, the data obtained by compressing the target files and contained in the finally obtained compressed files are the same as the data originally contained in the target files, the application server does not need to compress and encode the target files after obtaining the target files from the file server, and only needs to generate file fragments contained in the compressed files and send the file fragments and the data of the target files to the user side, and the user side can directly combine the data of the target files and the file fragments to generate the compressed files. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
The embodiment of the present invention also provides another electronic device, as shown in fig. 12, including a processor 1201, a communication interface 1202, a memory 1203, and a communication bus 1204, where the processor 1201, the communication interface 1202, and the memory 1203 perform communication with each other through the communication bus 1204,
a memory 1203 for storing a computer program;
the processor 1201 is configured to implement method steps of a file downloading method applied to a user terminal when executing a program stored in the memory 1203.
When the electronic device provided by the embodiment of the invention is applied to downloading files, the compressed files comprise data obtained by compressing the target files and file fragments, and because the compressed files are obtained by compressing the target files with the compression level of 0, the data obtained by compressing the target files and contained in the finally obtained compressed files are the same as the data originally contained in the target files, the application server does not need to compress and encode the target files after obtaining the target files from the file server, and only needs to generate file fragments contained in the compressed files and send the file fragments and the data of the target files to the user side, and the user side can directly combine the data of the target files and the file fragments to generate the compressed files. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processor, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, there is further provided a computer readable storage medium, in which a computer program is stored, the computer program implementing the file downloading method applied to an application server according to any one of the above embodiments when executed by a processor.
When the computer program stored in the computer readable storage medium provided by the embodiment is used for downloading a file, the compressed file contains data obtained by compressing the target file and file fragments, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the invention, the data contained in the finally obtained compressed file and obtained by compressing the target file are the same as the data originally contained in the target file, the application server does not need to perform compression coding on the target file after obtaining the target file from the file server, only needs to generate the file fragments contained in the compressed file, and sends the file fragments and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragments to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
In still another embodiment of the present invention, a computer readable storage medium is provided, where a computer program is stored, where the computer program is executed by a processor to implement a file downloading method applied to a client according to any one of the foregoing embodiments.
When the computer program stored in the computer readable storage medium provided by the embodiment is used for downloading a file, the compressed file contains data obtained by compressing the target file and file fragments, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the invention, the data contained in the finally obtained compressed file and obtained by compressing the target file are the same as the data originally contained in the target file, the application server does not need to perform compression coding on the target file after obtaining the target file from the file server, only needs to generate the file fragments contained in the compressed file, and sends the file fragments and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragments to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform the file downloading method applied to an application server as set forth in any one of the above embodiments.
When the computer program product file downloading provided by the embodiment is executed, the compressed file contains data obtained by compressing the target file and file fragments, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the invention, the data obtained by compressing the target file and contained in the finally obtained compressed file are the same as the data originally contained in the target file, the application server does not need to compress and encode the target file after obtaining the target file from the file server, and only needs to generate file fragments contained in the compressed file, and send the file fragments and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragments to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
In yet another embodiment of the present invention, a computer program product containing instructions that, when executed on a computer, cause the computer to perform the file downloading method applied to a client according to any of the foregoing embodiments is also provided.
When the computer program product file downloading provided by the embodiment is executed, the compressed file contains data obtained by compressing the target file and file fragments, and because the compressed file is obtained by compressing the target file with the compression level of 0 in the embodiment of the invention, the data obtained by compressing the target file and contained in the finally obtained compressed file are the same as the data originally contained in the target file, the application server does not need to compress and encode the target file after obtaining the target file from the file server, and only needs to generate file fragments contained in the compressed file, and send the file fragments and the data of the target file to the user side, and the user side can directly combine the data of the target file and the file fragments to generate the compressed file. In this period, the application server is equivalent to forwarding only the data of the target file, and the data of the target file is not required to be stored, so that the waste of storage resources of the application server can be reduced in the process of transmitting the target file by applying the embodiment of the invention. And because the application server does not need to compress and encode the target file, the data computing resource consumed in the process of compressing the target file by the application server is saved, and the efficiency of file transmission is improved. If the number of the target files is multiple, the multiple target files can be synchronously transmitted, a compressed file is generated in the user side, and under the condition that the user side has a limit on the number of synchronously downloaded files, the compressed file obtained by jointly compressing the multiple target files can be generated, which is equivalent to jointly completing the downloading process of the multiple target files.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for a system, apparatus, electronic device, computer readable storage medium and computer program product, the description is relatively simple as it is substantially similar to the method embodiments, as relevant points are found in the partial description of the method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (13)

1. A method for downloading a file, the method being applied to an application server, the method comprising:
after a first file request which is sent by a user side and is used for requesting to download a target file is acquired, predicting second data quantity of a compressed file to be generated and offset of each target file in the compressed file according to first data quantity of the target file and file name length of the target file, wherein the compressed file is as follows: and compressing the target file with the compression level of 0, wherein the offset is as follows: the position of the first byte of the target file in the compressed file;
the second data volume is sent to the user side, so that the user side determines the second data volume of the obtained compressed file;
acquiring data of a target file from a file server storing the file in the form of a file stream;
generating a file fragment of the compressed file based on the first data amount, the file name length, and the offset, the file fragment comprising: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
And sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file containing the target file based on the received file fragments and the data to finish the downloading process of the target file.
2. The method of claim 1, wherein after the interruption of the process of sending the file segments and the data of the target file to the client, the method further comprises:
receiving a second file request sent by the user side and representing the continuous downloading of the target file, wherein the second file request carries a third data volume of the data received by the user side;
determining the position of the data received by the user side in the compressed file based on the third data amount, the first data amount and the file name length;
acquiring data which are contained in the target file and are not acquired by the user side from the file server in the form of a file stream based on the determined position;
generating file fragments of the compressed file, which are not obtained by the user side, based on the first data volume, the file name length and the offset;
and sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file based on the file fragments and the data received before and after the interruption to finish the downloading process of the target file.
3. The method according to claim 1 or 2, wherein before the sending the data of the file segment and the target file to the user terminal, so that the user terminal generates a compressed file containing the target file based on the received file segment and the data, the method further comprises:
acquiring a check code of the target file from the file server;
the step of sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file containing the target file based on the received file fragments and the data, and the step of completing the downloading process of the target file comprises the following steps:
and sending the data, the file fragments and the check codes of the target file to the user side so that the user side generates a compressed file containing the target file based on the received data, the file fragments and the check codes to finish the downloading process of the target file.
4. A method for downloading a file, the method being applied to a user terminal, the method comprising:
sending a first file request for requesting to download a target file to an application server;
Obtaining a second data amount of the predicted compressed file to be obtained, wherein the second data amount is sent by the application server, and the compressed file is: compressing the target file with the compression grade of 0;
receiving data of a target file and a file fragment sent by the application server, wherein the file fragment comprises: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
and generating a compressed file containing the target file based on the received data and the file fragment, and completing the downloading process of the target file.
5. The method of claim 4, wherein after the process of receiving the data of the target file and the file segments transmitted by the application server is interrupted, the method further comprises:
sending a second file request for representing the continuous downloading of the target file to the application server, wherein the second file request carries a third data volume of the data received by the user terminal;
receiving data of a target file which is sent by the application server and is not obtained yet and file fragments;
And generating a compressed file containing the target file based on the data and the file fragments received before and after the interruption, and completing the downloading process of the target file.
6. The method according to claim 4 or 5, wherein the receiving the data of the target file and the file fragment sent by the application server includes:
receiving data of a target file, a file fragment and a check code of the target file, which are sent by the application server;
the generating, based on the received data and the file segments, a compressed file containing the target file includes:
and generating a compressed file containing the target file based on the received data, the file fragments and the check code, and completing the downloading process of the target file.
7. The file downloading system is characterized by comprising a user side and an application server;
the user terminal is used for sending a first file request for requesting to download the target file to the application server;
the application server is used for predicting the second data amount of the compressed file to be generated and the offset of each target file in the compressed file according to the first data amount of the target file and the file name length of the target file; transmitting the second data amount to the user terminal; acquiring data of a target file from a file server storing the file in the form of a file stream; generating a file fragment of the compressed file based on the first data amount, the file name length, and the offset; and sending the data of the file fragments and the target file to the user side, wherein the compressed file is: and compressing the target file with the compression level of 0, wherein the offset is as follows: the first byte of the target file is located in the compressed file, and the file fragment comprises: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
The user side is used for generating a compressed file containing the target file based on the received data and the file fragments, and completing the downloading process of the target file.
8. The system of claim 7, wherein after the transmission of the data and file fragments of the target file between the application server and the client is interrupted;
the user side is further configured to send a second file request to the application server, where the second file request carries a third data amount of data received by the user side;
the application server is further configured to determine, based on the third data amount, the first data amount, and the file name length, a location of the data received by the user terminal in the compressed file; acquiring data which are contained in the target file and are not acquired by the user side from the file server in the form of a file stream based on the determined position; generating file fragments of the compressed file, which are not obtained by the user side, based on the first data volume, the file name length and the offset; transmitting the file fragments and the data of the target file to the user side;
The user side is further configured to generate a compressed file containing the target file based on the data and the file fragments received before and after the interruption, so as to complete the downloading process of the target file.
9. The system of claim 7 or 8, wherein the application server is further configured to:
acquiring a check code of the target file from the file server;
the application server is specifically configured to send the data, the file fragment and the check code of the target file to the user terminal;
the user side is specifically configured to generate a compressed file containing the target file based on the received data, the file fragment and the check code, and complete the downloading process of the target file.
10. A file downloading apparatus for application to an application server, the apparatus comprising:
the data quantity prediction module is used for predicting second data quantity of a compressed file to be generated and offset of each target file in the compressed file according to the first data quantity of the target file and the file name length of the target file after acquiring a first file request which is sent by a user and is used for requesting to download the target file, wherein the compressed file is: and compressing the target file with the compression level of 0, wherein the offset is as follows: the position of the first byte of the target file in the compressed file;
The data volume sending module is used for sending the second data volume to the user side so that the user side can determine the second data volume of the obtained compressed file;
a first data acquisition module for acquiring data of a target file from a file server storing the file in the form of a file stream;
a first segment generation module, configured to generate a file segment of the compressed file based on the first data amount, a file name length, and the offset, where the file segment includes: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
and the first data sending module is used for sending the data of the file fragments and the target file to the user side so that the user side generates a compressed file containing the target file based on the received file fragments and the data and finishes the downloading process of the target file.
11. A file downloading apparatus, applied to a user terminal, comprising:
the first request sending module is used for sending a first file request for requesting to download the target file to the application server;
the data volume obtaining module is used for obtaining a second data volume of the predicted compressed file to be obtained, which is sent by the application server, wherein the compressed file is: compressing the target file with the compression grade of 0;
The first data receiving module is configured to receive data of a target file and a file fragment sent by the application server, where the file fragment includes: file tail for describing the position of the target file in the compressed file and file header for describing different target files respectively;
and the first file generation module is used for generating a compressed file containing the target file based on the received data and the file fragments, and completing the downloading process of the target file.
12. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-3 or 4-6 when executing a program stored on a memory.
13. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-3 or 4-6.
CN202111613886.3A 2021-12-27 2021-12-27 File downloading method, system and device Active CN114422499B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111613886.3A CN114422499B (en) 2021-12-27 2021-12-27 File downloading method, system and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111613886.3A CN114422499B (en) 2021-12-27 2021-12-27 File downloading method, system and device

Publications (2)

Publication Number Publication Date
CN114422499A CN114422499A (en) 2022-04-29
CN114422499B true CN114422499B (en) 2023-12-05

Family

ID=81269060

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111613886.3A Active CN114422499B (en) 2021-12-27 2021-12-27 File downloading method, system and device

Country Status (1)

Country Link
CN (1) CN114422499B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103051723A (en) * 2012-12-27 2013-04-17 广州市动景计算机科技有限公司 Increment updating method as well as server and terminal
CN103685470A (en) * 2013-11-19 2014-03-26 Tcl光电科技(惠州)有限公司 Browser-based remote control method and system, and browser and application server
WO2015085939A1 (en) * 2013-12-12 2015-06-18 北京奇虎科技有限公司 File transfer method, device, and system
CN104737121A (en) * 2012-09-04 2015-06-24 谷歌公司 In browser muxing and demuxing for video playback
CN106575263A (en) * 2014-08-05 2017-04-19 高通股份有限公司 Cache line compaction of compressed data segments
WO2017198079A1 (en) * 2016-05-20 2017-11-23 广州优视网络科技有限公司 File download method and apparatus, user terminal and machine-readable storage medium
CN109495271A (en) * 2018-10-19 2019-03-19 北京梆梆安全科技有限公司 Compare APK file method, apparatus, server and its storage medium
CN109981751A (en) * 2019-03-06 2019-07-05 珠海金山网络游戏科技有限公司 A kind of document transmission method and system, computer equipment and storage medium
CN110572422A (en) * 2018-06-06 2019-12-13 北京京东尚科信息技术有限公司 Data downloading method and device
CN110944003A (en) * 2019-12-06 2020-03-31 北京数码视讯软件技术发展有限公司 File transmission method and electronic equipment
CN112491832A (en) * 2020-11-16 2021-03-12 中国银联股份有限公司 File transmission method and device
CN113568742A (en) * 2021-07-22 2021-10-29 四川英得赛克科技有限公司 File compression method, device and system, electronic equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10963521B2 (en) * 2016-12-22 2021-03-30 Vmware, Inc. Handling large streaming file formats in web browsers
US20210144226A1 (en) * 2019-11-13 2021-05-13 Microsoft Technology Licensing, Llc Partial downloads of compressed data

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104737121A (en) * 2012-09-04 2015-06-24 谷歌公司 In browser muxing and demuxing for video playback
CN103051723A (en) * 2012-12-27 2013-04-17 广州市动景计算机科技有限公司 Increment updating method as well as server and terminal
CN103685470A (en) * 2013-11-19 2014-03-26 Tcl光电科技(惠州)有限公司 Browser-based remote control method and system, and browser and application server
WO2015085939A1 (en) * 2013-12-12 2015-06-18 北京奇虎科技有限公司 File transfer method, device, and system
CN106575263A (en) * 2014-08-05 2017-04-19 高通股份有限公司 Cache line compaction of compressed data segments
WO2017198079A1 (en) * 2016-05-20 2017-11-23 广州优视网络科技有限公司 File download method and apparatus, user terminal and machine-readable storage medium
CN110572422A (en) * 2018-06-06 2019-12-13 北京京东尚科信息技术有限公司 Data downloading method and device
CN109495271A (en) * 2018-10-19 2019-03-19 北京梆梆安全科技有限公司 Compare APK file method, apparatus, server and its storage medium
CN109981751A (en) * 2019-03-06 2019-07-05 珠海金山网络游戏科技有限公司 A kind of document transmission method and system, computer equipment and storage medium
CN110944003A (en) * 2019-12-06 2020-03-31 北京数码视讯软件技术发展有限公司 File transmission method and electronic equipment
CN112491832A (en) * 2020-11-16 2021-03-12 中国银联股份有限公司 File transmission method and device
CN113568742A (en) * 2021-07-22 2021-10-29 四川英得赛克科技有限公司 File compression method, device and system, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN114422499A (en) 2022-04-29

Similar Documents

Publication Publication Date Title
KR101745456B1 (en) Ecu for transmitting large data in hil test environment, system including the same and method thereof
EP2717476A1 (en) Data processing method and data processing device
CN109756536A (en) A kind of method, apparatus and system of data transmission
CN111262876B (en) Data processing method, device and equipment based on block chain and storage medium
US10817460B2 (en) RDMA data sending and receiving methods, electronic device, and readable storage medium
CN103873507A (en) Data block uploading and storing system and method
CN110647490B (en) Data transmission method, device, equipment and computer storage medium
CN109086307B (en) File processing method and device
CN106685429B (en) Integer compression method and device
CN108092956B (en) Method and device for acquiring compression dictionary
CN111708743A (en) File storage management method, file management client and file storage management system
CN112286565B (en) Embedded system differential upgrading method based on storage container
CN110324681B (en) Slicing method, device, storage medium and transmission system of multimedia data
CN116800796A (en) Method, device, equipment and medium for transmitting internet of vehicles data
CN113726341B (en) Data processing method and device, electronic equipment and storage medium
CN111198885A (en) Data processing method and device
CN114422499B (en) File downloading method, system and device
US10803018B2 (en) Compressed data rearrangement to optimize file compression
CN112235422B (en) Data processing method and device, computer readable storage medium and electronic device
CN115834604A (en) Data transmitting terminal, data receiving terminal, synchronization method and computer program product
CN111800223A (en) Method, device and system for generating sending message and processing receiving message
WO2021036189A1 (en) Rdma data sending and receiving methods, electronic device and readable storage medium
CN107203559B (en) Method and device for dividing data strips
CN115904488A (en) Data transmission method, system, device and equipment
CN108011952B (en) Method and device for acquiring compression dictionary

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant