CN112468550A - File downloading method and device and electronic equipment - Google Patents

File downloading method and device and electronic equipment Download PDF

Info

Publication number
CN112468550A
CN112468550A CN202011275014.6A CN202011275014A CN112468550A CN 112468550 A CN112468550 A CN 112468550A CN 202011275014 A CN202011275014 A CN 202011275014A CN 112468550 A CN112468550 A CN 112468550A
Authority
CN
China
Prior art keywords
downloading
file
target file
link address
download
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
CN202011275014.6A
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.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202011275014.6A priority Critical patent/CN112468550A/en
Publication of CN112468550A publication Critical patent/CN112468550A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content

Abstract

The invention provides a file downloading method, a device and electronic equipment, wherein POST request information carrying a specified request header is generated in response to a downloading instruction aiming at a target file, and the POST request information is sent to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file; and receiving binary file data of the target file returned by the back-end server, and downloading the target file based on the binary file data. The method can download files dynamically generated according to the content and files previewed by the browser, and has no limitation on the length of the address character, so that the files can be downloaded based on various user requirements, the downloading method is wide in application range, and the personalized and diversified requirements of file downloading can be met.

Description

File downloading method and device and electronic equipment
Technical Field
The invention relates to the technical field of internet, in particular to a file downloading method and device and electronic equipment.
Background
In order to realize the function of downloading files from a webpage, the jump address of the a label in the webpage code can be set as files which cannot be previewed by the browser, such as files in a doc format, a tar format and a zip format, and the browser can download the files by default because the browser cannot open and preview the files in the formats; however, the method can only download the existing file of the back-end server, and requires that the file cannot be opened and previewed by the browser, so that the limitation condition is more; in another mode, after a back-end server generates a file, a response header Content-Disposition is set for the file, a front-end browser requests an API (Application Programming Interface) of the back-end server through get, the back-end returns the file with the response header Content-Disposition, and the front-end browser downloads the file after recognizing the response header; however, the method has a limitation on the length of the request address, and the front-end browser cannot provide more demand parameters to the back-end browser, so that file downloading meeting personalized and diversified demands is difficult to meet.
Disclosure of Invention
In view of the above, the present invention provides a file downloading method, device and electronic device, so as to download files under various types and requirements, and further meet personalized and diversified requirements of file downloading.
In a first aspect, an embodiment of the present invention provides a file downloading method, where the method includes: responding to a downloading instruction aiming at the target file, generating POST request information carrying a specified request header, and sending the POST request information to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file; and receiving binary file data of the target file returned by the back-end server, and downloading the target file based on the binary file data.
Further, the step of generating the POST request information carrying the specified request header includes: acquiring a downloading demand parameter from a downloading instruction; the downloading requirement parameter is used for indicating the downloading requirement of a user for the target file; and generating POST request information carrying a specified request header based on the download requirement parameters, wherein the download requirement parameters are contained in the request body of the POST request information.
Further, the specified request header is specifically used to indicate: the response type of the back-end server responding to the POST request information is the blob object.
Further, specifying the request header includes: responseType: 'blob'.
Further, the step of downloading the target file based on the binary file data includes: and generating a link address of the binary file data, and downloading the target file through the link address.
Further, the step of generating a link address of the binary file data and downloading the target file through the link address includes: if the current browser supports execution of a preset downloading function, a link address of binary file data is generated in a Blob mode; and inputting the link address and the file name of the target file into a preset downloading function so as to download the target file through the preset downloading function.
Further, the preset downloading function includes: window.
Further, the step of generating a link address of the binary file data and downloading the target file through the link address includes: if the current browser does not support the execution of the preset downloading function, generating a link address of the binary file data through a link address generating function; and generating an a-tag DOM node associated with the link address, and downloading the target file through the a-tag DOM node.
Further, the link address generating function includes: url. createobjecturl function.
Further, the step of downloading the target file through the a-tag DOM node includes: inserting a label DOM node into a webpage code of a current webpage; the a label DOM node is used for downloading a target file; and automatically triggering the a-tag DOM node to download the target file.
In a second aspect, an embodiment of the present invention provides a file downloading apparatus, where the apparatus includes: the sending module is used for responding to a downloading instruction aiming at the target file, generating POST request information carrying a specified request header and sending the POST request information to the back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file; and the downloading module is used for receiving the binary file data of the target file returned by the back-end server and downloading the target file based on the binary file data.
In a third aspect, an embodiment of the present invention provides an electronic device, which includes a processor and a memory, where the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the file downloading method in any one of the first aspect.
In a fourth aspect, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions that, when invoked and executed by a processor, cause the processor to implement the file download method of any one of the first aspect.
The embodiment of the invention has the following beneficial effects:
according to the file downloading method, the file downloading device and the electronic equipment, provided by the embodiment of the invention, a downloading instruction aiming at a target file is responded, POST request information carrying a specified request header is generated, and the POST request information is sent to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file; and receiving binary file data of the target file returned by the back-end server, and downloading the target file based on the binary file data. In the method, the binary file data of the target file returned by the server can be acquired by utilizing the POST request information carrying the appointed request head, and the target file is downloaded based on the binary file data.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a file downloading method according to an embodiment of the present invention;
fig. 2 is a flowchart of another file downloading method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a file downloading device according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Currently, the following two methods are generally used for realizing the downloading function of the webpage document attachment: one is to set the jump address of the a tag in the webpage code as a file which cannot be previewed by the browser, for example, files in a. doc format, a. tar format and a. zip format, and since the browser cannot open the files in the formats for previewing, the files are downloaded by default; however, this method can only download files already existing in the backend server, and cannot download files dynamically generated according to the content; and the file cannot be opened and previewed by the browser, and the file which can be opened and previewed by the browser cannot be downloaded, such as the files in the js format, the html format and the jpg format, so that the restriction conditions are more.
The other is that after the back-end server generates a document attachment, a response head Content-Disposition is set for the file, the front-end browser requests the back-end server API through get, the back-end returns the file with the response head Content-Disposition, and the front-end browser downloads the file after identifying the response head; however, the method can only download the file requested by get, the length of the request address is limited, the front-end browser cannot provide more demand parameters to the back-end browser, and the file download meeting the personalized and diversified demands is difficult. Based on this, the file downloading method, the file downloading device and the electronic device provided by the embodiment of the invention can be applied to devices such as mobile phones and computers.
To facilitate understanding of the embodiment, first, a detailed description is given of a file downloading method disclosed in the embodiment of the present invention, where an execution subject of the method may be a device such as a mobile phone and a computer, as shown in fig. 1, the method includes the following steps:
step S102, responding to a downloading instruction aiming at a target file, generating POST request information carrying a specified request header, and sending the POST request information to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file;
the target file may be a file already existing in the backend server, a file dynamically generated according to the content, a file that the client (e.g., a browser) cannot open for preview, or the like. The specified request header may be an HTTP (hypertext Transfer Protocol) request header, and is mainly used to indicate a request type when sending a request to a server, so that a backend server returns binary file data of a target file, for example, the specified request header may be a responseType: 'blob', responseType: 'document' etc. request type. The POST request is generally used for submitting data to a server, and POST request information comprises a specified request header, a request line and a request body; including parameter information associated with the target file, data type information returned to the target file, etc.
Specifically, a download control of a target file displayed in a client program may be clicked, for example, a download link of the target file displayed in a browser, the client program (e.g., browser) at the front end responds to a download instruction for the target file, POST request information carrying a specified request header may be generated by a web code of a current web page, and the POST request information is sent to the back-end server.
And step S104, receiving the binary file data of the target file returned by the back-end server, and downloading the target file based on the binary file data.
After receiving the POST request information, the back-end server can generate binary file data of the target file according to a specified request header, parameter information of the target file and the like in the POST request information; returning the generated binary file data of the target file to the front-end browser; or directly returning the binary file data of the target file pre-stored by the back-end server to the front-end browser according to the specified request header in the POST request information, the parameter information of the target file and the like. After binary file data of a target file returned by a back-end server is received, due to the characteristic of a POST request mode, the essence of the POST request mode is that the data is submitted to the back-end server, and therefore, even if a specified request head is arranged and the returned data is indicated to be the binary data, a browser cannot download the target file, therefore, a link or an address capable of downloading the target file can be generated based on the binary file data, and the target file is downloaded according to the generated link or the address of the target file.
The file downloading method provided by the embodiment of the invention responds to a downloading instruction aiming at a target file, generates POST request information carrying a specified request head, and sends the POST request information to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file; and receiving binary file data of the target file returned by the back-end server, and downloading the target file based on the binary file data. In the method, the binary file data of the target file returned by the server can be acquired by utilizing the POST request information carrying the appointed request head, and the target file is downloaded based on the binary file data.
This embodiment further provides another file downloading method, and this embodiment mainly describes a specific implementation process of the step of generating the POST request information carrying the specified request header (implemented by steps S202 to S204), and a specific implementation process of the step of downloading the target file based on the binary file data (implemented by step S208), as shown in fig. 2, this method includes the following steps:
step S202, responding to a downloading instruction aiming at a target file, and acquiring a downloading demand parameter from the downloading instruction; the downloading requirement parameter is used for indicating the downloading requirement of a user for the target file;
the download requirement parameters may include a series of parameters such as format, type, name, and attribute of the target file, and are mainly used to indicate the download requirement of the user for the target file; for example, the target file to be downloaded is a word file, and parameters such as a name, a type, a format, and the like of the file need to be acquired from the download instruction, so that the target file to be downloaded finally is a file required by the user.
Since the get request can only put these download requirement parameters behind a URL (Uniform Resource Locator), and the get request has a limitation on the length of the address character, when the backend needs to generate a document according to a large number of parameters, the method has more limitations. The POST request does not transmit parameters through the URL and is not limited by the length of address characters, so that the downloading requirement of files which need to be generated according to a large number of parameters is met.
Step S204, based on the download requirement parameters, POST request information carrying a specified request header is generated; wherein, the download demand parameter is contained in the request body of the POST request information;
the request body may be understood as a request body, and is mainly used for writing the download requirement parameter acquired by the front-end browser, and when the request body is used specifically, the download requirement parameter may be bound to the request body by using the @ request body. Specifically, the download requirement parameters may be converted into download requirement parameters in a specific format, and the download requirement parameters converted into the specific format may be written into the request body of the POST request information.
The specified request header is specifically used to indicate: the response type of the back-end server responding to the POST request information is the blob object. Specifically, the specified request header may be responseType: a form of 'blob', where blob represents a binary format. In actual implementation, the backend server may respond to the POST request information with a variety of response types, e.g., DOMString, ArrayBuffer objects, blob objects, etc. The designated request head indicates that the response type responding to the POST request information is the blob object, the designated request head represents that the back-end server needs to return the target file in the form of binary data, and the front end can obtain the binary file data of the target file.
Step S206, POST request information is sent to a back-end server;
and step S208, receiving the binary file data of the target file returned by the back-end server, generating a link address of the binary file data, and downloading the target file through the link address.
The returned binary file data of the target file is returned in a POST mode. In actual implementation, due to the characteristic of the POST request mode, the essence of the POST request mode is to submit data to the back-end server, so that the browser does not download the target file after receiving the binary file data of the target file returned by the back-end server, and therefore, a link address of the binary file data can be generated in a preset mode according to the binary file data of the target file returned by the back-end server, and the target file is downloaded through the link address.
One possible implementation:
(1) if the current browser supports execution of a preset downloading function, a link address of binary file data is generated in a Blob mode;
(2) and inputting the link address and the file name of the target file into a preset downloading function so as to download the target file through the preset downloading function.
The preset download function includes: window. If the current browser supports execution of a window navigator msSaveBlob function, the front-end browser can generate a link address of binary file data in a Blob mode according to the binary file data of a target file returned by a back-end server; the mssavebob method allows a user to save files on the client, which is equivalent to downloading files from the Internet.
And then, a window navigator msSaveBlob (blob) can be used for downloading a target file generated by the back end, wherein the blob is a link address, the filename is the name of the target file, and the format of the target file is also included.
Another possible implementation:
(1) if the current browser does not support the execution of the preset downloading function, generating a link address of the binary file data through a link address generating function;
(2) and generating an a-tag DOM node associated with the link address, and downloading the target file through the a-tag DOM node.
The link address generating function includes: url. createobjecturl function. If the current browser does not support execution of a window.
Then, generating an a-tag DOM node associated with the link address through a front-end browser, wherein the a-tag can define a hyperlink used for linking from one page to another page, and the a-tag in the HTML5 has a download characteristic; downloading a target file through the a-tag DOM node;
the step of downloading the target file through the a-tag DOM node includes: inserting a label DOM node into a webpage code of a current webpage; the a label DOM node is used for downloading a target file; and automatically triggering the a-tag DOM node to download the target file.
Specifically, by using the download characteristic of the a tag in the HTML5, the a tag DOM node is inserted into the webpage code of the current webpage, the code of the click DOM node in the webpage code is automatically run, and the generated DOM node is automatically clicked, so that the target file can be downloaded.
In the process, the user only needs to click the download button aiming at the target file in the browser once, and the download of various types of files can be realized.
The step of generating the link address of the binary file data and downloading the target file through the link address can be implemented by the following codes:
Figure BDA0002775731710000091
Figure BDA0002775731710000101
wherein, let Blob { 'application/octet-stream' } represents that binary data of the target file is received; the if () function is used for judging whether the current browser supports executing the preset download function window.
Summary element ('a'); templink. href is blob URL; templink setattribute ('download', filename); a link address representing the binary file data generated by the link address generating function, and an a-tag DOM node associated with the link address;
document, body, apendchild (tempLink); click (); representing clicking to download the target file; document body removecold (tempLink) indicates that the download is completed to remove the element.
It should be noted that, the determining whether the current browser supports executing the preset download function may be before the front-end browser sends the POST request message to the back-end server, or after the front-end browser receives the binary data of the target file returned by the back-end server.
In the method, a downloading demand parameter is obtained from a downloading instruction; generating POST request information carrying a specified request header based on the download demand parameter; sending POST request information carrying a specified request header to a back-end server; the specified request head is used for indicating the back-end server to return the binary file data of the target file; judging whether the current browser supports execution of a preset downloading function, generating a link address of binary file data according to a judgment result, and downloading a target file through window. The method can download the dynamically generated file, can download the file which can be opened by the browser, avoids the limitation of the length of the address character, and can realize the function of downloading the file even if the back end needs to generate the file according to a large number of parameters. The file downloading method has the advantages that the file can be downloaded based on various user requirements, the application range of the downloading mode is wide, and the personalized and diversified requirements of file downloading can be met.
Corresponding to the above method embodiment, this embodiment provides a file downloading device, as shown in fig. 3, where the device includes:
a sending module 31, configured to respond to a download instruction for a target file, generate POST request information carrying a specified request header, and send the POST request information to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file;
and the downloading module 32 is configured to receive binary file data of the target file returned by the back-end server, and download the target file based on the binary file data.
The file downloading device provided by the embodiment of the invention responds to a downloading instruction aiming at a target file, generates POST request information carrying a specified request header, and sends the POST request information to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file; and receiving binary file data of the target file returned by the back-end server, and downloading the target file based on the binary file data. In the method, the binary file data of the target file returned by the server can be acquired by utilizing the POST request information carrying the appointed request head, and the target file is downloaded based on the binary file data.
Further, the sending module is further configured to: acquiring a downloading demand parameter from a downloading instruction; the downloading requirement parameter is used for indicating the downloading requirement of a user for the target file; and generating POST request information carrying a specified request header based on the download requirement parameters, wherein the download requirement parameters are contained in the request body of the POST request information.
Further, the specified request header is specifically used to indicate: the response type of the back-end server responding to the POST request information is the blob object.
Further, the above-mentioned specified request header includes: responseType: 'blob'.
Further, the download module is further configured to: and generating a link address of the binary file data, and downloading the target file through the link address.
Further, the download module is further configured to: if the current browser supports execution of a preset downloading function, a link address of binary file data is generated in a Blob mode; and inputting the link address and the file name of the target file into a preset downloading function so as to download the target file through the preset downloading function.
Further, the preset downloading function includes: window.
Further, the download module is further configured to: if the current browser does not support the execution of the preset downloading function, generating a link address of the binary file data through a link address generating function; and generating an a-tag DOM node associated with the link address, and downloading the target file through the a-tag DOM node.
Further, the link address generating function includes: url. createobjecturl function.
Further, the download module is further configured to: inserting a label DOM node into a webpage code of a current webpage; the a label DOM node is used for downloading a target file; and automatically triggering the a-tag DOM node to download the target file.
The file downloading device provided by the embodiment of the invention has the same technical characteristics as the file downloading method provided by the embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
The embodiment also provides an electronic device, which comprises a processor and a memory, wherein the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to realize the file downloading method.
Referring to fig. 4, the electronic device includes a processor 100 and a memory 101, the memory 101 stores machine executable instructions capable of being executed by the processor 100, and the processor 100 executes the machine executable instructions to implement the file downloading method.
Further, the electronic device shown in fig. 4 further includes a bus 102 and a communication interface 103, and the processor 100, the communication interface 103, and the memory 101 are connected through the bus 102.
The Memory 101 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 102 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
Processor 100 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 100. The Processor 100 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the foregoing embodiment in combination with the hardware thereof.
The present embodiments also provide a machine-readable storage medium having stored thereon machine-executable instructions that, when invoked and executed by a processor, cause the processor to implement the file download method described above.
The file downloading method, the file downloading device and the computer program product of the electronic device provided by the embodiments of the present invention include a computer readable storage medium storing program codes, instructions included in the program codes may be used to execute the method described in the foregoing method embodiments, and specific implementations may refer to the method embodiments and are not described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In addition, in the description of the embodiments of the present invention, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present invention can be understood in specific cases for those skilled in the art.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that the following embodiments are merely illustrative of the present invention, and not restrictive, and the scope of the present invention is not limited thereto: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (13)

