[go: up one dir, main page]

CN117354301A - File downloading method, device, equipment and storage medium - Google Patents

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

Info

Publication number
CN117354301A
CN117354301A CN202311339432.0A CN202311339432A CN117354301A CN 117354301 A CN117354301 A CN 117354301A CN 202311339432 A CN202311339432 A CN 202311339432A CN 117354301 A CN117354301 A CN 117354301A
Authority
CN
China
Prior art keywords
target
download
task
file
download task
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.)
Pending
Application number
CN202311339432.0A
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.)
Shenzhen Lexin Software Technology Co Ltd
Original Assignee
Shenzhen Lexin Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Lexin Software Technology Co Ltd filed Critical Shenzhen Lexin Software Technology Co Ltd
Priority to CN202311339432.0A priority Critical patent/CN117354301A/en
Publication of CN117354301A publication Critical patent/CN117354301A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/62Queue scheduling characterised by scheduling criteria
    • H04L47/625Queue scheduling characterised by scheduling criteria for service slots or service orders
    • H04L47/6275Queue scheduling characterised by scheduling criteria for service slots or service orders based on priority

Landscapes

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

Abstract

The embodiment of the application discloses a file downloading method, device, equipment and storage medium. The method is applied to a file downloading device in target equipment, and comprises the following steps: acquiring at least one target downloading task sent by a target application in target equipment; determining the priority of each target downloading task according to a preset priority strategy; adding each target downloading task into a downloading operation queue of target equipment according to the priority of each target downloading task, and orderly arranging the downloading tasks in the downloading operation queue from high to low according to the priority; determining whether the current downloading task of the downloading operation queue comprises a target downloading task or not according to each target downloading task; and if the current downloading task comprises the target downloading task, downloading target file data corresponding to the target downloading task through a downloader of the target equipment. By implementing the method of the embodiment of the application, the downloading device in the target equipment can execute the downloading task according to the priority of the task.

Description

文件下载方法、装置、设备及存储介质File download methods, devices, equipment and storage media

技术领域Technical field

本申请涉及数据处理技术领域,尤其涉及一种文件下载方法、装置、设备及存储介质。The present application relates to the field of data processing technology, and in particular, to a file downloading method, device, equipment and storage medium.

背景技术Background technique

随着互联网的快速发展,在线数据越来越多,需要进行传输的业务数据也越来越庞大。与此同时,也越来越多的终端支持通过网络连接下载各类数据文件,用户通过终端可快捷地获取网络数据。With the rapid development of the Internet, there is more and more online data, and the business data that needs to be transmitted is also becoming larger and larger. At the same time, more and more terminals support downloading various data files through network connections, and users can quickly obtain network data through the terminals.

例如,用户使用iOS终端进行文件下载是一个非常常用的功能,iOS原生超文本传输协议(HTTP,HyperText Transfer Protocol)会话NSURLSession(一种网络访问接口)提供了DownloadTask与DataTask两种下载器,然而,这两种下载器均无法设置下载任务的优先级,当有下载任务请求下载时,终端只能按照下载请求生成的先后顺序进行下载,当同时存在多个下载任务时,下载器不能按照任务优先级执行下载任务。For example, it is a very common function for users to use iOS terminals to download files. The iOS native Hypertext Transfer Protocol (HTTP, HyperText Transfer Protocol) session NSURLSession (a network access interface) provides two downloaders, DownloadTask and DataTask. However, Both downloaders cannot set the priority of download tasks. When a download task requests downloading, the terminal can only download in the order in which the download requests are generated. When there are multiple download tasks at the same time, the downloader cannot prioritize the tasks. level to perform download tasks.

发明内容Contents of the invention

本申请实施例提供了一种文件下载方法、装置、设备及存储介质,可以使目标设备中的下载器按照任务的优先级执行下载任务。Embodiments of the present application provide a file downloading method, device, equipment and storage medium, which can enable the downloader in the target device to perform downloading tasks according to the priority of the task.

第一方面,本申请实施例提供了一种文件下载方法,所述方法应用于目标设备中的文件下载装置,所述方法包括:In a first aspect, embodiments of the present application provide a file downloading method, which method is applied to a file downloading device in a target device. The method includes:

获取所述目标设备中目标应用发送的至少一个目标下载任务;Obtain at least one target download task sent by the target application in the target device;

根据预设的优先级策略确定各所述目标下载任务的优先级;Determine the priority of each target download task according to the preset priority policy;

根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;According to the priority of each target download task, add each target download task to the download operation queue of the target device, and the download tasks in the download operation queue are arranged in order from high to low according to priority;

针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;For each target download task, determine whether the current download task in the download operation queue includes the target download task;

若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。If the current download task includes the target download task, the target file data corresponding to the target download task is downloaded through the downloader of the target device.

第二方面,本申请实施例还提供了一种文件下载装置,所述文件下载装置部署在目标设备中,所述文件下载装置包括:In a second aspect, embodiments of the present application also provide a file download device, the file download device is deployed in the target device, and the file download device includes:

收发单元,用于获取所述目标设备中目标应用发送的至少一个目标下载任务;A transceiver unit configured to obtain at least one target download task sent by a target application in the target device;

处理单元,用于根据预设的优先级策略确定各所述目标下载任务的优先级;根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。A processing unit configured to determine the priority of each target download task according to a preset priority policy; and add each target download task to the download operation queue of the target device according to the priority of each target download task. , the download tasks in the download operation queue are arranged in order from high to low priority; for each target download task, it is determined whether the current download task of the download operation queue includes the target download task; if the If the current download task includes the target download task, the target file data corresponding to the target download task is downloaded through the downloader of the target device.

第三方面,本申请实施例还提供了一种目标设备,其包括存储器及处理器,所述存储器上存储有计算机程序,所述处理器执行所述计算机程序时实现上述方法。In a third aspect, embodiments of the present application also provide a target device, which includes a memory and a processor. A computer program is stored on the memory. When the processor executes the computer program, the above method is implemented.

第四方面,本申请实施例还提供了一种计算机可读存储介质,所述存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时可实现上述方法。In a fourth aspect, embodiments of the present application also provide a computer-readable storage medium, the storage medium stores a computer program, the computer program includes program instructions, and when executed by a processor, the program instructions can implement the above method. .

