CN113411404A - File downloading method, device, server and storage medium - Google Patents

File downloading method, device, server and storage medium Download PDF

Info

Publication number
CN113411404A
CN113411404A CN202110707632.1A CN202110707632A CN113411404A CN 113411404 A CN113411404 A CN 113411404A CN 202110707632 A CN202110707632 A CN 202110707632A CN 113411404 A CN113411404 A CN 113411404A
Authority
CN
China
Prior art keywords
file
fragment
downloading
target
target file
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.)
Withdrawn
Application number
CN202110707632.1A
Other languages
Chinese (zh)
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202110707632.1A priority Critical patent/CN113411404A/en
Publication of CN113411404A publication Critical patent/CN113411404A/en
Withdrawn legal-status Critical Current

Links

Images

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/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • H04L67/1078Resource delivery mechanisms
    • H04L67/108Resource delivery mechanisms characterised by resources being split in blocks or fragments
    • 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/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • H04L67/1078Resource delivery mechanisms
    • H04L67/1085Resource delivery mechanisms involving dynamic management of active down- or uploading connections

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application relates to the field of data processing, and discloses a file downloading method, a file downloading device, a file downloading server and a storage medium, wherein the method comprises the following steps: when a file downloading request submitted by a browser is detected, determining a target file to be downloaded according to the file downloading request, and calling a plurality of threads to perform fragment downloading or fragment transmission on the target file. In the process of calling a plurality of multiple threads to download or transmit the target file in a slicing mode, if the downloading or transmitting process is interrupted, slicing information of the target file is obtained, the target slicing file which is not downloaded successfully is determined according to the slicing information, and then the target slicing file is downloaded or transmitted by calling the multiple threads. The present application relates to a block chain technology, and for example, the above-mentioned fragmentation information can be written into a block chain, which can ensure faster data acquisition.

Description

