A method, device, and electronic device for downloading files through a browser

By splitting file intervals in the browser and downloading shards asynchronously, the problem of uncontrollable downloads in traditional browsers is solved, real-time progress display and user experience improvement are achieved.

CN118540319BActive Publication Date: 2025-07-29BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410627879.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2025-07-29
Estimated Expiration
2044-05-20

AI Technical Summary

Technical Problem

The process of downloading files in traditional browsers is uncontrollable, resulting in users being unable to understand the download progress in real time, affecting the download experience.

Method used

Split the file interval into multiple sub-intervals through the browser, download and store the target shards asynchronously to the preset database, and listen to the shard progress to determine the file download progress.

Benefits of technology

It realizes the controllability of the browser's file download process, provides real-time download progress, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118540319B_ABST
    Figure CN118540319B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, apparatus, and electronic device for downloading files through a browser, relating to the technical field of data transmission, and particularly to the technical fields of information content processing and browser technology. The specific implementation solution is as follows: The browser receives a file download instruction, which is used to indicate downloading a target file. Then the browser obtains the file size of the target file, determines the file range of the target file according to the file size, and splits the file range into multiple sub-ranges, where the maximum value of the file range is the file size. Then, the browser downloads the target shards corresponding to each sub-range in the target file from the first server respectively, stores the downloaded target shards in a preset database of the browser, and asynchronously monitors the target shards stored in the preset database. According to the target shards stored in the preset database, the browser determines the download progress of the target file and displays the download progress. Thus, it realizes providing real-time download progress for users and improving the user's download experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data transmission, and particularly to the technical fields of information content processing and browser technology. Background Art

[0002] With the rapid development of global Wide Area Web (Web) application services and the increasing maturity of Internet technology, file download has become one of the core functions of network services and occupies an important position in front-end development practice. Currently, the mainstream methods of file download include two types: downloading through a browser and downloading through a client. Summary of the Invention

[0003] The present disclosure provides a method, apparatus, and electronic device for downloading a file through a browser.

[0004] According to a first aspect of the present disclosure, there is provided a method for downloading a file through a browser, which is applied to the browser and includes:

[0005] Receiving a file download instruction for instructing to download a target file;

[0006] Obtaining the file size of the target file, determining a file range of the target file according to the file size, and splitting the file range into multiple sub-ranges, where the maximum value of the file range is the file size;

[0007] Downloading target shards corresponding to each sub-range in the target file from a first server, storing the downloaded target shards in a preset database, and asynchronously listening to the target shards stored in the preset database, and determining the download progress of the target file according to the target shards stored in the preset database.

[0008] According to a second aspect of the present disclosure, there is provided an apparatus for downloading a file through a browser, which is applied to the browser and includes:

[0009] A receiving module for receiving a file download instruction for instructing to download a target file;

[0010] A splitting module for obtaining the file size of the target file, determining a file range of the target file according to the file size, and splitting the file range into multiple sub-ranges, where the maximum value of the file range is the file size;

[0011] A download module, configured to download the target shards corresponding to each sub-interval in the target file from the first server respectively, store the downloaded target shards in a preset database, and asynchronously monitor the target shards stored in the preset database, and determine the download progress of the target file according to the target shards stored in the preset database.

[0012] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0013] At least one processor; and

[0014] A memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of the first aspect.

[0016] According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method according to any one of the first aspect.

[0017] According to a fifth aspect of the present disclosure, there is provided a computer program product, including a computer program, and the computer program realizes the method according to any one of the first aspect when being executed by a processor.

[0018] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings are used to better understand the solution and do not constitute a limitation to the present disclosure. Among them:

[0020] Figure 1 is a flowchart of a method for downloading a file through a browser provided by an embodiment of the present disclosure;

[0021] Figure 2 is a flowchart of a shard download method provided by an embodiment of the present disclosure;

[0022] Figure 3 is a flowchart of a file transfer method provided by an embodiment of the present disclosure;

[0023] Figure 4 is an exemplary diagram of a process of downloading a file through a browser provided by an embodiment of the present disclosure;

[0024] Figure 5It is an exemplary schematic diagram of another process for downloading a file through a browser provided by an embodiment of the present disclosure;

[0025] Figure 6 It is a schematic structural diagram of a device for downloading a file through a browser provided by an embodiment of the present disclosure;

[0026] Figure 7 It is a block diagram of an electronic device for implementing the method of downloading a file through a browser according to an embodiment of the present disclosure. Detailed implementation manners

[0027] The following makes an explanation of exemplary embodiments of the present disclosure with reference to the accompanying drawings. Various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted below.

[0028] Currently, the mainstream methods of file downloading include two types: downloading through a browser and downloading through a client. Although the purpose of downloading a file through a browser and downloading a file through a client is the same, that is, to transfer a file on a remote server to a local device, there are significant differences between these two file downloading methods in terms of implementation mechanisms, user experience, and optimization directions.

[0029] Downloading files through a client means downloading files through a dedicated download management software or application. This method can usually effectively utilize network bandwidth, provide a relatively stable and reliable download service, and support rich download functions, such as multi-threaded download, resume breakpoint, download speed control, and file storage location management. This download method also features high visualization and user controllability. For example, it can display the real-time download progress for users, allow users to adjust the download strategy, and manage the downloaded files. This download method can provide users with a good download experience. However, this download method also has obvious drawbacks. For example, if a user wants to download a video, they need to install a video software on the terminal first to download the video through the video software; if a user wants to download a song, they need to install a music software on the terminal first to download the song through the music software. Another example is that if a user wants to download an exclusive video of Video Software A, since the exclusive video is only provided by Video Software A and cannot be provided by other video software, even if other video software is installed on the terminal, the user cannot download the exclusive video through other video software. Therefore, they need to install Video Software A on the terminal to download the exclusive video through Video Software A. It can be seen that for different types of files and files from different sources, different software needs to be used for downloading through the client. Therefore, the installation time cost is high, which is a non-negligible threshold for users seeking a simple and fast download experience.

[0030] Downloading files through a browser is a way to download files within a Web browser. This method can download various files without installing additional software on the terminal. For example, it can download videos, songs, texts, and application installation packages through the browser, which is highly convenient. However, the traditional browser download process is essentially a one-way and non-interactive data transmission mode. That is, when the browser needs to download a file, it calls a preset download interface, and the download manager corresponding to the download interface downloads the file. Once the download starts, the entire download process is unknown and uncontrollable for the browser. Therefore, the browser cannot determine the download progress of the file and cannot provide the download progress of the file to the user. This invisibility restricts the user's understanding of the download process and affects the user's download experience.