本申请实施例提供了一种文件下载方法、装置、设备及存储介质。所述方法应用于目标设备中的文件下载装置,其中,当文件下载装置获取到目标设备中目标应用发送的至少一个目标下载任务之后,将根据预设的优先级策略确定各所述目标下载任务的优先级;然后再根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。本申请实施例由于在下载器进行任务下载之前,会先按照任务的优先级将任务加入下载操作队列中,再按照下载操作队列中任务的排列顺序依次请求下载器执行文件下载,故本申请实施例中的下载器可以按照任务的优先级执行下载任务。Embodiments of the present application provide a file downloading method, device, equipment and storage medium. The method is applied to a file download device in a target device, where, after the file download device obtains at least one target download task sent by a target application in the target device, each of the target download tasks will be determined according to a preset priority policy. priority; and then add each target download task to the download operation queue of the target device according to the priority of each target download task, and the download tasks in the download operation queue are arranged in order from high to high priority. Arranged in order of low; for each target download task, determine whether the current download task of the download operation queue includes the target download task; if the current download task includes the target download task, then through the target device The downloader downloads the target file data corresponding to the target download task. In the embodiment of this application, before the downloader downloads the task, it will first add the task to the download operation queue according to the priority of the task, and then request the downloader to perform file download in sequence according to the order of tasks in the download operation queue. Therefore, this application is implemented The downloader in the example can perform download tasks according to the priority of the task.

附图说明Description of drawings

为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present application, which are of great significance to this field. Ordinary technicians can also obtain other drawings based on these drawings without exerting creative work.

图1为本申请实施例提供的文件下载方法的应用场景示意图;Figure 1 is a schematic diagram of the application scenario of the file download method provided by the embodiment of the present application;

图2为本申请实施例提供的文件下载方法的流程示意图;Figure 2 is a schematic flow chart of a file downloading method provided by an embodiment of the present application;

图3为本申请实施例提供的文件下载装置的示意性框图;Figure 3 is a schematic block diagram of a file download device provided by an embodiment of the present application;

图4为本申请实施例提供的目标设备的示意性框图。Figure 4 is a schematic block diagram of a target device provided by an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.

应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that, when used in this specification and the appended claims, the terms "comprises" and "comprises" indicate the presence of described features, integers, steps, operations, elements and/or components but do not exclude the presence of one or The presence or addition of multiple other features, integers, steps, operations, elements, components and/or collections thereof.

还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。It should also be understood that the terminology used in the specification of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a", "an" and "the" are intended to include the plural forms unless the context clearly dictates otherwise.

还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It will be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items. .

本申请实施例提供了一种文件下载方法、装置、设备及存储介质。Embodiments of the present application provide a file downloading method, device, equipment and storage medium.

该文件下载方法的执行主体可以是本申请实施例提供的文件下载装置,或者集成了该文件下载装置的目标设备,其中,该文件下载装置可以采用硬件或者软件的方式实现,该目标设备可以为终端,该终端可以是智能手机、平板电脑、掌上电脑、或者笔记本电脑等。The execution subject of the file downloading method may be the file downloading device provided in the embodiment of the present application, or a target device integrated with the file downloading device, where the file downloading device may be implemented in hardware or software, and the target device may be Terminal, the terminal can be a smart phone, a tablet computer, a handheld computer, or a laptop computer, etc.

其中,在一些实施例中,本申请实施例中提供的目标设备为iOS设备,下载器为该iOS设备的原生下载器,如DataTask,下载操作队列为iOS设备的原生操作队列,如NSOperationQueue,可见,在该实施例中,本申请实施例提供的文件下载装置即复用了iOS设备核心的网络加载能力,又通过原生操作队列提高了下载任务的可操作性(调整原生下载器的下载顺序),本实施例提供的文件下载装置包括目标设备中的原始操作队列以及原生下载器。Among them, in some embodiments, the target device provided in the embodiment of the present application is an iOS device, the downloader is the native downloader of the iOS device, such as DataTask, and the download operation queue is the native operation queue of the iOS device, such as NSOperationQueue. It can be seen that , in this embodiment, the file download device provided by the embodiment of the present application not only reuses the network loading capability of the core of the iOS device, but also improves the operability of the download task through the native operation queue (adjusting the download order of the native downloader) , The file download device provided in this embodiment includes the original operation queue and the native downloader in the target device.

请参阅图1,图1为本申请实施例提供的文件下载方法的应用场景示意图。该文件下载方法应用于图1中的文件下载装置10中,该文件下载装置10部署在目标设备中,该目标设备中还安装有至少一个目标应用20,目标应用20可以调用文件下载装置10实现文件下载。Please refer to Figure 1. Figure 1 is a schematic diagram of an application scenario of the file download method provided by an embodiment of the present application. This file download method is applied to the file download device 10 in Figure 1. The file download device 10 is deployed in the target device. The target device is also installed with at least one target application 20. The target application 20 can call the file download device 10 to implement Download Document.

具体地,当目标应用20有任务需要进行下载时,将根据需求生成至少一个目标下载任务,并将调用文件下载装置10的接口,将目标下载任务发送给文件下载装置10,此时文件下载装置10将获取至少一个目标下载任务;然后根据预设的优先级策略确定各所述目标下载任务的优先级;根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。Specifically, when the target application 20 has a task that needs to be downloaded, at least one target download task will be generated according to the demand, and the interface of the file download device 10 will be called to send the target download task to the file download device 10. At this time, the file download device 10. Obtain at least one target download task; then determine the priority of each target download task according to the preset priority policy; and add each target download task to the target according to the priority of each target download task. In the download operation queue of the device, the download tasks in the download operation queue are arranged in order from high to low priority; for each target download task, it is determined whether the current download task of the download operation queue includes the target download Task; if the current download task includes the target download task, download the target file data corresponding to the target download task through the downloader of the target device.

图2是本申请实施例提供的文件下载方法的流程示意图。如图2所示,该方法包括以下步骤S110-S150。Figure 2 is a schematic flowchart of a file downloading method provided by an embodiment of the present application. As shown in Figure 2, the method includes the following steps S110-S150.

S110、获取所述目标设备中目标应用发送的至少一个目标下载任务。S110. Obtain at least one target download task sent by the target application in the target device.

本实施例中,当目标下载任务有多个时,多个目标下载任务可以来自于目标设备中的一个或多个目标应用。In this embodiment, when there are multiple target download tasks, the multiple target download tasks may come from one or more target applications in the target device.