1. A method for downloading a file, the method comprising:
responding to a downloading instruction aiming at a target file, generating POST request information carrying a specified request header, and sending the POST request information to a back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file;
and receiving binary file data of the target file returned by the back-end server, and downloading the target file based on the binary file data.
2. The method of claim 1, wherein the step of generating the POST request message carrying the specified request header comprises:
acquiring a downloading demand parameter from the downloading instruction; the downloading requirement parameter is used for indicating the downloading requirement of a user for the target file;
and generating POST request information carrying a specified request header based on the download requirement parameters, wherein the download requirement parameters are contained in the request body of the POST request information.
3. The method according to claim 1 or 2, wherein the specified request header is specifically configured to indicate: and the response type of the back-end server responding to the POST request information is a blob object.
4. The method of claim 3, wherein the specifying the request header comprises: responseType: 'blob'.
5. The method of claim 1, wherein the step of downloading the object file based on the binary file data comprises: and generating a link address of the binary file data, and downloading the target file through the link address.
6. The method of claim 5, wherein the step of generating a link address of the binary file data and downloading the target file through the link address comprises:
if the current browser supports execution of a preset downloading function, generating a link address of the binary file data in a Blob mode;
and inputting the link address and the file name of the target file into a preset downloading function so as to download the target file through the preset downloading function.
7. The method of claim 6, wherein the predetermined download function comprises: window.
8. The method of claim 5, wherein the step of generating a link address of the binary file data and downloading the target file through the link address comprises:
if the current browser does not support the execution of a preset downloading function, generating a link address of the binary file data through a link address generating function;
and generating an a-tag DOM node associated with the link address, and downloading the target file through the a-tag DOM node.
9. The method of claim 8, wherein the link address generation function comprises: url. createobjecturl function.
10. The method according to claim 8, wherein the step of downloading the target file via the a-tag DOM node comprises:
inserting the a-tag DOM node into a webpage code of a current webpage; the a-tag DOM node is used for downloading the target file;
and automatically triggering the a-tag DOM node to download the target file.
11. A file download apparatus, characterized in that the apparatus comprises:
the sending module is used for responding to a downloading instruction aiming at the target file, generating POST request information carrying a specified request header, and sending the POST request information to the back-end server; wherein the specified request header is used to indicate: the back-end server returns the binary file data of the target file;
and the downloading module is used for receiving the binary file data of the target file returned by the back-end server and downloading the target file based on the binary file data.
12. An electronic device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor, the processor executing the machine executable instructions to implement the file download method of any one of claims 1 to 10.
13. A machine-readable storage medium having stored thereon machine-executable instructions which, when invoked and executed by a processor, cause the processor to implement the file download method of any of claims 1 to 10.
CN202011275014.6A 2020-11-12 2020-11-12 File downloading method and device and electronic equipment Pending CN112468550A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011275014.6A CN112468550A (en) 2020-11-12 2020-11-12 File downloading method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011275014.6A CN112468550A (en) 2020-11-12 2020-11-12 File downloading method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN112468550A true CN112468550A (en) 2021-03-09