[0031] To improve the user experience of the file download method through a browser, an embodiment of the present disclosure provides a method for downloading files through a browser, which is applied to the browser. Among them, the browser is installed on the terminal. For example, the terminal can be an electronic device with network communication and data processing capabilities, such as a mobile phone, a tablet computer, a notebook computer, or a desktop computer.

[0032] As Figure 1 shown, the method for downloading files through a browser provided by the embodiment of the present disclosure includes the following steps:

[0033] S101. Receive a file download instruction, where the file download instruction is used to indicate downloading a target file.

[0034] The browser can display a web page and detect a file download instruction triggered by the user in the web page. Optionally, the file download instruction can be triggered by clicking a download button or voice control, etc. For example, when the browser displays a certain video web page, the user interface (UI) includes a download button or download link for the video. When the browser detects that the user clicks the video download button or download link, a file download instruction for the video is triggered.

[0035] The target file can be: a video, an audio, a text, or a software installation package, etc. The embodiments of the present disclosure do not make specific limitations on this.

[0036] S102. Obtain the file size of the target file, determine the file range of the target file according to the file size, and split the file range into multiple sub-ranges, where the maximum value of the file range is the file size.

[0037] For example, assuming the file size of the target file is 500 bytes (Byte), the file range can be [0, 500], and the multiple sub-ranges obtained by splitting the file range can be: [0, 100), [100, 200), [200, 300), [300, 400), and [400, 500].

[0038] S103. Download the target shards corresponding to each sub-range in the target file from the first server respectively, store the downloaded target shards in a preset database of the browser, and asynchronously monitor the target shards stored in the preset database, and determine the download progress of the target file according to the target shards stored in the preset database.

[0039] To implement asynchronous processing, the browser can download the target shards in each sub-range of the target file from the first server through a first thread, store the downloaded target shards in a preset database of the browser, and monitor the target shards stored in the preset database through a second thread, determine the download progress of the target file according to the target shards stored in the preset database, and display the download progress. Among them, the first thread and the second thread are executed asynchronously.

[0040] The preset database can be an Indexed Database (IndexedDB).

[0041] The browser can obtain the download link of the target file from the web page, analyze the domain name of the first server from the download link, then obtain the Internet Protocol (IP) address of the first server through domain name resolution, and then communicate with the first server based on the IP address of the first server.

[0042] Since in the embodiments of the present disclosure, the browser can store each target shard downloaded from the first server in a preset database, by listening to the target shards stored in the preset database, the download progress of the target file can be obtained. It can be seen that for the browser, the storage location of the target shards is known. Therefore, by listening to the shard situation stored at this storage location, the downloaded part of the target file can be obtained, that is, the real-time download progress can be obtained, improving the controllability of the browser for the file download process, so as to provide the user with the real-time download progress and enhance the user's download experience.

[0043] The following details the method for downloading a file through a browser provided by the embodiments of the present disclosure.

[0044] In some embodiments of the present disclosure, the manner in which the browser obtains the file size of the target file in S102 includes the following steps:

[0045] Step 1: Send a metadata acquisition request to the first server. The metadata acquisition request is used to request to obtain the metadata of the target file.

[0046] The metadata of the target file is data describing the attributes of the target file. For example, the metadata of the target file includes: file size, type, and name, etc.

[0047] Step 2: Receive the metadata acquisition response sent by the first server, and extract the file size of the target file from the metadata of the target file included in the metadata acquisition response.

[0048] It should be noted that the metadata acquisition request and the metadata acquisition response can be based on the Hypertext Transfer Protocol (HTTP) or the Hypertext Transfer Protocol Secure (HTTPS), etc.

[0049] The browser can obtain the metadata of the target file from the first server, including the file size of the target file, so that subsequent accurate splitting of the file interval can be performed based on the file size, providing a basis for the segmented download of the target file.

[0050] Before the above S102, the browser can also perform an authentication process first to improve the security of the transmission and storage of the target file. The authentication process includes: the browser sends an authentication request to the second server, where the authentication request is used to request the second server to authenticate whether the browser has the permission to download the target file, and then the browser receives the authentication response sent by the second server.

[0051] Among them, the browser can obtain the domain name of the second server for authentication from the web page, then obtain the IP address of the second server through domain name resolution, and then communicate with the second server based on the IP address of the second server.

[0052] The authentication request includes: the file name of the target file and the authentication information. For example, the authentication information includes at least one of the following data or a combination of any number of data: the user name of the logged-in user of the browser, the token identity number (token Identity document, token ID), and the device ID of the terminal where the browser is located, etc. The embodiments of the present disclosure do not make specific limitations on this.

[0053] After receiving the authentication request, the second server can determine the target file corresponding to the file name of the target file, obtain the download whitelist of the target file, where the download whitelist includes the authentication information of those who have the permission to download the target file. Then the browser checks whether the authentication information included in the authentication request is in the download whitelist of the target file. If so, it is determined that the authentication is passed, that is, the browser has the permission to download the target file; if not, it is determined that the authentication fails, that is, the browser does not have the permission to download the target file.

[0054] In the embodiments of the present disclosure, the download whitelist of the target file can be preset. For example, if the target file is a confidential file of an organization, the second server can pre-receive the authentication information of each member in the organization uploaded by the organization, and form the download whitelist of the target file with the received authentication information.

[0055] Another example is that if the target file is paid content, the second server can add the authentication information of the user to the download whitelist of the target file after the user successfully purchases the target file.

[0056] In another implementation, after receiving the authentication request, the browser can determine the target file corresponding to the file name of the target file, obtain the download blacklist of the target file, where the download blacklist includes the authentication information of those who are not allowed to download the target file. Then the browser checks whether the authentication information included in the authentication request is in the download blacklist of the target file. If so, it is determined that the authentication fails; if not, it is determined that the authentication passes.

[0057] Among them, the download blacklist of the target file can be preset. For example, the second server can obtain authentication information with malicious download risks and form the download blacklist of the target file with the obtained authentication information.

[0058] The authentication response returned by the second server to the browser includes an authentication result field. For example, an authentication result field of 1 indicates that the authentication is passed, and an authentication result field of 0 indicates that the authentication fails.

[0059] It should be noted that the first server and the second server can physically be the same server or different servers. The authentication request and the authentication response can be based on HTTP or HTTPS, etc.

[0060] After the authentication process is completed, the manner in which the browser sends a metadata acquisition request to the first server in S102 above can be implemented as: if the authentication response indicates that the browser has the permission to download the target file, then send a metadata acquisition request to the first server.

[0061] Through the above method, the browser can first request authentication from the second server, and only start the download process when the second server's authentication result for the browser is that it has the permission to download the target file, and then obtain the file size of the target file from the first server. This improves the security of the target file transmission and reduces the risk of the target file being maliciously obtained.