具体地,当目标应用需要下载目标文件数据时,会向目标设备内的文件下载装置发送对应的目标下载任务。Specifically, when the target application needs to download target file data, the corresponding target download task will be sent to the file download device in the target device.

S120、根据预设的优先级策略确定各所述目标下载任务的优先级。S120: Determine the priority of each target download task according to a preset priority policy.

在一些实施例中,该优先级策略包括第一优先级策略、第二优先级策略或第三优先级策略,其中:In some embodiments, the priority policy includes a first priority policy, a second priority policy, or a third priority policy, wherein:

第一优先级策略包括:根据预先设置的优先级对应关系确定目标下载任务的优先级,其中,该优先级对应关系包括数据类型标识与优先级的对应关系。The first priority strategy includes: determining the priority of the target download task according to a preset priority correspondence, wherein the priority correspondence includes a correspondence between a data type identifier and a priority.

此时,每个目标下载任务都携带有目标数据类型标识,该目标数据类型标识可以为数据本身的数据属性标识,或者数据产生的场景类型标识,即在优先级对应关系中,针对不同的数据产生场景或不同的数据属性设置了不同的优先级,其中,该数据产生场景包括应用页面打开场景、聊天框接收文件场景以及文件主动下载场景等,其中,数据属性包括图片、word文档、ppt文档以及h5页面数据等。At this time, each target download task carries a target data type identifier. The target data type identifier can be the data attribute identifier of the data itself, or the scene type identifier of the data generation, that is, in the priority correspondence relationship, for different data Generation scenarios or different data attributes are set with different priorities. Among them, the data generation scenarios include application page opening scenarios, chat box receiving file scenarios, and file active download scenarios. Among them, data attributes include pictures, word documents, and ppt documents. And h5 page data, etc.

第二优先级策略包括:根据目标下载任务中携带的优先级信息确定目标下载任务的优先级。The second priority strategy includes: determining the priority of the target download task according to the priority information carried in the target download task.

此时,每一个目标下载任务都携带有优先级信息,该优先级信息在用户触发对应的下载任务时,由用户自行设置的,或者,用户预先在对应的目标应用中预先设置的,其中,该优先级信息包括优先级的等级。At this time, each target download task carries priority information, which is set by the user when the user triggers the corresponding download task, or is preset by the user in the corresponding target application, where, The priority information includes a level of priority.

第三优先级策略包括:若目标下载任务中携带有优先级信息,则优先按照所携带的优先级信息确定优先级,若目标下载任务中没有携带优先级信息,则进一步获取目标下载任务的目标数据类型标识,然后根据该目标数据类型标识以及优先级之间的对应关系确定所述目标下载任务的优先级(没有携带优先级信息的情况可参考第一优先级策略)。The third priority strategy includes: if the target download task carries priority information, the priority will be determined based on the priority information carried. If the target download task does not carry priority information, then the target of the target download task will be further obtained. data type identifier, and then determine the priority of the target download task according to the corresponding relationship between the target data type identifier and the priority (if no priority information is carried, refer to the first priority policy).

此时,步骤S120包括:若所述目标下载任务中携带有优先级信息,则根据所述优先级信息确定所述目标下载任务的优先级;若所述目标下载任务中不携带优先级信息,则根据所述目标下载任务的目标数据类型标识以及预设的优先级之间的对应关系确定所述目标下载任务的优先级。此时,目标下载任务中可以携带优先级信息(若用户有设置则携带),也可以不携带优先级信息。At this time, step S120 includes: if the target download task carries priority information, determining the priority of the target download task according to the priority information; if the target download task does not carry priority information, Then, the priority of the target download task is determined according to the corresponding relationship between the target data type identifier of the target download task and the preset priority. At this time, the target download task may carry priority information (if the user has set it, it will be carried), or it may not carry priority information.

S130、根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中。S130. Add each target download task to the download operation queue of the target device according to the priority of each target download task.

其中,所述下载操作队列中的下载任务按照优先级从高到低依次排列,优先级的优先下载。Wherein, the download tasks in the download operation queue are arranged in order from high to low priority, and those with priority are downloaded first.

本实施例中,下载操作队列用于按照优先级的高低对待执行的候选下载任务进行排序,在加入目标下载任务之前,下载操作队列中可能已经存在一个或多个候选下载任务,每个候选下载任务都有其对应的优先级,此时,可以根据优先级的大小将目标下载任务插入下载操作队列中;此外,若在加入目标下载任务之前,下载操作队列中没有候选下载任务,此时,在下载操作队列中直接按照各个目标下载任务的优先级进行排序。In this embodiment, the download operation queue is used to sort candidate download tasks to be executed according to priority. Before adding the target download task, one or more candidate download tasks may already exist in the download operation queue. Each candidate download task Tasks have their corresponding priorities. At this time, the target download task can be inserted into the download operation queue according to the priority; in addition, if there are no candidate download tasks in the download operation queue before adding the target download task, at this time, Sort directly according to the priority of each target download task in the download operation queue.

S140、针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务。S140. For each target download task, determine whether the current download task in the download operation queue includes the target download task.

本实施例中,下载器会向下载操作队列实时汇报下载情况,例如,会实时向下载操作队列报告当前空闲下载位置数量,下载操作队列会根据从下载操作队列中选取优先级最高的当前空闲下载位置数量的下载任务作为当前下载任务,当前下载任务即当前需要执行下载的任务。In this embodiment, the downloader will report the download status to the download operation queue in real time. For example, it will report the current number of idle download locations to the download operation queue in real time. The download operation queue will select the current idle download with the highest priority from the download operation queue. The download task with the number of locations is regarded as the current download task, and the current download task is the task that currently needs to be downloaded.

此时,在确定所述下载操作队列的当前下载任务是否包括所述目标下载任务之前,需要先获取所述下载器发送的当前空闲下载位置数量;然后文件下载装置再根据所述当前空闲下载位置数量从所述下载操作队列中确定当前下载任务;At this time, before determining whether the current download task in the download operation queue includes the target download task, it is necessary to first obtain the number of current idle download locations sent by the downloader; The number determines the current download task from the download operation queue;

其中,若当前下载器是空闲的,则该当前空闲下载位置数量为目标任务并发数量,目标任务并发数量减去下载器当前在执行的任务数量即当前空闲下载位置数量,该目标任务并发数量为下载器的最大并发下载数量,该目标任务并发数量可由用户设置,也可以为下载器的默认配置。Among them, if the current downloader is idle, the current number of idle download locations is the target concurrency number of tasks. The target concurrency number minus the number of tasks currently being executed by the downloader is the current number of idle download locations. The target concurrency number is The maximum number of concurrent downloads of the downloader. This target number of concurrent tasks can be set by the user, or it can be the default configuration of the downloader.