File downloading method, device, server and storage medium
Technical Field
The present application relates to the field of data processing, and in particular, to a file downloading method, apparatus, server, and storage medium.
Background
File downloading is a problem frequently encountered in daily life of people, for small files, a user can easily download the small files regardless of a browser or a client, but for large files, most of the small files need to be downloaded by a single client, or download the large files based on a plug-in, when the downloading is interrupted due to a network problem, if the user wants to continue downloading the large files, the whole file needs to be downloaded from beginning to end, the file downloading efficiency is low, and resources are wasted.
Therefore, how to improve the downloading efficiency of the file on the browser on the basis of not installing the client and installing the plug-in becomes an urgent technical problem to be solved.
Disclosure of Invention
The embodiment of the application provides a file downloading method, a file downloading device, a server and a storage medium, which can improve the file downloading efficiency and save time and resources.
One aspect of the embodiments of the present application discloses a file downloading method, including:
when a file downloading request submitted by a browser is detected, determining a target file to be downloaded according to the file downloading request, and calling a plurality of threads to perform fragment downloading or fragment transmission on the target file;
in the process of calling the multiple threads to perform fragment downloading or fragment transmission on the target file, if the downloading or transmission process is interrupted, fragment information of the target file is acquired, wherein the fragment information comprises information of a fragment file distributed for each thread in the multiple threads and downloading progress of each thread on the distributed fragment file, and the fragment file is obtained by performing fragment processing on the target file;
according to the fragment information, determining an unsuccessfully downloaded target fragment file from the fragment files distributed for each thread in the multiple threads;
and calling the multiple threads to download or transmit the target fragment file.
An embodiment of the present application discloses a file downloading device, which includes:
the processing unit is used for determining a target file to be downloaded according to a file downloading request when the file downloading request submitted by the browser is detected, and calling a plurality of threads to perform fragment downloading or fragment transmission on the target file;
an obtaining unit, configured to obtain fragmentation information of the target file if a downloading or transmission process is interrupted during a process of calling the multiple threads to perform fragmentation downloading or fragmentation transmission on the target file, where the fragmentation information includes information of a fragmentation file allocated to each of the multiple threads and a downloading progress of the allocated fragmentation file by each thread, and the fragmentation file is obtained by performing fragmentation processing on the target file;
a determining unit, configured to determine, according to the fragmentation information, an unsuccessfully downloaded target fragmentation file from the fragmentation files allocated to each of the multiple threads;
the processing unit is further configured to invoke the multiple threads to download or transmit the target fragment file.
An embodiment of the present application discloses a server, which includes:
a processor adapted to implement one or more computer programs; and the number of the first and second groups,
a computer storage medium storing one or more computer programs adapted to be loaded by the processor and to perform the above-described file download method.
In one aspect, the present application discloses a computer-readable storage medium, which stores one or more computer programs adapted to be loaded by a processor and execute the above file downloading method.
An aspect of the embodiments of the present application discloses a computer program product or a computer program, where the computer program product includes a computer program, and the computer program is stored in a computer readable storage medium. The processor of the server reads the computer program from the computer-readable storage medium, and executes the computer program, so that the server executes the file download method described above.
In the embodiment of the application, when a server detects a file downloading request submitted by a browser, a target file to be downloaded is determined according to the file downloading request, whether the target file is fragmented or not is judged firstly, if yes, a plurality of threads are directly called to perform fragmentation downloading or fragmentation transmission on the target file, if not, fragmentation processing is performed on the target file, and then the plurality of threads are called to perform fragmentation downloading or fragmentation transmission on the target file. In the process of calling a plurality of multiple threads to download or transmit the target file in a slicing manner, if the downloading or transmitting process is interrupted, the slicing information of the target file is obtained, the target slicing file which is not downloaded successfully is determined according to the slicing information, then a plurality of threads are called to download or transmit the target slicing file, and the operation is repeated until the target file is downloaded or transmitted.
Drawings
In order to more clearly illustrate the embodiments of the present application 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, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of an architecture of a file downloading system disclosed in an embodiment of the present application;
fig. 2 is a schematic flowchart of a file downloading method disclosed in an embodiment of the present application;
FIG. 3 is a schematic flowchart illustrating a parallel downloading process of a target file according to an embodiment of the present disclosure;
FIG. 4 is a schematic flowchart illustrating a serial download of a target file according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating another file downloading method disclosed in an embodiment of the present application;
FIG. 6 is a schematic structural diagram of a file downloading device disclosed in an embodiment of the present application;
fig. 7 is a schematic structural diagram of a server disclosed in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a file downloading system according to an embodiment of the present disclosure, as shown in fig. 1, the file downloading system 100 may include a terminal device 101, a server 102, and a server 103, where the terminal device 101 may send a file downloading request to the server 102, the server 102 may be a server directly communicating with the terminal device 101, and the server 103 may be a server directly communicating with the server 102, and in an embodiment of the present disclosure, the server 102 may obtain data corresponding to the file downloading request from the server 103. It should be noted that the communication connection includes a wireless connection and a wired connection, which is not limited herein.
In one possible implementation manner, the terminal device 101 may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart car, and the like; the server 102 and the server 103 may be independent physical servers, may also be a server cluster or a distributed system formed by a plurality of physical servers, and may also be cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and big data and artificial intelligence platforms. Optionally, in this embodiment of the application, the device for implementing the function of the terminal device 101 may be a smart phone or other devices; it may also be an apparatus, such as a system-on-chip, capable of supporting the terminal device to implement the function, and the apparatus may be installed in the terminal device.
In a possible implementation manner, when detecting a file downloading request submitted by a browser corresponding to the terminal device 101, the server 102 determines a target file to be downloaded according to the file downloading request, first determines whether the target file is fragmented, if so, directly invokes a plurality of threads to perform fragment downloading or fragment transmission on the target file from the server 103, otherwise, performs fragment processing on the target file, and then invokes the plurality of thread servers 103 to perform fragment downloading or fragment transmission on the target file. In the process of calling a plurality of multiple threads to download or transmit the target file in a slicing manner, if the downloading or transmitting process is interrupted, the slicing information of the target file is obtained, the target slicing file which is not downloaded successfully is determined according to the slicing information, then a plurality of threads are called to download or transmit the target slicing file, and the operation is repeated until the target file is downloaded or transmitted.
In some feasible scenarios, one terminal device 101 may submit a plurality of file downloading requests through a browser, so as to obtain a plurality of lower target files, and return each target file to the client terminal 101 to be displayed in a browser interface; or, in another possible scenario, multiple different terminal devices 101 may send a file download request to the corresponding server 102 through corresponding browsers, then download an object file corresponding to the file download request from the same server 103 according to the download request, and return the object file to different terminal devices 101 and display the object file on a browser interface. Each target file on the browser interface displays a progress bar to display the downloading progress of the target file, and a user of the client terminal 101 can check the downloading progress of the target file in real time through the progress bar.
Based on the file downloading system, an embodiment of the present application discloses a file downloading method, please refer to fig. 2, which is a schematic flow diagram of the file downloading method disclosed in the embodiment of the present application, and the file downloading method may be executed by a server or a browser. The file downloading method may specifically include the following steps S201 to S204:
s201, when a file downloading request submitted by a browser is detected, determining a target file to be downloaded according to the file downloading request, and calling a plurality of threads to perform fragment downloading or fragment transmission on the target file.
The file downloading request may be a first downloading request for a certain target file submitted through the browser, or may be a "continuous downloading" downloading request submitted through the browser when the server is interrupted. On the browser interface, the user can select the download address of the target file, and for the file downloaded for the first time, the user clicks the download control after selecting the address. For the file downloaded after interruption, the server may automatically resume downloading or transmitting according to the network condition, or the user may click the "continue downloading" control after selecting the address in the browser interface, and then submit the file to the server for downloading or transmitting. Of course, the user can also click the "pause downloading" control to pause the downloading of the target file.
In a possible implementation manner, after receiving the sent file download request, the server may specifically be a file download request carrying a Uniform Resource Locator (URL) in the next file, and then parse the URL to determine the target file to be downloaded. Furthermore, the server acquires the target file from the corresponding internet address according to the submitted file downloading request, wherein the types of the target file comprise various types, such as videos, documents, pictures and the like. Specifically, in the embodiment of the present application, the server invokes a plurality of threads to perform fragment downloading or fragment transmission on the target file.
In a possible implementation manner, before the server invokes a plurality of threads to perform fragment downloading or fragment transmission on the target file, the server first needs to determine whether the target file has been fragment-processed, which may be understood that the target file that is not first downloaded has been fragment-processed in the previous downloading process, and the fragment information is successfully stored in the database and the local cache of the server. After the target file is determined, acquiring historical fragment information of whether the target file exists or not from a local cache or a database of the server firstly, wherein the historical fragment information comprises the file size, the fragment number, the file size of each fragment and a historical storage position (which is equivalent to judging whether the file to be downloaded is fragmented or not, and if the file to be downloaded is fragmented, backup information exists); if the server finds that the target file is not fragmented, the target file is a new file to be downloaded, and the server can perform fragmentation processing on the target file.
The slicing processing step may include: the server fragments the target file according to a preset rule submitted by a developer to obtain a plurality of fragment files, wherein the preset rule is self-defined by the developer in a development process, and in some feasible embodiments, the preset rule can be carried in a file downloading request or pre-configured and stored in the server. The preset rule may be fixed, where the segment 1 is 20M, the segment 2 is 30M, and the segment 3 is 25M, and each target file may be segmented according to the segment size, so that the size of each segment is configured in advance, and the processing time of the server may be saved. In some optional manners, the preset rules may also be different, and the preset rules may be set according to the size of the target file. For example, when the size of the target file is larger than a specified threshold, the size of the target file is sliced according to a first length, such as 500 Mb; when the size of the target file is smaller than or equal to a specified threshold, the size of the target file is sliced according to a second length, such as 100 Mb; or in some possible implementation manners, when the size of the target file is a certain smaller value, the target file is divided into one fragmented file, which is equivalent to not fragmenting the target file. The preset rules may be several sets, and may be determined according to the type of the target file, and when the target file is a video type, the preset rule 1 may be adopted, and when the target file is a document type, the preset rule 2 may be adopted, and so on.
In the embodiment of the application, one execution of a program can be regarded as one process, and one process comprises a plurality of threads, namely, the downloading of one file can be regarded as one process, the file is composed of a plurality of fragment files, and the fragment files are downloaded by different threads respectively.
S202, in the process of calling a plurality of threads to carry out fragment downloading or fragment transmission on the target file, if the downloading or transmission process is interrupted, fragment information of the target file is obtained.
In this embodiment of the present application, the obtained fragment information of the target file may specifically include: the method comprises the steps of distributing fragment file information for each thread in a plurality of threads, and downloading progress of each thread to the distributed fragment files, wherein the fragment files are obtained by carrying out fragment processing on target files. The fragmentation information may further include: the number of fragmented files that have been downloaded, the number of fragmented files, etc.
In a possible implementation manner, when a plurality of threads are called to perform fragment downloading or fragment transmission on a target file, a transmission or downloading interruption situation may occur due to a network problem or a user operation, and if the downloading or transmission process is interrupted, the server may obtain fragment information of the target file when a file downloading request submitted by the browser is detected again.
In another implementation, a "continue downloading" control is provided on a specific browser interface, and after a user clicks the control on the browser interface, first prompt information is displayed on the interface for prompting the user to continue downloading and prompting the user to download a storage path of a target file.
Or, in another implementation manner, after the user clicks the "continue downloading" control on the browser interface and switches the storage path, second prompt information is further displayed on the browser interface to prompt the user that the storage path of the target file has been changed and whether the change is confirmed, if the user does not change, the server determines, in the same manner, the target fragmented file which is not successfully downloaded according to the fragment information. If the user confirms to change the path, the server acquires the storage path of the target file when detecting the instruction of continuing downloading, and acquires the fragment information of the target file when the acquired storage path is inconsistent with the recorded storage path (namely the original storage path) of the target file, and the storage path is changed, so that the whole target file needs to be downloaded again.
And S203, according to the fragment information, determining the target fragment file which is not downloaded successfully from the fragment files distributed for each thread in the multiple threads.
In a specific implementation process, if the user selects to continue downloading the target file and the path of the target file is not changed, the server may determine, according to the fragment information of the target file, the target fragment file that is not successfully downloaded from the fragment files allocated to each of the multiple threads. If the user changes the storage path of the target file, the target fragmented file is all fragmented files (whole target file) of the target file, and if the user does not change the storage path of the target file, the target fragmented file is the fragmented file which is not downloaded successfully. For example, there are 10 fragmented files (10 fragmented files divided according to the beginning of time), where the download progress of the first 6 fragmented files is 100%, it can be determined that the download of the first 6 fragmented files is completed, the download progress of the later 4 fragmented files is 14%, 68%, 35% and 45%, it can be determined that the download of the later 4 fragmented files is not completed, and further, the later 4 fragmented files can be determined as the target fragmented files whose download is not completed.
And S204, calling a plurality of threads to download or transmit the target fragment file.
In a specific implementation process, the server may invoke multiple threads to download the determined target fragment file until all target fragment files are downloaded, so as to obtain the target file. The corresponding downloading modes when the multiple threads are used for downloading comprise two modes, wherein one mode is parallel downloading, and the other mode is serial downloading.
The parallel downloading is to queue each fragment file in sequence, and download by using a plurality of threads, wherein the number of threads is equal to the number of threads, and the number of threads is equal to the number of threads. According to the running memory of the server, the set threads are limited, and if the number of the threads is too large, the load is brought to the server. The number of the fragment files is often larger than the number of the threads, under the condition, a plurality of fragment files need to be queued, a plurality of fragment files are downloaded simultaneously, after downloading of one thread is completed, one fragment file which is not downloaded is downloaded by the thread, after downloading of all threads is completed, the downloaded fragment files are combined, a folder specially used for storing the downloaded fragment files is arranged on the browser, and all the fragment files can be combined, so that the complete downloaded file is obtained. For example, there are 10 fragmented files, but there are only 6 threads provided by the server, then the server downloads the first 6 fragmented files in parallel, when one thread finishes downloading, the seventh fragmented file is added to the thread for downloading, and the same is true for the other fragmented files, until all 10 fragmented files are downloaded, the server combines the 10 fragmented files in sequence to obtain the completed target file. The front-end user sees a progress bar, the progress bar is 0% at first, and after the downloading is completed, the progress bar becomes 100%, which indicates that the target file has been downloaded, and the target file is obtained. This approach is suitable for some browsers with relatively high configurations. It should be noted that in the process of invoking multiple threads to download the target fragment file or the target file in parallel, under the situation that there are many files downloaded by the threads, the server needs to determine an idle thread in the multiple threads first and then invoke the idle thread to download the target fragment file or the target file in parallel.
As shown in fig. 3, which is a schematic flow diagram of parallel downloading of an object file disclosed in an embodiment of the present application, in a process of downloading an object file, each time a server completes downloading or transmission of one thread, the server stores a fragmented file completed by the thread in a database, and sends the fragmented file completed by downloading to a browser, so that the browser also performs corresponding recording, and the browser performs a recorded downloading condition by using a random file. The information recorded in the database and the front end comprises the serial number of the fragment file after downloading and the total downloading progress of the file to be downloaded. The downloading progress of the target file is recorded in the database and the browser at any time, so that the downloading progress of the target file can be monitored in real time, and if downloading interruption occurs, the server can respond in time.
The above serial downloading is to arrange each fragment file in order and sequentially download by using a thread, the thread can be understood as a target thread, the fragment file 1 is downloaded at a first time, the target thread can be correspondingly called as thread 1, that is, the thread 1 and the fragment file 1 have a corresponding relationship, the fragment file 2 is downloaded at a second time, the target thread can be correspondingly called as thread 2, that is, the thread 2 and the fragment file 2 have a corresponding relationship, and the serial downloading is performed on the target file until all the fragment files are downloaded, the target file does not need to be combined after the downloading is completed, and the complete downloading file is obtained after the downloading is completed, that is, the target file. This approach is suitable for most browsers.
As shown in fig. 4, which is a schematic flowchart of a serial download process of a target file disclosed in an embodiment of the present application, in a download process of the target file, each thread is also stored, so as to implement real-time monitoring of a download progress of the target file.
After the interruption occurs in the transmission or downloading process, the user selects to continue downloading the target file, the storage path is not changed, the server does not download the whole target file again, but continues downloading or transmitting the target fragment file which is not successfully downloaded.
Or before the downloading interruption does not occur, the downloading mode when the server calls a plurality of threads to download the target file also comprises two modes, wherein one mode is parallel downloading, and the other mode is serial downloading. The specific implementation process is the same as above.
In the embodiment of the application, when a server detects a file downloading request submitted by a browser, a target file to be downloaded is determined according to the file downloading request, and a plurality of threads are called to perform fragment downloading or fragment transmission on the target file; in the process of calling a plurality of multiple threads to download or transmit the target file in a slicing manner, if the downloading or transmitting process is interrupted, the slicing information of the target file is obtained, the target slicing file which is not downloaded successfully is determined according to the slicing information, then a plurality of threads are called to download or transmit the target slicing file, and the operation is repeated until the target file is downloaded or transmitted.
Based on the file downloading method, an embodiment of the present application discloses another file downloading method, please refer to fig. 5, which is a flowchart illustrating another file downloading method disclosed in the embodiment of the present application. The file downloading method may specifically include steps S501-509:
s501, when a file downloading request submitted by the browser is detected, determining a target file to be downloaded according to the file downloading request.
S502, inquiring whether the database has a plurality of fragment files of the target file.
The step is to determine whether the target file has been fragmented, if yes, backup information of the target file, that is, fragmentation information, is stored in the local caches of the database and the server.
And S503, if the database is stored in the plurality of fragment files of the target file, calling a plurality of threads to perform fragment downloading or fragment transmission on the plurality of fragment files of the target file.
If the target file is determined to be fragmented, the fragmented file can be directly obtained, and multithreading is called to perform fragment downloading or fragment transmission on the target file, so that the time for downloading the target file can be effectively saved.
S504, if the database does not have a plurality of fragment files of the target file, the target file is subjected to fragment processing, and a plurality of threads are called to perform fragment downloading or fragment transmission on the plurality of fragment files of the target file subjected to fragment processing.
If the target file is determined not to be subjected to fragmentation processing, the server can perform fragmentation processing on the target file to determine fragmentation information of the target file, and then a plurality of threads are invoked to perform fragmentation downloading or fragmentation transmission on a plurality of fragmentation files of the target file subjected to fragmentation processing. The application can be realized by firstly fragmenting and then downloading, if the interruption exists, the downloading can be continued from the interruption without downloading the whole target file, so that the file downloading time is saved, and the resources are saved.
And S505, if the downloading or transmission process is interrupted, acquiring the storage path of the target file when the file downloading request submitted by the browser is detected again.
S506, when the acquired storage path is consistent with the storage path of the recorded target file, the fragment information of the target file is acquired.
And S507, according to the fragment information, determining the target fragment file which is not downloaded successfully from the fragment files distributed for each thread in the multiple threads.
And S508, calling idle threads in the multiple threads to download or transmit the target fragment file.
Steps S501 to S508 have already been explained in detail in the related embodiment shown in fig. 2, and are not described again here.
Step S509, if the acquired storage path does not match the storage path of the recorded target file, step S503 is executed.
In step S509, the case that the target file needs to be downloaded again is indicated, so that the execution of step S503 needs to be started again, and it is determined whether there is an interruption or not during the downloading process, until the file downloading is completed, the target file is obtained and sent to the browser, so that the user can clearly see the file downloading condition, and after the downloading is completed, the "downloading is completed" can be correspondingly displayed on the browser interface.
The embodiment of the application describes a file downloading method more completely, and through the flow chart, the execution process including the determination of the target file, the confirmation of whether the target file is fragmented, the determination of the target fragmented file after the medium and short time and the like can be clearly seen. Meanwhile, the file is downloaded by calling a plurality of threads, so that the problems that a plurality of users download the same file at the same time, conflict and disorder are avoided and the like can be solved; the downloading process is stored in the database, and when the downloading is interrupted due to network abnormality or system abnormality and the like, the downloading can be continued through the database without the need of a user for downloading again, so that the problems of time waste, flow waste and the like are avoided.
Based on the above method embodiment, the embodiment of the present application further provides a schematic structural diagram of a file downloading device. Fig. 6 is a schematic structural diagram of a file downloading device according to an embodiment of the present application. The file download apparatus 600 shown in fig. 6 may operate as follows:
the processing unit 601 is configured to, when a file download request submitted by a browser is detected, determine a target file to be downloaded according to the file download request, and invoke multiple threads to perform fragment downloading or fragment transmission on the target file;
an obtaining unit 602, configured to obtain fragment information of the target file if a downloading or transmission process is interrupted during a process of calling the multiple threads to perform fragment downloading or fragment transmission on the target file, where the fragment information includes information of a fragment file allocated to each thread of the multiple threads and a downloading progress of the fragment file allocated to each thread, and the fragment file is obtained by performing fragment processing on the target file;
a determining unit 603, configured to determine, according to the fragment information, an unsuccessfully downloaded target fragment file from the fragment files allocated to each of the multiple threads;
the processing unit 601 is further configured to invoke the multiple threads to download or transmit the target fragment file.
In a possible implementation manner, the processing unit 601 invokes a plurality of threads to perform the fragment downloading on the target file, and may specifically be configured to:
calling the multiple threads to carry out parallel fragment downloading on the target file;
when there are multiple target fragment files, the processing unit 601 calls the multiple threads to download the target fragment files, which may be specifically configured to:
calling the multiple threads to download the target fragment file in parallel;
after the target fragment file is downloaded by calling the multiple threads in parallel, the method further comprises:
and combining the target fragmented files to obtain the target file.
In a possible implementation manner, the processing unit 601 calls the multiple threads to download the target fragment file in parallel, and is specifically configured to:
determining an idle thread of the plurality of threads;
and calling the idle thread to download the target fragment file in parallel.
In a possible implementation manner, the processing unit 601 is further configured to:
inquiring whether a database has a plurality of fragment files of the target file;
and if the database has a plurality of fragment files of the target file, executing the step of calling a plurality of threads to perform fragment downloading or fragment transmission on the target file.
In a possible implementation manner, if the downloading or transmission process is interrupted, the obtaining unit 602 obtains the fragment information of the target file, and specifically is configured to:
and if the downloading or transmission process is interrupted, acquiring the fragment information of the target file when a file downloading request submitted by the browser is detected again.
In a possible implementation manner, when the file download request submitted by the browser is detected again, the obtaining unit 602 obtains the fragment information of the target file, and specifically is configured to:
when a file downloading request submitted by the browser is detected again, a storage path of the target file is obtained;
and when the acquired storage path is consistent with the recorded storage path of the target file, acquiring the fragment information of the target file.
In a possible implementation manner, the processing unit 602 is further configured to:
and when the acquired storage path is inconsistent with the recorded storage path of the target file, executing the step of calling a plurality of threads to perform fragment downloading on the target file.
According to an embodiment of the present application, the steps involved in the file downloading methods shown in fig. 2 and 5 may be performed by the units in the file downloading apparatus shown in fig. 6. For example, step S201 and step S204 in the file downloading method shown in fig. 2 may be executed by the processing unit 601 in the file downloading device shown in fig. 6, step S202 may be executed by the obtaining unit 602 in the file downloading device shown in fig. 6, and step S203 may be executed by the determining unit 603 in the file downloading device shown in fig. 6; as another example, steps S501 and S507 in the file downloading method shown in fig. 5 may be performed by the determination unit 603 in the file downloading device shown in fig. 6, steps S502 to S504 and steps S508 to S509 may be performed by the processing unit 601 in the file downloading device shown in fig. 6, and steps S505 to S506 and steps may be performed by the acquisition unit 602 in the file downloading device shown in fig. 6.
According to another embodiment of the present application, the units in the file downloading device shown in fig. 6 may be respectively or entirely combined into one or several other units to form the file downloading device, or some unit(s) may be further split into multiple units with smaller functions to form the file downloading device, which may achieve the same operation without affecting the achievement of the technical effect of the embodiment of the present application. The units are divided based on logic functions, and in practical application, the functions of one unit can be realized by a plurality of units, or the functions of a plurality of units can be realized by one unit. In other embodiments of the present application, the file downloading device may also include other units, and in practical applications, these functions may also be implemented by being assisted by other units, and may be implemented by cooperation of multiple units.
According to another embodiment of the present application, the file downloading apparatus as shown in fig. 6 may be constructed by running a computer program (including program codes) capable of executing the steps involved in the respective methods as shown in fig. 2 and fig. 5 on a general-purpose computing device such as a computer including a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), and a storage element, and implementing the file downloading method of the embodiment of the present application. The computer program may be embodied on a computer-readable storage medium, for example, and loaded into and executed by the above-described computing apparatus via the computer-readable storage medium.
In this embodiment of the application, when detecting a file download request submitted by a browser, a processing unit 601 determines a target file to be downloaded according to the file download request, and invokes a plurality of threads to perform fragment download or fragment transmission on the target file. In the process of invoking multiple threads to perform fragment downloading or fragment transmission on a target file, if the downloading or transmission process is interrupted, the obtaining unit 602 obtains fragment information of the target file, the determining unit 603 determines an unsuccessfully downloaded target fragment file according to the fragment information, and the processing unit 601 invokes multiple threads to download or transmit the target fragment file.
Based on the method and the device embodiment, the embodiment of the application provides a server. Referring to fig. 7, a schematic structural diagram of a server provided in the embodiment of the present application is shown. The computer device 700 shown in fig. 7 comprises at least a processor 701, an input interface 702, an output interface 703, a computer storage medium 704 and a memory 705. The processor 701, the input interface 702, the output interface 703, the computer storage medium 704, and the memory 705 may be connected by a bus or other means.
A computer storage medium 704 may be stored in the memory 705 of the server 700, the computer storage medium 704 being used to store a computer program comprising program instructions, the processor 701 being used to execute the program instructions stored by the computer storage medium 704. The processor 701 (or CPU) is a computing core and a control core of the server 700, and is adapted to implement one or more instructions, and in particular, is adapted to load and execute one or more computer instructions to implement corresponding method flows or corresponding functions.
An embodiment of the present application further provides a computer storage medium (Memory), which is a Memory device in the server 700 and is used to store programs and data. It is understood that the computer storage medium herein may include both the built-in storage medium in the server 700 and, of course, also the extended storage medium supported by the server 700. The computer storage media provides storage space that stores the operating system of server 700. Also stored in this memory space are one or more instructions, which may be one or more computer programs (including program code), suitable for loading and execution by processor 701. The computer storage medium may be a high-speed RAM memory, or may be a non-volatile memory (non-volatile memory), such as at least one disk memory; and optionally at least one computer storage medium located remotely from the processor.
In one embodiment, the computer storage medium may be loaded with one or more instructions stored in the computer storage medium and executed by the processor 701 to implement the corresponding steps of the file download method described above with respect to fig. 2 and 5. In particular implementations, one or more instructions in the computer storage medium are loaded by processor 701 and perform the following steps:
when a file downloading request submitted by a browser is detected, determining a target file to be downloaded according to the file downloading request, and calling a plurality of threads to perform fragment downloading or fragment transmission on the target file;
in the process of calling the multiple threads to perform fragment downloading or fragment transmission on the target file, if the downloading or transmission process is interrupted, fragment information of the target file is acquired, wherein the fragment information comprises information of a fragment file distributed for each thread in the multiple threads and downloading progress of each thread on the distributed fragment file, and the fragment file is obtained by performing fragment processing on the target file;
according to the fragment information, determining an unsuccessfully downloaded target fragment file from the fragment files distributed for each thread in the multiple threads;
and calling the multiple threads to download or transmit the target fragment file.
In a possible implementation manner, the processor 701 invokes a plurality of threads to perform the fragment downloading on the target file, which may be specifically configured to:
calling the multiple threads to carry out parallel fragment downloading on the target file;
when the target fragment file is multiple, the invoking the multiple threads to download the target fragment file includes:
calling the multiple threads to download the target fragment file in parallel;
after the target fragment file is downloaded by calling the multiple threads in parallel, the method further comprises:
and combining the target fragmented files to obtain the target file.
In a possible implementation manner, the processor 701 invokes the multiple threads to download the target fragment file in parallel, where the target fragment file is specifically configured to:
determining an idle thread of the plurality of threads;
and calling the idle thread to download the target fragment file in parallel.
In one possible implementation manner, the processor 701 is further configured to:
inquiring whether a database has a plurality of fragment files of the target file;
and if the database has a plurality of fragment files of the target file, executing the step of calling a plurality of threads to perform fragment downloading or fragment transmission on the target file.
In a possible implementation manner, if the downloading or transmission process is interrupted, the processor 701 obtains the fragment information of the target file, and specifically is configured to:
and if the downloading or transmission process is interrupted, acquiring the fragment information of the target file when a file downloading request submitted by the browser is detected again.
In a possible implementation manner, when the processor 701 detects a file download request submitted by a browser again, acquiring fragmentation information of the target file, where the fragmentation information includes:
when a file downloading request submitted by the browser is detected again, a storage path of the target file is obtained;
and when the acquired storage path is consistent with the recorded storage path of the target file, acquiring the fragment information of the target file.
In one possible implementation manner, the processor 701 is further configured to:
and when the acquired storage path is inconsistent with the recorded storage path of the target file, executing the step of calling a plurality of threads to perform fragment downloading on the target file.
In this embodiment of the present application, when detecting a file download request submitted by a browser, a processor 701 determines a target file to be downloaded according to the file download request, and invokes a plurality of threads to perform fragment download or fragment transmission on the target file. In the process of calling a plurality of multiple threads to download or transmit the target file in a slicing mode, if the downloading or transmitting process is interrupted, slicing information of the target file is obtained, the target slicing file which is not downloaded successfully is determined according to the slicing information, and then the target slicing file is downloaded or transmitted by calling the multiple threads.
According to an aspect of the present application, the present application embodiment also provides a computer product or a computer program, which includes computer instructions, which are stored in a computer-readable storage medium. The processor 701 reads the computer instructions from the computer-readable storage medium, and the processor 701 executes the computer instructions, so that the server 700 performs the file download method shown in fig. 2 and 4.
It is emphasized that the data may also be stored in a node of a blockchain in order to further ensure the privacy and security of the data. The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the above-described modules is merely a logical division, and other divisions may be realized in practice, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for downloading a file, the method comprising:
when a file downloading request submitted by a browser is detected, determining a target file to be downloaded according to the file downloading request, and calling a plurality of threads to perform fragment downloading or fragment transmission on the target file;
in the process of calling the multiple threads to perform fragment downloading or fragment transmission on the target file, if the downloading or transmission process is interrupted, fragment information of the target file is acquired, wherein the fragment information comprises information of a fragment file distributed for each thread in the multiple threads and downloading progress of each thread on the distributed fragment file, and the fragment file is obtained by performing fragment processing on the target file;
according to the fragment information, determining an unsuccessfully downloaded target fragment file from the fragment files distributed for each thread in the multiple threads;
and calling the multiple threads to download or transmit the target fragment file.
2. The method of claim 1, wherein invoking the plurality of threads to perform the fragmented download of the target file comprises:
calling the multiple threads to carry out parallel fragment downloading on the target file;
when the target fragment file is multiple, the invoking the multiple threads to download the target fragment file includes:
calling the multiple threads to download the target fragment file in parallel;
after the target fragment file is downloaded by calling the multiple threads in parallel, the method further comprises:
and combining the target fragmented files to obtain the target file.
3. The method of claim 2, wherein said invoking the multiple threads to download the target fragment file in parallel comprises:
determining an idle thread of the plurality of threads;
and calling the idle thread to download the target fragment file in parallel.
4. The method of claim 1, wherein prior to invoking the plurality of threads to perform the fragmented download or fragmented transfer of the target file, the method further comprises:
inquiring whether a database has a plurality of fragment files of the target file;
and if the database has a plurality of fragment files of the target file, executing the step of calling a plurality of threads to perform fragment downloading or fragment transmission on the target file.
5. The method according to any one of claims 1 to 3, wherein the obtaining the fragment information of the target file if the downloading or transmission process is interrupted comprises:
and if the downloading or transmission process is interrupted, acquiring the fragment information of the target file when a file downloading request submitted by the browser is detected again.
6. The method according to claim 5, wherein the obtaining the fragment information of the target file when the file download request submitted by the browser is detected again comprises:
when a file downloading request submitted by the browser is detected again, a storage path of the target file is obtained;
and when the acquired storage path is consistent with the recorded storage path of the target file, acquiring the fragment information of the target file.
7. The method of claim 6, further comprising:
and when the acquired storage path is inconsistent with the recorded storage path of the target file, executing the step of calling a plurality of threads to perform fragment downloading on the target file.
8. A file download apparatus, characterized in that the apparatus comprises:
the processing unit is used for determining a target file to be downloaded according to a file downloading request when the file downloading request submitted by the browser is detected, and calling a plurality of threads to perform fragment downloading or fragment transmission on the target file;
an obtaining unit, configured to obtain fragmentation information of the target file if a downloading or transmission process is interrupted during a process of calling the multiple threads to perform fragmentation downloading or fragmentation transmission on the target file, where the fragmentation information includes information of a fragmentation file allocated to each of the multiple threads and a downloading progress of the allocated fragmentation file by each thread, and the fragmentation file is obtained by performing fragmentation processing on the target file;
a determining unit, configured to determine, according to the fragmentation information, an unsuccessfully downloaded target fragmentation file from the fragmentation files allocated to each of the multiple threads;
the processing unit is further configured to invoke the multiple threads to download or transmit the target fragment file.
9. A server, characterized in that the server comprises:
a processor adapted to implement one or more computer programs; and the number of the first and second groups,
computer storage medium storing one or more computer programs adapted to be loaded by said processor and to perform the file download method according to any of claims 1-7.
10. A computer-readable storage medium, characterized in that it stores one or more computer programs adapted to be loaded by a processor and to perform the file download method according to any of claims 1-7.
CN202110707632.1A 2021-06-24 2021-06-24 File downloading method, device, server and storage medium Withdrawn CN113411404A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110707632.1A CN113411404A (en) 2021-06-24 2021-06-24 File downloading method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110707632.1A CN113411404A (en) 2021-06-24 2021-06-24 File downloading method, device, server and storage medium