[0062] In the embodiment of the present disclosure, in the case where any target shard of the target file is not stored in the preset database, in order to download the complete target file, the minimum value of the file range of the target file can be set to 0, that is, the file range is [0, file size].

[0063] Through the above method, the browser can start segmenting the download of the target file from 0, which not only improves the download speed of the target file but also ensures the integrity of the downloaded target file.

[0064] Or, in the case where a part of the target shards of the target file are already stored in the preset database, in order to achieve breakpoint resumption, the embodiment of the present disclosure can set the minimum value of the file range to: the maximum value of the sub-range corresponding to the target shard with the largest index in the preset database + 1. For example, if the sub-range corresponding to the target shard with the largest index in the preset database is [50, 60], then the file range for setting breakpoint resumption is [61, file size of the target file].

[0065] The specific method of breakpoint resumption can be referred to the description below.

[0066] In S102 above, the manner in which the browser splits the file range into multiple sub-ranges includes the following two types:

[0067] The first way to split the file range: Split according to the preset shard size, that is, the browser obtains the preset shard size, and then in the file range, starting from the minimum value of the file range, sequentially intercepts multiple sub-ranges according to the preset shard size. Among them, there is no intersection between each sub-range, and the union of each sub-range is the file range.

[0068] For example, assume that the size of the target file is 300 bytes and the preset shard size is 100. Then the file range can be [0, 300], and the multiple sub-ranges obtained by splitting the file range are: [0, 100), [100, 200), [200, 300].

[0069] Among them, the preset shard size is pre-configured in the browser. And the preset shard size can be set according to aspects such as network conditions, the response ability of the first server, and / or the processing efficiency of the browser.

[0070] Through this method, the browser can control the size of each sub-range not to exceed the preset shard size, that is, control the size of each target shard downloaded not to exceed the preset shard size, optimize the use of network resources, and improve the transmission efficiency of a single target shard.

[0071] Since the file size of the target file is not necessarily exactly an integer multiple of the preset shard size, the interval size of the last sub-range obtained by splitting the file range in the first way is less than the preset shard size. In this case, after the browser sequentially intercepts multiple sub-ranges starting from the minimum value of the file range in the file range, it can judge whether the interval size of the last sub-range is less than the preset minimum interval size. Among them, the minimum interval size can be set according to actual needs. For example, the minimum interval size is 10% of the preset shard size.

[0072] If the interval size of the last sub-range is less than the preset minimum interval size, the browser merges the penultimate sub-range and the last sub-range. Conversely, if the interval size of the last sub-range is greater than or equal to the preset minimum interval size, the browser can maintain each sub-range split by the first way.

[0073] For example, assume that the size of the target file is 305 bytes and the preset shard size is 100 bytes. Then the file range can be [0, 305], and the multiple sub-ranges obtained by splitting the file range are: [0, 100), [100, 200), [200, 300), [300, 305]. Since the interval size of the last sub-range is less than 10, the penultimate sub-range and the last sub-range are merged, and the obtained sub-ranges are: [0, 100), [100, 200), [200, 305].

[0074] Since in a network environment with a relatively low network speed, the browser requests to download smaller shards from the server more frequently, and the risk of shard download failure is relatively high. Therefore, in the embodiments of the present disclosure, when the interval size of the last sub-interval is less than the preset minimum interval size, the penultimate sub-interval and the last sub-interval are merged to increase the data volume of the target shard corresponding to the sub-interval, avoid the data volume of the target shard requested from the first server being too small, reduce the risk of shard download failure, and improve the download success rate of the target file.

[0075] Second way of splitting the file interval: Split according to the preset number of shards, that is, the browser obtains the preset number of shards and divides the file interval into a preset number of sub-intervals. Among them, there is no intersection between the sub-intervals, and the union of the sub-intervals is the file interval.

[0076] Among them, the preset number of shards is pre-configured in the browser. And the preset number of shards can be set according to aspects such as network conditions, the response ability of the first server, and / or the processing efficiency of the browser.

[0077] The interval sizes of the preset number of sub-intervals obtained by the division can be the same, that is, the browser can evenly divide the file interval into a preset number of sub-intervals. For example, assume that the size of the target file is 300 bytes and the preset number of shards is 3, then the file interval can be [0, 300], and the multiple sub-intervals obtained by splitting the file interval are: [0, 100), [100, 200), [200, 300].

[0078] Or, the interval sizes of the preset number of sub-intervals obtained by the division may not be exactly the same. That is, the browser can calculate the ratio of the file size to the preset number of shards. When the ratio is not an integer, round up or down the ratio, and use the rounded result as the shard size. Then the browser sequentially intercepts multiple sub-intervals from 0 in the file interval according to the preset shard size, and merges the penultimate sub-interval and the last sub-interval. For example, assume that the size of the target file is 400 bytes and the preset number of shards is 3. Among them represents rounding up. At this time, the file interval can be [0, 400], the shard size is 133, and the multiple sub-intervals obtained by splitting are: [0, 133), [133, 266), [266, 399), [399, 400]. Merge the last two sub-intervals to get: [0, 133), [133, 266), [266, 400].

[0079] Through the above method, the browser can control the number of target shards requested to be downloaded from the first server, that is, control the number of requests, avoid requesting to download the target shard from the first server too frequently, and reduce the risk of processing errors or downtime caused by the first server being in a high concurrency state.

[0080] In addition to the above two ways of splitting the file range, the file range can also be split in other ways, which are not specifically limited in the embodiments of the present disclosure.

[0081] For example, the browser can determine whether the file size of the target file is greater than a preset threshold. If so, the above-mentioned method of splitting according to the preset number of shards is adopted, that is, the preset number of shards is obtained, and the file range is divided into a preset number of sub-ranges to control the number of sub-ranges obtained by splitting and avoid requesting to download the target shard from the first server too frequently. If not, the above-mentioned method of splitting according to the preset shard size is adopted, that is, the preset shard size is obtained, and then multiple sub-ranges are sequentially intercepted from 0 in the file range according to the preset shard size to control the size of each sub-range and improve the download speed of the sub-range.

[0082] In some embodiments of the present disclosure, refer to Figure 2 , the above-mentioned method in which the browser in S103 downloads the target shards corresponding to each sub-range in the target file from the first server includes:

[0083] S201. For each sub-range, send a shard download request to the first server, where the shard download request is used to request to download the target shard corresponding to the sub-range in the target file.