S150、若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。S150. If the current download task includes the target download task, download the target file data corresponding to the target download task through the downloader of the target device.

本实施例中,若当前下载任务中包括目标下载任务,则说明当前需要通过下载器执行该目标下载任务的下载操作。In this embodiment, if the current download task includes a target download task, it means that the download operation of the target download task currently needs to be performed by the downloader.

具体地,在一些实施例中,所述目标下载任务携带有目标下载地址、目标下载头以及目标文件名称,所述通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据,包括:Specifically, in some embodiments, the target download task carries a target download address, a target download header, and a target file name, and the target file data corresponding to the target download task is downloaded through the downloader of the target device, include:

根据所述目标下载地址以及所述目标下载头生成目标下载请求;通过所述下载器向服务器发送所述目标下载请求;接收所述服务器基于所述目标下载请求返回的所述目标文件数据,并将所述目标文件数据存储在与所述目标文件名称对应的目标缓存文件中,该目标缓存文件可以为tmp缓存路径中的文件。Generate a target download request according to the target download address and the target download header; send the target download request to the server through the downloader; receive the target file data returned by the server based on the target download request, and The target file data is stored in a target cache file corresponding to the target file name. The target cache file may be a file in the tmp cache path.

其中,向服务器发送目标下载请求之后,将在下载操作队列中删除对应的下载任务,具体地,文件下载装置通过http会话向下载器发送该目标下载请求,该目标下载请求包括目标下载地址以及请求头,该请求头为http header,该请求头中包括range值,该range值基于目标下载头确定得到。After sending the target download request to the server, the corresponding download task will be deleted from the download operation queue. Specifically, the file download device sends the target download request to the downloader through the http session. The target download request includes the target download address and the request header, the request header is an http header, and the request header includes a range value, which is determined based on the target download header.

在一些实施例中,本申请实施例中的文件下载装置还提供文件的断点续传功能,若通过匹配本地的本地缓存目录发现已经存在与该下载任务对应的文件,此时,说明已经下载过该下载任务,若该任务未下载完全,则通过调整对应的下载区间,对该任务执行断点续传功能。In some embodiments, the file download device in the embodiment of the present application also provides a breakpoint resume function for files. If it is found that a file corresponding to the download task already exists by matching the local cache directory, at this time, it means that the file has been downloaded. After passing the download task, if the task is not completely downloaded, the breakpoint resume function will be executed for the task by adjusting the corresponding download interval.

针对目标下载任务,具体地,在一些实施例中,所述根据所述目标下载地址以及所述目标下载头生成目标下载请求之前,所述方法还包括:For the target download task, specifically, in some embodiments, before generating a target download request according to the target download address and the target download header, the method further includes:

检测本地缓存目录中是否包括所述目标文件名称,所述本地缓存目录包括多个缓存文件分别对应的缓存文件名称,所述缓存文件为未下载完成的文件;若所述本地缓存目录中包括所述目标文件名称,则获取与所述目标文件名称对应的目标缓存文件的文件大小;根据所述文件大小调整所述目标下载头。Detect whether the target file name is included in the local cache directory. The local cache directory includes cache file names corresponding to multiple cache files. The cache files are files that have not been downloaded; if the local cache directory includes the cache file names, If the target file name is specified, the file size of the target cache file corresponding to the target file name is obtained; and the target download header is adjusted according to the file size.

此时,根据调整后的目标下载头生成目标下载请求,可实现对目标下载任务的断点续传,从而节约目标下载任务的下载流量以及提高目标下载任务的下载效率。At this time, the target download request is generated based on the adjusted target download header, and the target download task can be resumed at a breakpoint, thereby saving the download traffic of the target download task and improving the download efficiency of the target download task.

例如,目标应用请求下载一个1024K的文件,已经下载了其中512K,由于网络中断,目标应用请求续传,此时,目标应用也会向文件下载装置发送一目标下载任务,此时,通过匹配本地的本地缓存目录发现已经存在与该目标下载任务对应的目标缓存文件,且目标缓存文件的文件大小为512K,此时,将下载头的range值从默认的“bytes=0”调整为“bytes=512000”,服务器接收到该目标下载请求之后,将从文件的512K位置开始传输,并且在HTTP头中增加:bytes512000-/1024000。For example, the target application requests to download a 1024K file, of which 512K has been downloaded. Due to the network interruption, the target application requests to resume the download. At this time, the target application will also send a target download task to the file download device. At this time, by matching the local It is found that the target cache file corresponding to the target download task already exists in the local cache directory, and the file size of the target cache file is 512K. At this time, the range value of the download header is adjusted from the default "bytes=0" to "bytes= 512000", after the server receives the target download request, it will start transmission from the 512K position of the file, and add: bytes512000-/1024000 to the HTTP header.

其中,若发现目标缓存文件的大小为目标文件的大小,此时,将返回完成下载信息,结束所述目标下载任务的下载流程。If it is found that the size of the target cache file is the size of the target file, then the download completion information will be returned and the download process of the target download task will be ended.

具体地,在一些实施例中,具体通过以下步骤检测本地缓存目录中是否包括所述目标文件名称:Specifically, in some embodiments, the following steps are used to detect whether the target file name is included in the local cache directory:

对所述目标文件名称进行哈希值转换处理,得到所述目标文件名称对应的目标哈希值;确定所述本地缓存目录中是否存在与所述目标哈希值相同的缓存文件名称;若存在与所述目标哈希值相同的缓存文件名称,则确定所述本地缓存目录中包括所述目标文件名称;若不存在与所述目标哈希值相同的缓存文件名称,则确定所述本地缓存目录中不包括所述目标文件名称。Perform hash value conversion processing on the target file name to obtain the target hash value corresponding to the target file name; determine whether there is a cache file name with the same target hash value in the local cache directory; if there is If the cache file name is the same as the target hash value, it is determined that the local cache directory contains the target file name; if there is no cache file name that is the same as the target hash value, it is determined that the local cache The target file name is not included in the directory.

即,本地缓存目录中存储的文件名称的哈希值。That is, the hash of the file name stored in the local cache directory.