Family

ID=74837491

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011275014.6A Pending CN112468550A (en) 2020-11-12 2020-11-12 File downloading method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112468550A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114500478A (en) * 2021-12-24 2022-05-13 奇安信科技集团股份有限公司 Software distribution method and device and electronic equipment
CN114697317A (en) * 2022-05-11 2022-07-01 上海七牛信息技术有限公司 File access method and system
CN114500478B (en) * 2021-12-24 2024-05-17 奇安信科技集团股份有限公司 Software distribution method and device and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6128653A (en) * 1997-03-17 2000-10-03 Microsoft Corporation Method and apparatus for communication media commands and media data using the HTTP protocol
US20100325155A1 (en) * 2009-06-23 2010-12-23 James Skinner Systems and Methods for Providing Access to Various Files Across a Network
CN104504060A (en) * 2014-12-18 2015-04-08 北京奇虎科技有限公司 File downloading method in browser, browser client side and device
CN104537020A (en) * 2014-12-18 2015-04-22 北京奇虎科技有限公司 Method for downloading file through browser and browser client side and device
CN106126595A (en) * 2016-06-20 2016-11-16 浪潮电子信息产业股份有限公司 A kind of document down loading method and device
CN111327690A (en) * 2020-01-23 2020-06-23 湖南快乐阳光互动娱乐传媒有限公司 Cross-domain file downloading method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6128653A (en) * 1997-03-17 2000-10-03 Microsoft Corporation Method and apparatus for communication media commands and media data using the HTTP protocol
US20100325155A1 (en) * 2009-06-23 2010-12-23 James Skinner Systems and Methods for Providing Access to Various Files Across a Network
CN104504060A (en) * 2014-12-18 2015-04-08 北京奇虎科技有限公司 File downloading method in browser, browser client side and device
CN104537020A (en) * 2014-12-18 2015-04-22 北京奇虎科技有限公司 Method for downloading file through browser and browser client side and device
CN106126595A (en) * 2016-06-20 2016-11-16 浪潮电子信息产业股份有限公司 A kind of document down loading method and device
CN111327690A (en) * 2020-01-23 2020-06-23 湖南快乐阳光互动娱乐传媒有限公司 Cross-domain file downloading method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
BYE_CHERRY: "post请求下载文件(兼容IE)", 《HTTPS://BLOG.CSDN.NET/BYE_CHERRY/ARTICLE/DETAILS/109373781》 *
浪浪浪浪浪浪浪浪: "post方法下载文件", 《HTTPS://WWW.CNBLOGS.COM/HAMILI/P/12102063.HTML》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114500478A (en) * 2021-12-24 2022-05-13 奇安信科技集团股份有限公司 Software distribution method and device and electronic equipment
CN114500478B (en) * 2021-12-24 2024-05-17 奇安信科技集团股份有限公司 Software distribution method and device and electronic equipment
CN114697317A (en) * 2022-05-11 2022-07-01 上海七牛信息技术有限公司 File access method and system