[0084] The shard download request in the embodiments of the present disclosure can be based on HTTP or HTTPS. The request header of the shard download request includes a range field, and the range field is used to represent the data range of the target shard to be downloaded in the target file. For example, the range field includes {start:0, end:10}, indicating that the data range of the target shard to be downloaded in the target file is the 0th to 10th bytes.

[0085] Among them, other fields can also be included in the request header of the shard download request. For example, Content-Type, Content-Disposition, and Content-Length. Among them, Content-Type is used to represent the type of the target file. Content-Disposition is used to represent the download method of the target file, where the download method indicates downloading to the local. Content-Length represents the file size of the target file.

[0086] Optionally, the browser can send the shard download requests corresponding to each sub-range to the first server at the same time. In this way, the downloads of the target shards included in the target file can be carried out almost simultaneously, greatly improving the file download speed.

[0087] Alternatively, the browser may sequentially send a shard download request corresponding to each sub-interval to the first server according to the arrangement order of the sub-intervals in the file interval.

[0088] Alternatively, the browser may send a shard download request corresponding to a specified number of sub-intervals to the first server at regular intervals, and the embodiments of the present disclosure do not make specific limitations thereto. Wherein, the specified number may be pre-set or may be determined according to the download speed of the browser. For example, the browser pre-stores the parallel download quantities corresponding to various download speed ranges, the browser may obtain the current download speed, determine the download speed range to which the current download speed belongs, and then find the parallel download quantity corresponding to the download speed range as the specified number.

[0089] S202. Receive the shard download response sent by the first server, and extract the target shard corresponding to the sub-interval from the shard download response.

[0090] The shard download response in the embodiments of the present disclosure may be based on HTTP or HTTPS, and the shard download response includes the target shard corresponding to the sub-interval.

[0091] Through the above method, the browser can implement segmented download of the target file, and the target shards of the target file can be downloaded in parallel, reducing the amount of data downloaded in a single request and improving the file download speed. At the same time, since the target file is segmented for download, the browser can more clearly obtain the downloaded part and the undownloaded part, facilitating the monitoring and management of the download process.

[0092] In some embodiments of the present disclosure, the first server may split the target file in the above manner of splitting the file interval into multiple sub-intervals, obtain multiple target shards included in the target file, and obtain the index of each target shard, where the index is used to represent the position of the target shard in the target file.

[0093] The shard download response sent by the first server to the browser in S202 above further includes the index of the target shard. Based on this, the manner in which the browser stores the downloaded target shards in the preset database in S103 above may be implemented as: storing the target shard and the index included in the shard download response in the preset database correspondingly.

[0094] By correspondingly recording the target shard and its index in the preset database, it is more convenient for the browser to monitor and manage the download process of the target file, providing a basis for functions such as breakpoint continuation, download progress monitoring, and integrity verification.

[0095] Optionally, in addition to including the index of the target shard, the shard download response may further include other metadata of the target shard, such as the size of the target shard, and the other metadata may also be stored in a preset database corresponding to the target shard.

[0096] The browser constructs a data model including a download task table and a shard information table in the preset database. Among them, the download task table records the unique identifier of the download task for the target file, that is, the download task identifier, as well as the metadata and download status of the target file corresponding to the download task identifier. The shard information table records the download task identifier, as well as the metadata, download status, and storage key of each target shard corresponding to the download task identifier. The storage key is used to represent the storage location of the target shard in the preset database.

[0097] The download status includes: not downloaded, downloading, and downloaded. The download status of the target file stored in the preset database and the download status of the target shard are maintained by the browser. When the browser has not sent a shard download request for any target shard to the first server, it can be determined that the download status of the target file is not downloaded; when a shard download request for any target shard has been sent to the first server, it can be determined that the download status of the target file is downloading; when all target shards are stored in the preset database, it can be determined that the download status of the target file is downloaded. For each target shard, when the browser has not sent a shard download request corresponding to the target shard to the first server, it can be determined that the download status of the target shard is not downloaded; when a shard download request corresponding to the target shard has been sent to the first server, it can be determined that the download status of the target shard is downloading; when the target shard is stored in the preset database, it can be determined that the download status of the target shard is downloaded.

[0098] Based on this, when listening to the preset database, the browser can use the download task table and the shard information table to distinguish the target shards included in different target files. That is, the browser can determine the download task identifier corresponding to each target file based on the download task table, and determine the target shards corresponding to each download task identifier based on the shard information table, so as to obtain the target shards included in each target file.

[0099] In the embodiments of the present disclosure, the browser can also perform integrity verification on each downloaded target shard of the target file. The implementation methods include: listening to the number of target shards of the target file stored in the preset database. When the number of target shards of the stored target file reaches the number of sub-intervals obtained by dividing the file interval of the target file in S102, it is determined that each target shard of the target file has been downloaded. At this time, the indexes of each target shard can be sorted, and it is checked whether there are any missing indexes in the indexes of each target shard. For example, if the indexes of each target shard are: 1, 2, 4, 5, then there is a missing index 3 between 2 and 4. If there is no omission, it is determined that the data integrity verification passes. Otherwise, it is determined that the data integrity verification fails, and a prompt message can be displayed to prompt the user that the download fails, or the target file can be redownloaded using the above method, or a request can be sent to the first server to redownload the missing target shards.

[0100] This method can perform integrity verification on each downloaded target shard, ensuring the efficiency, reliability, and integrity of the download process for the target file.

[0101] Moreover, the browser in the embodiments of the present disclosure also supports users to set file download priorities. The browser can download multiple target files simultaneously. The download method for each target file is the same, which can refer to the above description. The browser can receive the priority setting instruction from the user before downloading multiple target files or during the process of downloading multiple target files. The priority setting instruction includes the priority of each target file, and the priorities of each target file are all different. For example, the user can click on the download controls corresponding to each target file in the browser in sequence, and the browser will use the click order of the user on the download controls as the priority of the target files corresponding to each download control; or the browser can receive the priorities of each target file input by the user. The embodiments of the present disclosure do not make specific limitations on this. Then the browser can allocate transmission bandwidth for each target file in descending order of the priorities of each target file, where the priority of the target file is positively correlated with the allocated transmission bandwidth, and download the target shards included in the target file from the first server according to the transmission bandwidth allocated for each target file.

[0102] In some embodiments of the present disclosure, the method in which the browser in S103 determines the download progress of the target file according to the target shards stored in the preset database includes the following steps:

[0103] Step 1: Obtain the maximum index in the indexes of the target shards stored in the preset database.

[0104] The browser can look up the download task identifier of the download task for the target file in the download task table of the preset database, then look up the indexes of the target shards corresponding to the download task identifier in the shard information table, and then obtain the maximum index from the found indexes.