Publications (1)

Publication Number Publication Date
CN113411404A true CN113411404A (en) 2021-09-17

Family

ID=77683151

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110707632.1A Withdrawn CN113411404A (en) 2021-06-24 2021-06-24 File downloading method, device, server and storage medium

Country Status (1)

Country Link
CN (1) CN113411404A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422533A (en) * 2021-12-29 2022-04-29 成都鲁易科技有限公司 Method and device for processing path conflict in cloud backup and electronic equipment
CN114629896A (en) * 2022-04-19 2022-06-14 高途教育科技集团有限公司 File downloading method and device, electronic equipment and readable storage medium
CN115174679A (en) * 2022-07-27 2022-10-11 天翼云科技有限公司 Network file caching method and device, electronic equipment and storage medium
CN115242780A (en) * 2022-07-26 2022-10-25 北京知道创宇信息技术股份有限公司 File downloading method and device, downloading manager and readable storage medium
CN116669097A (en) * 2022-08-26 2023-08-29 天翼数字生活科技有限公司 Method and device for transmitting fragments based on OKhttp
CN118041929A (en) * 2024-04-12 2024-05-14 云筑信息科技(成都)有限公司 Method for realizing browser large file fragment downloading based on stream

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422533A (en) * 2021-12-29 2022-04-29 成都鲁易科技有限公司 Method and device for processing path conflict in cloud backup and electronic equipment
CN114422533B (en) * 2021-12-29 2023-05-09 成都鲁易科技有限公司 Method and device for processing path conflict in cloud backup and electronic equipment
CN114629896A (en) * 2022-04-19 2022-06-14 高途教育科技集团有限公司 File downloading method and device, electronic equipment and readable storage medium
CN115242780A (en) * 2022-07-26 2022-10-25 北京知道创宇信息技术股份有限公司 File downloading method and device, downloading manager and readable storage medium
CN115174679A (en) * 2022-07-27 2022-10-11 天翼云科技有限公司 Network file caching method and device, electronic equipment and storage medium
CN116669097A (en) * 2022-08-26 2023-08-29 天翼数字生活科技有限公司 Method and device for transmitting fragments based on OKhttp
CN118041929A (en) * 2024-04-12 2024-05-14 云筑信息科技(成都)有限公司 Method for realizing browser large file fragment downloading based on stream