其中,所述将所述目标文件数据存储在与所述目标文件名称的对应目标缓存文件中之后,所述方法还包括:Wherein, after storing the target file data in the target cache file corresponding to the target file name, the method further includes:

根据所述目标缓存文件的文件大小与所述目标下载任务对应的任务大小确定所述目标文件数据是否下载完毕;若确定所述目标文件数据下载完毕,则将所述目标缓存文件转换为目标可用文件,然后向目标应用返回目标可用文件的目标文件数据,例如文件路径以及元数据。Determine whether the target file data has been downloaded according to the file size of the target cache file and the task size corresponding to the target download task; if it is determined that the target file data has been downloaded, convert the target cache file into a target available file, and then returns the target file data, such as the file path and metadata, of the file available to the target to the target application.

其中,本实施例通过修改文件的后缀将目标缓存文件转换为目标可用文件。Among them, this embodiment converts the target cache file into a target available file by modifying the suffix of the file.

若下载中途出现异常,则目标下载任务对应的目标缓存文件,并返回异常信息。If an exception occurs during the download, the target downloads the target cache file corresponding to the task and returns the exception information.

综上所述,本申请实施例提供的文件下载方法应用于目标设备中的文件下载装置,其中,当文件下载装置获取到目标设备中目标应用发送的至少一个目标下载任务之后,将根据预设的优先级策略确定各所述目标下载任务的优先级;然后再根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。本申请实施例由于在下载器进行任务下载之前,会先按照任务的优先级将任务加入下载操作队列中,再按照下载操作队列中任务的排列顺序依次请求下载器执行文件下载,故本申请实施例中的下载器可以按照任务的优先级执行下载任务。To sum up, the file download method provided by the embodiment of the present application is applied to the file download device in the target device. After the file download device obtains at least one target download task sent by the target application in the target device, it will download the file according to the preset The priority policy determines the priority of each target download task; and then adds each target download task to the download operation queue of the target device according to the priority of each target download task, and the download operation The download tasks in the queue are arranged in order from high to low priority; for each target download task, it is determined whether the current download task of the download operation queue includes the target download task; if the current download task includes the Target download task, then download the target file data corresponding to the target download task through the downloader of the target device. In the embodiment of this application, before the downloader downloads the task, it will first add the task to the download operation queue according to the priority of the task, and then request the downloader to perform file download in sequence according to the order of tasks in the download operation queue. Therefore, this application is implemented The downloader in the example can perform download tasks according to the priority of the task.

图3是本申请实施例提供的一种文件下载装置的示意性框图。如图3所示,对应于以上文件下载方法,本申请还提供一种文件下载装置。该文件下载装置包括用于执行上述文件下载方法的单元,该装置被配置于目标设备中,该目标设备为终端。具体地,请参阅图3,该文件下载装置300包括收发单元301以及下载单元302,其中:Figure 3 is a schematic block diagram of a file downloading device provided by an embodiment of the present application. As shown in Figure 3, corresponding to the above file downloading method, this application also provides a file downloading device. The file downloading device includes a unit for executing the above file downloading method. The device is configured in a target device, and the target device is a terminal. Specifically, please refer to Figure 3. The file download device 300 includes a transceiver unit 301 and a download unit 302, where:

收发单元301,用于获取所述目标设备中目标应用发送的至少一个目标下载任务;The transceiver unit 301 is configured to obtain at least one target download task sent by the target application in the target device;

处理单元302,用于根据预设的优先级策略确定各所述目标下载任务的优先级;根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。The processing unit 302 is configured to determine the priority of each target download task according to a preset priority policy; and add each target download task to the download operation of the target device according to the priority of each target download task. In the queue, the download tasks in the download operation queue are arranged in order from high to low priority; for each target download task, it is determined whether the current download task of the download operation queue includes the target download task; if If the current download task includes the target download task, the target file data corresponding to the target download task is downloaded through the downloader of the target device.

在一些实施例中,所述处理单元302在执行所述根据预设的优先级策略确定各所述目标下载任务的优先级步骤时,具体用于:In some embodiments, when performing the step of determining the priority of each target download task according to a preset priority policy, the processing unit 302 is specifically configured to:

若所述目标下载任务中携带有优先级信息,则根据所述优先级信息确定所述目标下载任务的优先级;若所述目标下载任务中不携带优先级信息,则根据所述目标下载任务的目标数据类型标识以及预设的优先级之间的对应关系确定所述目标下载任务的优先级,所述优先级对应关系包括数据类型标识与优先级的对应关系。If the target download task carries priority information, then determine the priority of the target download task based on the priority information; if the target download task does not carry priority information, then determine the priority of the target download task based on the priority information. The corresponding relationship between the target data type identifier and the preset priority determines the priority of the target download task, and the priority corresponding relationship includes the corresponding relationship between the data type identifier and the priority.

在一些实施例中,所述处理单元302在执行所述确定所述下载操作队列的当前下载任务是否包括所述目标下载任务步骤之前,还用于:In some embodiments, before executing the step of determining whether the current download task of the download operation queue includes the target download task, the processing unit 302 is also configured to:

通过所述收发单元301获取所述下载器发送的当前空闲下载位置数量;Obtain the current number of free download locations sent by the downloader through the transceiver unit 301;

此时,所述处理单元302执行所述确定所述下载操作队列的当前下载任务是否包括所述目标下载任务步骤时,具体用于:At this time, when the processing unit 302 performs the step of determining whether the current download task of the download operation queue includes the target download task, it is specifically used to:

根据所述当前空闲下载位置数量从所述下载操作队列中确定当前下载任务;确定所述当前下载任务中是否包括所述目标下载任务。Determine the current download task from the download operation queue according to the current number of idle download locations; determine whether the current download task includes the target download task.

在一些实施例中,所述目标下载任务携带有目标下载地址、目标下载头以及目标文件名称,所述处理单元302在执行所述通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据步骤时,具体用于:In some embodiments, the target download task carries a target download address, a target download header, and a target file name. The processing unit 302 performs the downloading of the target download task corresponding to the target download task through the downloader of the target device. Target file data step, specifically used for:

根据所述目标下载地址以及所述目标下载头生成目标下载请求;基于所述收发单元301通过所述下载器向服务器发送所述目标下载请求;通过所述收发单元301接收所述服务器基于所述目标下载请求返回的所述目标文件数据,并将所述目标文件数据存储在与所述目标文件名称对应的目标缓存文件中。Generate a target download request according to the target download address and the target download header; send the target download request to the server through the downloader based on the transceiver unit 301; receive the target download request based on the server based on the transceiver unit 301. The target downloads the target file data returned by the request, and stores the target file data in a target cache file corresponding to the target file name.