[0105] Step 2: Use the ratio of the maximum index to the number of target shards included in the target file as the download progress of the target file.

[0106] The browser can use the number of sub-intervals obtained by dividing the file interval in S102 as the number of target shards included in the target file.

[0107] Among them, the download progress can be in the form of a percentage. For example, if the maximum index is 3 and the number of target shards included in the target file is 5, then the download progress of the target file is: 3 / 5 = 60%.

[0108] Optionally, the browser can execute Step 1 and Step 2 every preset time period and update the displayed download progress. Or the browser can execute Step 1 and Step 2 every time a new target shard is stored in the preset database and update the displayed download progress. Thus, the real-time nature of the download progress is ensured.

[0109] Through the above method, the browser can monitor the download progress in real time by querying the indexes of the target shards stored in the preset database, and update it dynamically, improving the transparency, that is, the visibility, of the file download process, enabling users to more intuitively understand the download progress and enhancing the download experience. Moreover, this method does not need to request the download progress from the server, so it effectively reduces the request frequency to the server and alleviates the network load. In addition, since the present disclosure embodiment uses IndexedDB as the preset database of the browser, thanks to the large capacity and high-efficiency reading and writing ability of IndexedDB, it is ensured that the browser can accurately record and save the downloaded shards and the related information of the shards even in a complex network environment.

[0110] In addition to the above ways to implement S103, the download progress of the target file can also be determined by other ways, and the present disclosure embodiment does not make specific limitations on this.

[0111] For example, the browser can calculate the sum of the shard sizes of the target shards stored in the preset database, and use the ratio of the sum to the file size of the target file as the download progress of the target file.

[0112] For another example, the browser can obtain the number of target shards stored in the preset database, and use the ratio of the number to the number of target shards included in the target file as the download progress of the target file.

[0113] To enhance the user experience, after determining the download progress of the target file in S103 above, the browser can also display the download progress.

[0114] Among them, the browser can display the download progress in the front-end progress bar module of the browser. The front-end progress bar module can be implemented through modern Web technologies. For example, it can be implemented using HyperText Markup Language 5 (HTML5), Cascading Style Sheets 3 (CSS3), and programming language (JavaScript) technologies. The front-end progress bar module can dynamically display the download progress bar in a graphical manner and update the download progress represented by the download progress bar in real time. The front-end progress bar module can also display the amount of data already downloaded, the file size of the target file, the current download speed of the browser, and the estimated remaining download time, etc. Among them, the browser can calculate the difference between the file size of the target file and the amount of data already downloaded, and determine the remaining download time based on the difference and the current download speed.

[0115] Since the browser can display the download progress, users can intuitively view the download situation of the file, improving the visibility of the file download process, ensuring the user's understanding of the file download process, and enhancing the download experience of the user downloading the file through the browser.

[0116] See Figure 3 After each target shard of the target file is stored in the preset database, the browser can also reorganize each target shard, including the following steps:

[0117] S301. After each target shard included in the target file is stored in the preset database, combine each target shard into a binary large object.

[0118] Optionally, the browser can obtain the maximum index in the indexes of each target shard stored in the preset database. When the maximum index is equal to the number of target shards included in the target file, it is determined that each target shard included in the target file is stored in the preset database. Or, the browser can obtain the number of target shards stored in the preset database. When the number of target shards is equal to the number of target shards included in the target file, it is determined that each target shard included in the target file is stored in the preset database. Or, the browser can calculate the total sum of the shard sizes of the target shards stored in the preset database. When the total sum is equal to the file size of the target file, it is determined that each target shard included in the target file is stored in the preset database.

[0119] The browser can use the Binary Large Object (Blob) technology to combine the target shards into a Blob object in ascending order of the indexes of the target shards one by one.

[0120] S302. Generate a download link for the binary large object.

[0121] The browser can use the URL.createObjectURL() method to generate an accessible Uniform Resource Location (URL) based on the Blob object. Among them, the URL.createObjectURL() method is a method for generating a URL pointing to a specified web resource. In the embodiments of the present disclosure, the specified web resource is the Blob object.

[0122] S303. When it is detected that the download link is triggered, save the binary large object to a preset storage location of the terminal where the browser is located.

[0123] The download link can be triggered automatically, or the browser can display the download link and determine that the download link is triggered when it is detected that the user clicks the download link.

[0124] For example, the browser can create a temporary The HTML element of the label, set the Hypertext Reference (href) attribute of the HTML element to the download link generated by S302, and set the download attribute of the HTML element to the file name of the target file. Here, the file name can be the original file name of the target file or the file name set by the user. After that, the browser can automatically save the binary large object to the preset storage location of the terminal where the browser is located by automatically executing the click event of the HTML element.

[0125] Optionally, the preset storage location can be the default storage location in the terminal for saving downloaded files, or the preset storage location can be the location selected by the user.

[0126] Through the above method, the browser can reorganize each target shard and save it to the preset storage location of the terminal, so that various types of files such as documents, pictures, videos, or audios can be quickly downloaded to the terminal, that is, seamless download and storage are achieved. And the process of data reorganization and saving is completely executed by the browser, and the browser does not need to interact with the server during this process, which reduces the burden on the server and also protects the privacy of the terminal information.

[0127] In some embodiments of the present disclosure, the browser also supports resume from breakpoint, and the implementation method includes: if an interruption occurs during the process of downloading each target shard from the first server and a continue download instruction is received, then obtain the maximum index in the index of the target shard stored in the preset database, and then download the target shard after the target shard corresponding to the maximum index from the first server.

[0128] The interruption can occur passively or actively. For example, when the network of the terminal where the browser is located is unstable or the network connection is disconnected, or the terminal crashes, etc., the process of the browser downloading each target shard is interrupted passively. Another example is that when the browser detects that the user clicks the pause download button during the process of downloading each target shard, the download process is interrupted actively, that is, the browser actively pauses the download.

[0129] The continue download instruction can be triggered automatically or by the user. For example, when the network connection of the terminal where the browser is located is restored, the continue download instruction can be triggered automatically. Another example is that when it is detected that the user clicks the continue download button, it is determined that the continue download instruction is triggered.

[0130] Since the browser can instantaneously record the exact data of the download process in a preset database, when resuming the download, the browser can obtain the maximum index of each target shard stored in the preset database, and the target shards after the target shard corresponding to the maximum index are the shards that need to be continuously downloaded. Then the browser can determine the sub-interval corresponding to the target shard to which the maximum index belongs, generate a shard download request for each sub-interval after this sub-interval, send it to the first server, and then obtain the target shard from the shard download response sent by the first server.