Similar Documents

Publication Publication Date Title
CN113411404A (en) File downloading method, device, server and storage medium
EP2682863B1 (en) Installing applications remotely
US10409649B1 (en) Predictive load balancer resource management
WO2019201039A1 (en) Method and system for updating application and application server
US20140250158A1 (en) Method and device for obtaining file
CN107273213B (en) Calculation control method, network card and electronic equipment
US9912747B2 (en) Browser and system for download and download method
CN102567339A (en) Method, device and system for acquiring start page
EP3313041A1 (en) Application download method and device
CN115277566B (en) Load balancing method and device for data access, computer equipment and medium
CN112422450B (en) Computer equipment, and flow control method and device for service request
CN106657182B (en) Cloud file processing method and device
CN111338834B (en) Data storage method and device
EP3506599B1 (en) Method for synchronizing contact information, apparatus and medium
CN113452733A (en) File downloading method and device
US20170171307A1 (en) Method and electronic apparatus for processing picture
CN112818270A (en) Data cross-domain transfer method and device and computer equipment
CN111177600B (en) Built-in webpage loading method and device based on mobile application
CN107045452B (en) Virtual machine scheduling method and device
EP2724489B1 (en) Validating download success
EP3748493B1 (en) Method and device for downloading installation-free application
CN113360815A (en) Request retry method and device
CN110020290B (en) Webpage resource caching method and device, storage medium and electronic device
US11366613B2 (en) Method and apparatus for writing data
CN112688980B (en) Resource distribution method and device, and computer equipment

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
WW01 Invention patent application withdrawn after publication
WW01 Invention patent application withdrawn after publication

Application publication date: 20210917