在一些实施例中,所述处理单元302在执行所述根据所述目标下载地址以及所述目标下载头生成目标下载请求步骤之前,还用于:In some embodiments, before executing the step of generating a target download request according to the target download address and the target download header, the processing unit 302 is also configured to:

检测本地缓存目录中是否包括所述目标文件名称,所述本地缓存目录包括多个缓存文件分别对应的缓存文件名称,所述缓存文件为未下载完成的文件;若所述本地缓存目录中包括所述目标文件名称,则获取与所述目标文件名称对应的目标缓存文件的文件大小;根据所述文件大小调整所述目标下载头。Detect whether the target file name is included in the local cache directory. The local cache directory includes cache file names corresponding to multiple cache files. The cache files are files that have not been downloaded; if the local cache directory includes the cache file names, If the target file name is specified, the file size of the target cache file corresponding to the target file name is obtained; and the target download header is adjusted according to the file size.

在一些实施例中,所述处理单元302在执行所述检测本地缓存目录中是否包括所述目标文件名称步骤时,具体用于:In some embodiments, when performing the step of detecting whether the target file name is included in the local cache directory, the processing unit 302 is specifically configured to:

对所述目标文件名称进行哈希值转换处理,得到所述目标文件名称对应的目标哈希值;确定所述本地缓存目录中是否存在与所述目标哈希值相同的缓存文件名称;若存在与所述目标哈希值相同的缓存文件名称,则确定所述本地缓存目录中包括所述目标文件名称;若不存在与所述目标哈希值相同的缓存文件名称,则确定所述本地缓存目录中不包括所述目标文件名称。Perform hash value conversion processing on the target file name to obtain the target hash value corresponding to the target file name; determine whether there is a cache file name with the same target hash value in the local cache directory; if there is If the cache file name is the same as the target hash value, it is determined that the local cache directory contains the target file name; if there is no cache file name that is the same as the target hash value, it is determined that the local cache The target file name is not included in the directory.

在一些实施例中,所述处理单元302在执行所述将所述目标文件数据存储在与所述目标文件名称的对应目标缓存文件中步骤之后,还用于:In some embodiments, after performing the step of storing the target file data in the target cache file corresponding to the target file name, the processing unit 302 is also configured to:

根据所述目标缓存文件的文件大小与所述目标下载任务对应的任务大小确定所述目标文件数据是否下载完毕;若确定所述目标文件数据下载完毕,则将所述目标缓存文件转换为目标可用文件。Determine whether the target file data has been downloaded according to the file size of the target cache file and the task size corresponding to the target download task; if it is determined that the target file data has been downloaded, convert the target cache file into a target available document.

综上所述,由于在下载器进行任务下载之前,文件下载装置300会先按照任务的优先级将任务加入下载操作队列中,再按照下载操作队列中任务的排列顺序依次请求下载器执行文件下载,故本申请实施例中的下载器可以按照任务的优先级执行下载任务。To sum up, before the downloader downloads a task, the file download device 300 will first add the task to the download operation queue according to the priority of the task, and then sequentially request the downloader to perform file download according to the order of tasks in the download operation queue. , so the downloader in the embodiment of the present application can execute the download task according to the priority of the task.

需要说明的是,所属领域的技术人员可以清楚地了解到,上述文件下载装置和各单元的具体实现过程,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。It should be noted that those skilled in the art can clearly understand that for the specific implementation process of the above file downloading device and each unit, reference can be made to the corresponding descriptions in the foregoing method embodiments. For the convenience and simplicity of description, they will not be described here. Repeat.

上述文件下载装置可以实现为一种计算机程序的形式,该计算机程序可以在如图4所示的目标设备上运行。The above file downloading device can be implemented in the form of a computer program, and the computer program can be run on the target device as shown in Figure 4.

请参阅图4,图4是本申请实施例提供的一种目标设备的示意性框图。该目标设备400可以为终端,该目标设备400中部署有文件下载装置。Please refer to Figure 4, which is a schematic block diagram of a target device provided by an embodiment of the present application. The target device 400 may be a terminal, and a file download device is deployed in the target device 400 .

参阅图4,该目标设备400包括通过系统总线401连接的处理器402、存储器和网络接口405,其中,存储器可以包括非易失性存储介质403和内存储器404。Referring to Figure 4, the target device 400 includes a processor 402, a memory and a network interface 405 connected through a system bus 401, where the memory may include a non-volatile storage medium 403 and an internal memory 404.

该非易失性存储介质403可存储操作系统4031和计算机程序4032。该计算机程序4032包括程序指令,该程序指令被执行时,可使得处理器402执行一种文件下载方法。The non-volatile storage medium 403 can store an operating system 4031 and a computer program 4032. The computer program 4032 includes program instructions, which when executed, can cause the processor 402 to perform a file downloading method.

该处理器402用于提供计算和控制能力,以支撑整个目标设备400的运行。The processor 402 is used to provide computing and control capabilities to support the operation of the entire target device 400 .

该内存储器404为非易失性存储介质403中的计算机程序4032的运行提供环境,该计算机程序4032被处理器402执行时,可使得处理器402执行一种文件下载方法。The internal memory 404 provides an environment for the execution of the computer program 4032 in the non-volatile storage medium 403. When the computer program 4032 is executed by the processor 402, it can cause the processor 402 to perform a file download method.

该网络接口405用于与其它设备进行网络通信。本领域技术人员可以理解,图4中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的目标设备400的限定,具体的目标设备400可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface 405 is used for network communication with other devices. Those skilled in the art can understand that the structure shown in Figure 4 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the target device 400 to which the solution of the present application is applied. Specific target devices 400 may include more or fewer components than shown, some combinations of components, or a different arrangement of components.

其中,所述处理器402用于运行存储在存储器中的计算机程序4032,以实现如下步骤:Wherein, the processor 402 is used to run the computer program 4032 stored in the memory to implement the following steps:

获取所述目标设备中目标应用发送的至少一个目标下载任务;Obtain at least one target download task sent by the target application in the target device;

根据预设的优先级策略确定各所述目标下载任务的优先级;Determine the priority of each target download task according to the preset priority policy;