[0131] Through the above method, the browser can accurately locate the downloaded part of the target file before the download interruption and continue to download the remaining part, without having to start downloading the target file from the beginning, that is, breakpoint resume is achieved. This method effectively reduces the amount of data to be downloaded after the file download is interrupted and improves the speed of obtaining the target file.

[0132] In the embodiments of the present disclosure, the preset database further includes the download status of the target file. On this basis, the browser can also perform data cleaning on the preset database, and the data cleaning method can be implemented as: determine the files to be cleaned with the download status of download completed from the preset database, and then delete the files to be cleaned, each shard included in the files to be cleaned, and the download status corresponding to the files to be cleaned from the preset database.

[0133] The browser can execute the above data cleaning method after storing the target file in the preset storage location of the terminal in S303 above, or execute the above data cleaning method periodically, or execute the above data cleaning method when detecting that the amount of data stored in the preset database reaches the preset data volume. The embodiments of the present disclosure do not make specific limitations on this.

[0134] The period for executing the above data cleaning method can be set according to actual needs, for example, the period is 7 days.

[0135] When performing data cleaning, the browser can determine the files to be cleaned with the download status of download completed from the download task table, and the download task identifier corresponding to the files to be cleaned. Then search for the shards, shard metadata, shard download status, storage keys, etc. corresponding to the download task identifier from the shard information table. Delete the data items corresponding to the download task identifier in the download task table and the shard information table.

[0136] Since the file is saved to the preset storage location of the terminal after the download is completed, the relevant information of the downloaded file can be deleted, reducing the situation where the preset database is occupied by useless data, releasing the storage space, improving the utilization rate of the storage resources, ensuring the efficient operation of the browser, and at the same time reducing the load impact of invalid data on the storage resources.

[0137] See Figure 4 Next, the functional modules used by the browser in the process of downloading the target file in the embodiments of the present disclosure are introduced.

[0138] First, the browser requests the second server to authenticate whether the browser has the permission to download the target file through the request authentication module. After the authentication passes, the browser obtains the metadata of the target file from the first server through the metadata request module, including the file size of the target file. Then the browser uses the data sharding module to split the file range composed of 0 and the file size into multiple sub-ranges. Then the browser downloads the target shards corresponding to each sub-range in the target file from the first server through the continuous integration module, and stores the downloaded target shards into IndexedDB through the storage module. After all the target shards included in the target file are stored in IndexedDB, the browser combines the downloaded target shards through the file recombination module, and stores the combined target file into a preset storage location of the terminal where the browser is located through the resource storage service. The browser can also delete the relevant information such as each shard and metadata included in the downloaded file from IndexedDB through the data cleaning module.

[0139] See Figure 5 Next, the process of the browser downloading a file is described in detail in combination with an actual application scenario:

[0140] When the browser detects that the user initiates a download instruction for the target file, it sends an authentication request to the second server and receives the authentication response sent by the second server. If the authentication response indicates that the authentication fails, the browser does not perform the file download, and the download process ends here. If the authentication response indicates that the authentication passes, the browser obtains the metadata of the target file from the first server. Then, the browser splits the file range into multiple sub-ranges, generates a fragmented download task, and concurrently downloads the target fragments corresponding to the sub-ranges from the first server, and stores the downloaded target fragments in IndexedDB. At the same time, the browser asynchronously monitors the target fragments stored in the preset database, and determines and displays the download progress of the target file according to the target fragments stored in IndexedDB. The browser can also provide a breakpoint resume function according to the situation of the target fragments stored in IndexedDB. After all the target fragments included in the target file are stored in IndexedDB, the browser reorganizes the downloaded target fragments and saves the reorganized target file to the preset storage location of the terminal where the browser is located. After that, the browser checks whether there is a file to be cleaned with a download status of "download completed" in the preset database. If so, it deletes the file to be cleaned, each fragment included in the file to be cleaned, and the download status corresponding to the file to be cleaned from IndexedDB. If not, it retains all the data currently stored in IndexedDB.

[0141] It can be seen that the browser in the embodiments of the present disclosure can perform fine-grained control on the download process during file download, so as to adjust the download strategy according to actual needs and optimize the download efficiency and stability. In addition, the browser can also monitor the download progress throughout the process, record and mark each link of the file download in detail, which not only provides evidence for subsequent performance optimizations such as breakpoint resume, but also enables the traceability and analyzability of download problems. This method greatly enhances the user experience of file download through the browser, and at the same time lays a foundation for providing more personalized and efficient download services, and provides more possibilities for value-added services in data transmission commercialization. The potential of this visual download method is not only reflected in enhancing the individual user experience, but more importantly, it opens up a new optimization path for web application services, enabling the design and implementation of the download function to be more closely combined with user needs and the complexity of the modern network environment, showing a broad development space for browser download in future network applications.

[0142] In the technical solution of the present disclosure, the processing of collection, storage, use, processing, transmission, provision, and disclosure of the file information involved all comply with the provisions of relevant laws and regulations and do not violate public order and good customs.

[0143] Based on the same inventive concept, the embodiments of the present disclosure also provide a device for downloading files through a browser, which is applied to the browser, asFigure 6 As shown in Figure 6 , the device includes: a receiving module 601, a splitting module 602, and a downloading module 603;

[0144] The receiving module 601 is configured to receive a file download instruction, where the file download instruction is used to indicate downloading a target file;

[0145] The splitting module 602 is configured to obtain the file size of the target file, determine the file range of the target file according to the file size, and split the file range into multiple sub - ranges, where the maximum value of the file range is the file size;

[0146] The downloading module 603 is configured to separately download the target shards corresponding to each sub - range in the target file from the first server, store the downloaded target shards in a preset database of the browser, and asynchronously monitor the target shards stored in the preset database, and determine the download progress of the target file according to the target shards stored in the preset database.

[0147] In some embodiments of the present disclosure, the device further includes:

[0148] A combining module, configured to combine each target shard into a binary large object after all the target shards included in the target file are stored in the preset database;

[0149] A generating module, configured to generate a download link for the binary large object;

[0150] A storage module, configured to save the binary large object to a preset storage location of the terminal where the browser is located when it detects that the download link is triggered.

[0151] In some embodiments of the present disclosure, the downloading module 603 is specifically configured to:

[0152] For each sub - range, send a shard download request to the first server, where the shard download request is used to request downloading the target shard corresponding to the sub - range in the target file;

[0153] Receive a shard download response sent by the first server, and extract the target shard corresponding to the sub - range from the shard download response.

[0154] In some embodiments of the present disclosure, the shard download response further includes an index of the target shard, where the index is used to indicate the position of the target shard in the target file; the downloading module 603 is specifically configured to:

[0155] Correspondingly store the target shard and the index included in the shard download response in the preset database.