Similar Documents

Publication Publication Date Title
CN108228282B (en) Method and device for loading website page
CN106294648B (en) Processing method and device for page access path
CN103873918B (en) Image processing method, device and terminal
CN108717435B (en) Webpage loading method, information processing method, computer equipment and storage medium
US20160283499A1 (en) Webpage advertisement interception method, device and browser
US10120847B2 (en) Methods for transforming requests for web content and devices thereof
US20140100963A1 (en) Method, System and Device For Filtering Mobile Terminal Webpage Advertisements
KR102151457B1 (en) Method and apparatus for reducing page load time in a communication system
CN111104587A (en) Webpage display method and device and server
JP6093449B2 (en) Homepage forming method, peripheral device, and homepage forming system
WO2010051766A1 (en) Method and device for acquiring target resource information
CN110808868B (en) Test data acquisition method and device, computer equipment and storage medium
CN113382083B (en) Webpage screenshot method and device
US9058399B2 (en) System and method for providing network resource identifier shortening service to computing devices
CN114168869A (en) Information display method, device, system and storage medium
CN112612982A (en) Webpage preloading method and device and computer equipment
CN112818270B (en) Data cross-domain transfer method and device and computer equipment
CN112468550A (en) File downloading method and device and electronic equipment
CN102681996B (en) Pre-head method and device
CN112187622B (en) Instant message display method and device and server
CN115587075B (en) Layout file processing method and device, terminal equipment and storage medium
CN112149017A (en) Webpage access method, device and system, electronic equipment and storage medium
CN113626392A (en) Method and device for updating document data, electronic equipment and storage medium
CN103227827B (en) The method and apparatus of request resource
CN108959325B (en) Uniform resource locator display method, information display method and related products thereof

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210309

RJ01 Rejection of invention patent application after publication