根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;According to the priority of each target download task, add each target download task to the download operation queue of the target device, and the download tasks in the download operation queue are arranged in order from high to low according to priority;

针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;For each target download task, determine whether the current download task in the download operation queue includes the target download task;

若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。If the current download task includes the target download task, the target file data corresponding to the target download task is downloaded through the downloader of the target device.

应当理解,在本申请实施例中,处理器402可以是中央处理单元(CentralProcessing Unit,CPU),该处理器402还可以是其他通用处理器、数字信号处理器(DigitalSignal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that in this embodiment of the present application, the processor 402 may be a central processing unit (Central Processing Unit, CPU). The processor 402 may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), dedicated integrated processors, etc. Circuit (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general processor may be a microprocessor or the processor may be any conventional processor.

本领域普通技术人员可以理解的是实现上述实施例的方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成。该计算机程序包括程序指令,计算机程序可存储于一存储介质中,该存储介质为计算机可读存储介质。该程序指令被该计算机系统中的至少一个处理器执行,以实现上述方法的实施例的流程步骤。Those of ordinary skill in the art can understand that all or part of the processes in the methods of implementing the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, and the storage medium is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above method.

因此,本申请还提供一种存储介质。该存储介质可以为计算机可读存储介质。该存储介质存储有计算机程序,其中计算机程序包括程序指令。该程序指令被处理器执行时使处理器执行如下步骤:Therefore, this application also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, where the computer program includes program instructions. When executed by the processor, the program instructions cause the processor to perform the following steps:

获取所述目标设备中目标应用发送的至少一个目标下载任务;Obtain at least one target download task sent by the target application in the target device;

根据预设的优先级策略确定各所述目标下载任务的优先级;Determine the priority of each target download task according to the preset priority policy;

根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;According to the priority of each target download task, add each target download task to the download operation queue of the target device, and the download tasks in the download operation queue are arranged in order from high to low according to priority;

针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;For each target download task, determine whether the current download task in the download operation queue includes the target download task;

若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。If the current download task includes the target download task, the target file data corresponding to the target download task is downloaded through the downloader of the target device.

所述存储介质可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的计算机可读存储介质。The storage medium may be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk or an optical disk, and other computer-readable storage media that can store program codes.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of both. In order to clearly illustrate the relationship between hardware and software Interchangeability, in the above description, the composition and steps of each example have been generally described according to functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered beyond the scope of this application.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的。例如,各个单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only a logical function division, and there may be other division methods during actual implementation. For example multiple units or components may be combined or integrated into another system, or some features may be omitted, or not implemented.

本申请实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减。本申请实施例装置中的单元可以根据实际需要进行合并、划分和删减。另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。The steps in the methods of the embodiments of this application can be sequence adjusted, combined, and deleted according to actual needs. The units in the device of the embodiment of the present application can be merged, divided, and deleted according to actual needs. In addition, each functional unit in various embodiments of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.

该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,终端,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause a computer device (which can be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application.

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person familiar with the technical field can easily think of various equivalent methods within the technical scope disclosed in the present application. Modification or replacement, these modifications or replacements shall be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims (10)

1.一种文件下载方法,其特征在于,所述方法应用于目标设备中的文件下载装置,所述方法包括:1. A file downloading method, characterized in that the method is applied to a file downloading device in a target device, and the method includes: 获取所述目标设备中目标应用发送的至少一个目标下载任务;Obtain at least one target download task sent by the target application in the target device; 根据预设的优先级策略确定各所述目标下载任务的优先级;Determine the priority of each target download task according to the preset priority policy; 根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;According to the priority of each target download task, add each target download task to the download operation queue of the target device, and the download tasks in the download operation queue are arranged in order from high to low according to priority; 针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;For each target download task, determine whether the current download task in the download operation queue includes the target download task; 若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。If the current download task includes the target download task, the target file data corresponding to the target download task is downloaded through the downloader of the target device. 2.根据权利要求1所述的方法,其特征在于,所述根据预设的优先级策略确定各所述目标下载任务的优先级,包括:2. The method of claim 1, wherein determining the priority of each target download task according to a preset priority policy includes: 若所述目标下载任务中携带有优先级信息,则根据所述优先级信息确定所述目标下载任务的优先级;If the target download task carries priority information, determine the priority of the target download task based on the priority information; 若所述目标下载任务中不携带优先级信息,则根据所述目标下载任务的目标数据类型标识以及预设的优先级之间的对应关系确定所述目标下载任务的优先级。If the target download task does not carry priority information, the priority of the target download task is determined according to the corresponding relationship between the target data type identifier of the target download task and the preset priority. 3.根据权利要求1所述的方法,其特征在于,所述确定所述下载操作队列的当前下载任务是否包括所述目标下载任务之前,所述方法还包括:3. The method of claim 1, wherein before determining whether the current download task of the download operation queue includes the target download task, the method further includes: 获取所述下载器发送的当前空闲下载位置数量;Obtain the current number of free download locations sent by the downloader; 所述确定所述下载操作队列的当前下载任务是否包括所述目标下载任务,包括:Determining whether the current download task of the download operation queue includes the target download task includes: 根据所述当前空闲下载位置数量及各下载任务的优先级,从所述下载操作队列中确定当前下载任务;Determine the current download task from the download operation queue according to the current number of idle download locations and the priority of each download task; 确定所述当前下载任务中是否包括所述目标下载任务。Determine whether the current download task includes the target download task. 4.根据权利要求1所述的方法,其特征在于,所述目标下载任务携带有目标下载地址、目标下载头以及目标文件名称,所述通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据,包括:4. The method according to claim 1, wherein the target download task carries a target download address, a target download header and a target file name, and the target download task is downloaded through a downloader of the target device. The corresponding target file data includes: 根据所述目标下载地址以及所述目标下载头生成目标下载请求;Generate a target download request according to the target download address and the target download header; 通过所述下载器向服务器发送所述目标下载请求;Send the target download request to the server through the downloader; 接收所述服务器基于所述目标下载请求返回的所述目标文件数据,并将所述目标文件数据存储在与所述目标文件名称对应的目标缓存文件中。The target file data returned by the server based on the target download request is received, and the target file data is stored in a target cache file corresponding to the target file name. 5.根据权利要求4所述的方法,其特征在于,所述根据所述目标下载地址以及所述目标下载头生成目标下载请求之前,所述方法还包括:5. The method according to claim 4, characterized in that before generating a target download request according to the target download address and the target download header, the method further includes: 检测本地缓存目录中是否包括所述目标文件名称,所述本地缓存目录包括多个缓存文件分别对应的缓存文件名称,所述缓存文件为未下载完成的文件;Detect whether the target file name is included in the local cache directory. The local cache directory includes cache file names corresponding to multiple cache files, and the cache files are files that have not been downloaded; 若所述本地缓存目录中包括所述目标文件名称,则获取与所述目标文件名称对应的目标缓存文件的文件大小;If the target file name is included in the local cache directory, obtain the file size of the target cache file corresponding to the target file name; 根据所述文件大小调整所述目标下载头。Adjust the target download header based on the file size. 6.根据权利要求5所述的方法,其特征在于,所述检测本地缓存目录中是否包括所述目标文件名称,包括:6. The method of claim 5, wherein detecting whether the target file name is included in the local cache directory includes: 对所述目标文件名称进行哈希值转换处理,得到所述目标文件名称对应的目标哈希值;Perform hash value conversion processing on the target file name to obtain a target hash value corresponding to the target file name; 确定所述本地缓存目录中是否存在与所述目标哈希值相同的缓存文件名称;Determine whether a cache file name that is the same as the target hash value exists in the local cache directory; 若存在与所述目标哈希值相同的缓存文件名称,则确定所述本地缓存目录中包括所述目标文件名称;If there is a cache file name that is the same as the target hash value, determine that the local cache directory includes the target file name; 若不存在与所述目标哈希值相同的缓存文件名称,则确定所述本地缓存目录中不包括所述目标文件名称。If there is no cache file name that is the same as the target hash value, it is determined that the target file name is not included in the local cache directory. 7.根据权利要求4所述的方法,其特征在于,所述将所述目标文件数据存储在与所述目标文件名称的对应目标缓存文件中之后,所述方法还包括:7. The method according to claim 4, wherein after storing the target file data in a target cache file corresponding to the target file name, the method further includes: 根据所述目标缓存文件的文件大小与所述目标下载任务对应的任务大小确定所述目标文件数据是否下载完毕;Determine whether the target file data has been downloaded according to the file size of the target cache file and the task size corresponding to the target download task; 若确定所述目标文件数据下载完毕,则将所述目标缓存文件转换为目标可用文件。If it is determined that the target file data has been downloaded, the target cache file is converted into a target available file. 8.一种文件下载装置,其特征在于,所述文件下载装置部署在目标设备中,所述文件下载装置包括:8. A file downloading device, characterized in that the file downloading device is deployed in the target device, and the file downloading device includes: 收发单元,用于获取所述目标设备中目标应用发送的至少一个目标下载任务;A transceiver unit configured to obtain at least one target download task sent by a target application in the target device; 处理单元,用于根据预设的优先级策略确定各所述目标下载任务的优先级;根据各所述目标下载任务的优先级,将各所述目标下载任务加入所述目标设备的下载操作队列中,所述下载操作队列中的下载任务按照优先级从高到低依次排列;针对各所述目标下载任务,确定所述下载操作队列的当前下载任务是否包括所述目标下载任务;若所述当前下载任务包括所述目标下载任务,则通过所述目标设备的下载器下载所述目标下载任务对应的目标文件数据。A processing unit configured to determine the priority of each target download task according to a preset priority policy; and add each target download task to the download operation queue of the target device according to the priority of each target download task. , the download tasks in the download operation queue are arranged in order from high to low priority; for each target download task, it is determined whether the current download task of the download operation queue includes the target download task; if the If the current download task includes the target download task, the target file data corresponding to the target download task is downloaded through the downloader of the target device. 9.一种目标设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1-7中任一项所述的文件下载方法。9. A target device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that when the processor executes the computer program, the processor implements the claims as claimed in The file download method described in any one of 1-7. 10.一种存储介质,其特征在于,所述存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的文件下载方法。10. A storage medium, characterized in that the storage medium stores a computer program, the computer program includes program instructions, and when executed by a processor, the program instructions cause the processor to execute claims 1-7 Any of the file download methods described above.
CN202311339432.0A 2023-10-16 2023-10-16 File downloading method, device, equipment and storage medium Pending CN117354301A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311339432.0A CN117354301A (en) 2023-10-16 2023-10-16 File downloading method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311339432.0A CN117354301A (en) 2023-10-16 2023-10-16 File downloading method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117354301A true CN117354301A (en) 2024-01-05

Family

ID=89370642

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311339432.0A Pending CN117354301A (en) 2023-10-16 2023-10-16 File downloading method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117354301A (en)

Similar Documents

Publication Publication Date Title
US7594022B2 (en) Regulating client requests in an electronic messaging environment
CN107832100B (en) APK plug-in loading method and terminal thereof
CN110764688B (en) Method and device for processing data
CN110968331B (en) Methods and devices for running applications
CN109462650A (en) Data file downloading method, device, computer equipment and storage medium
CN111752582B (en) Software updating method and device in local area network and electronic equipment
WO2023241676A1 (en) Memory pool operation method and apparatus
CN101421719B (en) Managing network response buffering behavior
US20090157896A1 (en) Tcp offload engine apparatus and method for system call processing for static file transmission
CN117354301A (en) File downloading method, device, equipment and storage medium
US7885995B2 (en) Processing service requests in a distributed environment
WO2025200322A1 (en) Installation package generation method and apparatus, code obfuscation methods and apparatuses, and code obfuscation system
CN111400630A (en) Resource preloading method and related equipment
WO2025081566A1 (en) Dns access request processing method and apparatus, device, and storage medium
CN115801769A (en) Channel package obtaining method, electronic device and storage medium
CN117082142A (en) Data packet caching method and device, electronic equipment and storage medium
CN111901689B (en) Streaming media data transmission method, device, terminal equipment and storage medium
CN115412546A (en) File batch downloading method and device
CN114900485B (en) Method, electronic equipment and system for accessing network file storage
CN109688204B (en) File downloading method, node and terminal based on NDN (named data networking)
CN119271263B (en) Cluster-based multi-version compatible method, device and storage medium
CN113254203A (en) Service degradation processing method and device
CN119814758B (en) File transmission control method and device, storage medium and electronic device
US20250291770A1 (en) Seamless NFS Server Pod Addition
CN118733543A (en) Image loading method, device, equipment and storage medium

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