[0156] In some embodiments of the present disclosure, the downloading module 603 is specifically configured to:

[0157] Obtain the maximum index in the index of the target shards stored in the preset database;

[0158] Use the ratio of the maximum index to the number of target shards included in the target file as the download progress of the target file.

[0159] In some embodiments of the present disclosure, the apparatus further includes:

[0160] An obtaining module, configured to, if an interruption occurs during the process of downloading each target shard from the first server and a continue-download instruction is received, obtain the maximum index in the index of the target shards stored in the preset database;

[0161] The download module 603 is further configured to download the target shards after the target shard corresponding to the maximum index from the first server.

[0162] In some embodiments of the present disclosure, the preset database further includes the download status of the target file; the apparatus further includes:

[0163] A determining module, configured to determine, from the preset database, the files to be cleaned with the download status of download completed;

[0164] A deleting module, configured to delete the files to be cleaned, each shard included in the files to be cleaned, and the download status corresponding to the files to be cleaned from the preset database.

[0165] In some embodiments of the present disclosure, the splitting module 602 is specifically configured to:

[0166] Send a metadata acquisition request to the first server, where the metadata acquisition request is used to request to obtain the metadata of the target file;

[0167] Receive the metadata acquisition response sent by the first server, and extract the file size of the target file from the metadata of the target file included in the metadata acquisition response.

[0168] In some embodiments of the present disclosure, the apparatus further includes:

[0169] A sending module, configured to send an authentication request to the second server before sending the metadata acquisition request to the first server, where the authentication request is used to request the second server to authenticate whether the browser has the permission to download the target file;

[0170] A receiving module is further configured to receive the authentication response sent by the second server;

[0171] Wherein, the splitting module 602 is specifically configured to:

[0172] If the authentication response indicates that the browser has the permission to download the target file, send a metadata acquisition request to the first server.

[0173] In some embodiments of the present disclosure, the splitting module 602 is specifically configured to:

[0174] Obtain a preset shard size;

[0175] In the file range, starting from the minimum value of the file range, sequentially intercept a plurality of sub-ranges according to the preset shard size, where there is no intersection between the sub-ranges, and the union of the sub-ranges is the file range.

[0176] In some embodiments of the present disclosure, the apparatus further includes:

[0177] A merging module, configured to merge the penultimate sub-range and the last sub-range if the range size of the last sub-range is less than the preset minimum range size.

[0178] In some embodiments of the present disclosure, the splitting module 602 is specifically configured to:

[0179] Obtain a preset number of shards;

[0180] Divide the file range into a preset number of sub-ranges, where there is no intersection between the sub-ranges, and the union of the sub-ranges is the file range.

[0181] In some embodiments of the present disclosure, the apparatus further includes:

[0182] A display module, configured to display the download progress after determining the download progress of the target file.

[0183] In some embodiments of the present disclosure, the minimum value of the file range is 0.

[0184] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0185] Figure 7 FIG. shows a schematic block diagram of an exemplary electronic device 700 that can be used to implement the embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, for example, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, for example, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0186] As Figure 7As shown, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to computer programs stored in a read-only memory (ROM) 702 or computer programs loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0187] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, an optical disc, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0188] The computing unit 701 can be various general-purpose and / or dedicated processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 701 executes the various methods and processes described above, such as the method of downloading a file through a browser. For example, in some embodiments, the method of downloading a file through a browser can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the method of downloading a file through a browser described above can be executed. Alternatively, in other embodiments, the computing unit 701 can be configured to execute the method of downloading a file through a browser in any other appropriate manner (e.g., by means of firmware).

[0189] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems-on-chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.

[0190] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing device such that the program codes, when executed by the processor or controller, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0191] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0192] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, speech input, or tactile input).

[0193] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), and the Internet.

[0194] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship between the client and the server is generated by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, or a server of a distributed system, or a server incorporating a blockchain.

[0195] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitation is imposed herein.

[0196] The above specific embodiments do not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present disclosure shall be included within the protection scope of the present disclosure.

Claims

1. A method for downloading a file through a browser, applied to the browser, comprising: Receiving a file download instruction for instructing to download a target file; Obtaining the file size of the target file, determining a file range of the target file according to the file size, and splitting the file range into multiple sub-ranges, wherein the maximum value of the file range is the file size; Downloading corresponding target shards of each sub-range in the target file from a first server, storing the downloaded target shards in a preset database of the browser, and asynchronously monitoring the target shards stored in the preset database, and determining the download progress of the target file according to the target shards stored in the preset database; The downloading corresponding target shards of each sub-range in the target file from the first server comprises: For each sub-range, sending a shard download request to the first server, where the shard download request is used to request to download the target shard corresponding to this sub-range in the target file; Receiving a shard download response sent by the first server, and extracting the target shard corresponding to this sub-range from the shard download response; Wherein, the preset database further includes the download status of each target shard, and the download status includes: not downloaded, downloading, and downloaded; for each target shard, "not downloaded" means that the browser has not sent a shard download request corresponding to this target shard to the first server, "downloading" means that the browser has sent a shard download request corresponding to this target shard to the first server, and "downloaded" means that this target shard has been stored in the preset database; The sending a shard download request to the first server for each sub-range comprises: Sequentially sending a shard download request corresponding to each sub-range to the first server according to the arrangement order of each sub-range in the file range; Or, sending shard download requests corresponding to a specified number of sub-ranges to the first server at intervals of a certain time; The method further comprises: After all target shards included in the target file are stored in the preset database, combining the target shards into a binary large object; Generating a download link for the binary large object; When it is detected that the download link is triggered, saving the binary large object to a preset storage location of the terminal where the browser is located, and the preset storage location includes: the default storage location in the terminal for saving downloaded files, or a location selected by the user.

2. The method according to claim 1, wherein The shard download response further includes an index of the target shard, and the index is used to represent the position of the target shard in the target file; the storing the downloaded target shard in the preset database of the browser comprises: Correspondingly storing the target shard and the index included in the shard download response in the preset database.

3. The method according to claim 2, wherein The determining the download progress of the target file according to the target shards stored in the preset database comprises: Obtaining the maximum index among the indexes of the target shards stored in the preset database; Use the ratio of the maximum index to the number of target shards included in the target file as the download progress of the target file.

4. The method according to claim 2 further includes: If an interruption occurs during the process of downloading each target shard from the first server and a continue download instruction is received, obtain the maximum index among the indexes of the target shards stored in the preset database; Download the target shards after the target shard corresponding to the maximum index from the first server.

5. According to the method of claim 2, the download status of the target file is further included in the preset database; the method further includes: Determine the files to be cleaned with the download status of download completed from the preset database; Delete the files to be cleaned, each shard included in the files to be cleaned, and the download status corresponding to the files to be cleaned from the preset database.

6. The method according to claim 1, wherein The obtaining the file size of the target file includes: Send a metadata acquisition request to the first server, where the metadata acquisition request is used to request to obtain the metadata of the target file; Receive the metadata acquisition response sent by the first server, and extract the file size of the target file from the metadata of the target file included in the metadata acquisition response.

7. According to the method of claim 6, before sending the metadata acquisition request to the first server, it further includes: Send an authentication request to the second server, where the authentication request is used to request the second server to authenticate whether the browser has the permission to download the target file; Receive the authentication response sent by the second server; Wherein, the sending the metadata acquisition request to the first server includes: If the authentication response indicates that the browser has the permission to download the target file, then send a metadata acquisition request to the first server.

8. The method according to claim 1, wherein The splitting the file range into multiple sub-ranges includes: Obtain a preset shard size; In the file range, sequentially intercept multiple sub-ranges from the minimum value of the file range according to the preset shard size, where there is no intersection between the sub-ranges, and the union of the sub-ranges is the file range.

9. According to the method of claim 8, after sequentially intercepting multiple sub-ranges from the minimum value of the file range according to the preset shard size in the file range, it further includes: If the range size of the last sub-range is less than the preset minimum range size, then merge the penultimate sub-range and the last sub-range.

10. The method according to claim 1, wherein The splitting the file range into multiple sub-ranges includes: Obtain a preset number of shards; Divide the file range into the preset number of sub-ranges, where there is no intersection between the sub-ranges, and the union of the sub-ranges is the file range.

11. According to the method of any one of claims 1-10, after determining the download progress of the target file, it further includes: Display the download progress.

12. The method according to any one of claims 1-10, wherein, The minimum value of the file range is 0.

13. A device for downloading a file through a browser, applied to the browser, includes: A receiving module, configured to receive a file download instruction for instructing to download a target file; A splitting module, configured to obtain the file size of the target file, determine a file range of the target file according to the file size, and split the file range into multiple sub-ranges, where the maximum value of the file range is the file size; A download module, configured to separately download target shards corresponding to each sub-range in the target file from a first server, store the downloaded target shards in a preset database of the browser, and asynchronously monitor the target shards stored in the preset database, and determine the download progress of the target file according to the target shards stored in the preset database; The download module is specifically configured to: For each sub-range, send a shard download request to the first server, where the shard download request is used to request to download the target shard corresponding to the sub-range in the target file; Receive a shard download response sent by the first server, and extract the target shard corresponding to the sub-range from the shard download response; Wherein, the preset database further includes a download status of each target shard, and the download status includes: not downloaded, downloading, and downloaded; for each target shard, "not downloaded" means that the browser has not sent a shard download request corresponding to the target shard to the first server, "downloading" means that the browser has sent a shard download request corresponding to the target shard to the first server, and "downloaded" means that the target shard has been stored in the preset database; The download module is specifically configured to: Send shard download requests corresponding to each sub-range to the first server in sequence according to the arrangement order of the sub-ranges in the file range; Alternatively, send shard download requests corresponding to a specified number of sub-ranges to the first server at regular intervals; The apparatus further includes: A combining module, configured to combine each target shard into a binary large object after each target shard included in the target file is stored in the preset database; A generating module, configured to generate a download link for the binary large object; A storage module, configured to save the binary large object to a preset storage location of the terminal where the browser is located when it detects that the download link is triggered, and the preset storage location includes: a default storage location for saving downloaded files in the terminal, or a location selected by the user.

14. The apparatus according to claim 13, wherein, The shard download response further includes an index of the target shard, and the index is used to indicate the position of the target shard in the target file; the download module is specifically configured to: Correspondingly store the target shard and the index included in the shard download response in the preset database.

15. The device according to claim 14, wherein, The download module is specifically configured to: Obtain the maximum index in the indexes of the target shards stored in the preset database; Use the ratio of the maximum index to the number of target shards included in the target file as the download progress of the target file.

16. The apparatus according to claim 14, further comprising: An acquisition module, configured to, if an interruption occurs during the process of downloading each target shard from the first server and a continue-download instruction is received, acquire the maximum index in the indexes of the target shards stored in the preset database. The download module is further configured to download the target shards after the target shard corresponding to the maximum index from the first server.

17. The apparatus according to claim 14, wherein the preset database further includes the download status of the target file; the apparatus further includes: A determination module, configured to determine, from the preset database, the files to be cleaned with the download status being download completed. A deletion module, configured to delete the files to be cleaned, each shard included in the files to be cleaned, and the download status corresponding to the files to be cleaned from the preset database.

18. The apparatus according to claim 13, wherein, The splitting module is specifically configured to: Send a metadata acquisition request to the first server, where the metadata acquisition request is used to request to acquire the metadata of the target file. Receive the metadata acquisition response sent by the first server, and extract the file size of the target file from the metadata of the target file included in the metadata acquisition response.

19. The apparatus according to claim 18, further includes: A sending module, configured to send an authentication request to the second server before sending the metadata acquisition request to the first server, where the authentication request is used to request the second server to authenticate whether the browser has the permission to download the target file. The receiving module is further configured to receive the authentication response sent by the second server. Wherein, the splitting module is specifically configured to: If the authentication response indicates that the browser has the permission to download the target file, send a metadata acquisition request to the first server.

20. The device according to claim 13, wherein, The splitting module is specifically configured to: Acquire a preset shard size. In the file range, sequentially intercept multiple sub-ranges starting from the minimum value of the file range according to the preset shard size, where there is no intersection between the sub-ranges, and the union of the sub-ranges is the file range.

21. The apparatus according to claim 20, further includes: A merging module, configured to merge the penultimate sub-range and the last sub-range if the range size of the last sub-range is less than the preset minimum range size.

22. The device according to claim 13, wherein, The splitting module is specifically configured to: Acquire a preset number of shards. Divide the file range into the preset number of sub-ranges, where there is no intersection between the sub-ranges, and the union of the sub-ranges is the file range.

23. The apparatus according to any one of claims 13-22, further includes: A display module, configured to display the download progress after determining the download progress of the target file.

24. The device according to any one of claims 13-22, wherein, The minimum value of the file range is 0.

25. An electronic device, including: At least one processor; And A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1-12.

26. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-12.

27. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-12.

Citation Information

Patent Citations

  • File fragment downloading method and device

    CN111586103A

  • Streaming-based method for realizing fragmented downloading of large file of browser

    CN118041929A

  • File upload and download methods and associated server

    US20170171295A1