File downloading method and device, computer equipment and storage medium
By generating and verifying file download licenses during file downloading, the problem of inability to authenticate users in traditional technology is solved, and the security and permission control of file download are realized.
Patent Information
- Application Number
- CN202411741443.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-04-11
AI Technical Summary
Traditional file download methods cannot authenticate users, and there are problems with the security and authentication of file downloads, especially for confidential files, and download permissions cannot be strictly restricted.
Retrieve requests through the receiving terminal's file download license, extract user information and file information, generate file download license, and query whether there is a consistent license in the cache when downloading the file. If it exists, download the file. If it does not exist, reject the download.
It realizes authentication of users during file downloading, ensures the security of file downloading, and ensures strict control of downloading permissions for confidential files.
Smart Images

Figure CN119814757A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a file downloading method, device, computer equipment and storage medium. Background Art
[0002] With the development of terminal technology, the functions of terminals are becoming more and more complete. Connecting to the Internet through the terminal and downloading files has become a common operation for mobile terminal users.
[0003] In traditional technology, generally by using Tags download files, where The tag is an anchor link tag in HTML (HyperTextMarkup Language), which is used to create hyperlinks. It can convert text, pictures or other HTML elements into clickable links, allowing users to click on the link to jump to other pages or locations. When a tag downloads a file, the underlying layer calls the browser to download the file directly. The user cannot be authenticated, and there are security and authentication issues with file downloads. Especially for confidential files, download permissions cannot be strictly restricted. Summary of the invention
[0004] Based on this, it is necessary to provide a file downloading method, apparatus, computer device and storage medium that can authenticate users during the file downloading process in order to solve the above technical problems.
[0005] A file downloading method, comprising:
[0006] A receiving terminal submits a request for obtaining a file download license in response to a file download instruction;
[0007] Extract user information and file information according to the acquisition request;
[0008] Generate a file download license based on user information and file information;
[0009] Sending the file download license to the terminal so that the terminal generates a file download request according to the file download license;
[0010] Receive a file download request sent by a terminal and extract a file download license;
[0011] Check whether the file download license exists in the pre-created cache;
[0012] When a file download license exists, the file download is performed.
[0013] In one embodiment, extracting user information and file information according to the acquisition request includes:
[0014] Extract the user token from the get request;
[0015] Get user information and authorization information based on user token;
[0016] The method also includes:
[0017] Determine whether the user has the file download permission based on the authorization information;
[0018] When the user has the download authority, a step of generating a file download license according to the user information and the file information is executed.
[0019] In one embodiment, generating a file download license according to user information and file information includes:
[0020] A hash calculation is performed based on user information, file information, the timestamp of the acquisition request, and a preset hash algorithm to obtain a file download license.
[0021] In one embodiment, the file downloading method further includes:
[0022] When it is found that the file download license exists in the cache, the file download license is set to an invalid state or destroyed.
[0023] A file downloading method, comprising:
[0024] Submitting a request for obtaining a file download license to a server in response to a file download instruction;
[0025] Receiving the file download license returned by the server, and generating a uniform resource locator for file download according to the file download license;
[0026] Send a file download request to the server according to the uniform resource locator of the file download;
[0027] Receive the file to be downloaded returned by the server, and execute the file download according to the file to be downloaded.
[0028] In one embodiment, generating a uniform resource locator for file download according to the file download license includes:
[0029] Add the file download license as a query parameter to the uniform resource locator of the file download;
[0030] Alternatively, include the file download license as part of the path in the file download's Uniform Resource Locator.
[0031] In one embodiment, sending a file download request to a server according to a uniform resource locator for file download includes:
[0032] Create hyperlink tags;
[0033] The value of the hyperlink reference attribute of the hyperlink tag is set to the uniform resource locator of the file download;
[0034] Trigger a file download request based on the set hyperlink tag.
[0035] A file downloading device, comprising:
[0036] A first receiving module, configured to receive a request for obtaining a file download license submitted by a terminal in response to a file download instruction;
[0037] The acquisition module is used to extract user information and file information according to the acquisition request;
[0038] A generation module, used to generate a file download license according to user information and file information;
[0039] A sending module, used for sending the file download license to the terminal, so that the terminal generates a file download request according to the file download license;
[0040] A second receiving module, used for receiving a file download request sent by a terminal and extracting a file download license;
[0041] A query module, used for querying whether a file download license exists in a pre-created cache;
[0042] The download module is used to download files when a file download license exists.
[0043] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0044] A receiving terminal submits a request for obtaining a file download license in response to a file download instruction;
[0045] Extract user information and file information according to the acquisition request;
[0046] Generate a file download license based on user information and file information;
[0047] Sending the file download license to the terminal so that the terminal generates a file download request according to the file download license;
[0048] Receive a file download request sent by a terminal and extract a file download license;
[0049] Check whether the file download license exists in the pre-created cache;
[0050] When a file download license exists, the file download is performed.
[0051] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0052] A receiving terminal submits a request for obtaining a file download license in response to a file download instruction;
[0053] Extract user information and file information according to the acquisition request;
[0054] Generate a file download license based on user information and file information;
[0055] Sending the file download license to the terminal so that the terminal generates a file download request according to the file download license;
[0056] Receive a file download request sent by a terminal and extract a file download license;
[0057] Check whether the file download license exists in the pre-created cache;
[0058] When a file download license exists, the file download is performed.
[0059] The above-mentioned file downloading method, device, computer equipment and storage medium, when receiving a file download instruction, first obtains a file download license from the server, and initiates a file download request to the server again according to the file download license. When the server receives the file download, it extracts the file download license therein, and compares the extracted file download license with the file download license in the preset cache. If there is a consistent file download license in the cache, the corresponding file to be downloaded is obtained and returned to the terminal. If there is no consistent file download license, the file download is rejected, thereby realizing user authentication during the file download process, thereby ensuring the security of file downloading. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 An application environment diagram of a file downloading method in an embodiment;
[0061] Figure 2 A schematic diagram of a process flow of a file downloading method in one embodiment;
[0062] Figure 3 A schematic diagram of a process flow of a file downloading method in one embodiment;
[0063] Figure 4 A schematic diagram of interaction between a terminal and a server in one embodiment;
[0064] Figure 5 is a structural block diagram of a file downloading device in an embodiment;
[0065] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0067] Please refer to Figure 1 , Figure 1 A schematic diagram of an application environment of a file download method provided by an exemplary embodiment of the present application. Figure 1 As shown, the application environment includes a server 100 and a terminal 101. The server 100 and the terminal 101 can be communicatively connected via a network 102 to implement the file downloading method of the present application.
[0068] The server 100 is used to receive a request for obtaining a file download license submitted by the terminal 101 in response to a file download instruction, extract user information and file information according to the acquisition request, generate a file download license according to the user information and the file information, and send the file download license to the terminal 101 so that the terminal 101 generates a file download request according to the file download license, receives the file download request sent by the terminal 101, extracts the file download license, queries whether the file download license exists in a pre-created cache, and downloads the file when the file download license exists.
[0069] The server 100 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0070] The terminal 101 is used to submit a request for obtaining a file download license to the server 100 in response to a file download instruction, receive the file download license returned by the server 100, and generate a uniform resource locator for file download according to the file download license, send a file download request to the server 100 according to the uniform resource locator for file download, receive the file to be downloaded returned by the server 100, and execute file download according to the file to be downloaded.
[0071] The terminal 101 may be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, and portable wearable devices.
[0072] The network 102 is used to realize the network connection between the terminal 101 and the server 100. Specifically, the network 102 may include various types of wired or wireless networks.
[0073] In one embodiment, Figure 2 As shown, a file download method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:
[0074] Step S21: The receiving terminal submits a request for obtaining a file download license in response to a file download instruction.
[0075] Among them, a file download license is an authorization file that allows users to download certain files that are subject to copyright or usage permission restrictions from a specific server or repository.
[0076] A file download instruction is a command issued by a user or program to a computer system, network server, or other storage device to obtain a specific file and transfer it to a local device. Specifically, in this application, when a user clicks on a download link, the file download instruction is triggered. After receiving the file download instruction, the terminal submits a request to the server to obtain a file download license.
[0077] Step S22: extracting user information and file information according to the acquisition request.
[0078] The user information refers to information related to the user who initiated the file download instruction, such as the user information may include the user name, user ID, and user's geographical location information, etc. The file information refers to the file information of the file to be downloaded, such as the file name, file format, file version number, file size, and file source.
[0079] Step S23: Generate a file download license according to the user information and the file information.
[0080] Among them, this application can generate a file download license in the following ways:
[0081] First, based on the encryption algorithm to generate
[0082] The server can use an encryption algorithm to process user information and file information to generate a file download license.
[0083] Secondly, this application can also maintain a rule for generating a file download license in the database. For example, there is a self-incrementing integer primary key field. Every time there is a new download request, the value of this primary key is used as part of the file download license, and combined with other information (such as the user's unique identifier, the version number of the file, etc.), it is spliced together in a certain format. For example, assuming that the user ID is 1001, the file version is v1.0, and the database self-incrementing primary key is 2021, it can be spliced into a file download license like 1001-v1.0-2021.
[0084] Third, this application can also access third-party authorization services. After receiving the request, the request information is sent to the third-party authorization service, which generates a file download license based on the user information and file information according to its own rules, and then returns it to the server. This method is usually used in scenarios with extremely high security requirements, limited development resources, or the need to follow industry standard authorization mechanisms.
[0085] Step S24: sending the file download license to the terminal so that the terminal generates a file download request according to the file download license.
[0086] If the terminal initiates a file download request through a web page, the server can generate a file download license and use it as part of an HTTP (Hypertext Transfer Protocol) response. For example, the server can add the file download license to a response header or a response body in a routing function that processes the download request and return it to the terminal.
[0087] Step S25, receiving the file download request sent by the terminal, and extracting the file download license.
[0088] The terminal sends the file download license to the server along with the file download request. After receiving the file download request, the server extracts the file download license from the request.
[0089] Step S26, query whether there is a file download license in the pre-created cache.
[0090] In the present application, when the server generates a file download license, it will store the file download license in a preset cache, so that when the server subsequently receives a file download request sent by the terminal, it will match the file download license extracted from the file download request with the file download license stored in the cache. Specifically, the present application can cache in the cache in the form of a key-value pair, where the key is a hash value (i.e., the file download license), and the value is user information and file information, etc.
[0091] Step S27: When there is a file download license, download the file.
[0092] Specifically, the server matches the file download license extracted from the file download request with the file download license stored in the cache. If there is a file download license in the cache that is consistent with the file download license extracted from the file download request, it is considered that the user authentication is passed and further subsequent file download operations are performed.
[0093] When there is no file download license in the cache that is consistent with the file download license extracted from the file download request, it is considered that the user authentication fails, and the download operation is rejected.
[0094] Furthermore, when there is a file download license, the server obtains the original file according to the file information (such as the file ID), and returns the original file to the terminal in the form of a file output stream, and the terminal downloads the file, wherein the user can perform other web page operations during the download process.
[0095] In one embodiment, extracting user information and file information according to an acquisition request may include: extracting a user token in the acquisition request, and acquiring user information and authorization information according to the user token. The file download method may also include: determining whether the user has file download permission according to the authorization information, and when the user has download permission, executing the step of generating a file download license according to the user information and file information.
[0096] When a user logs in on a web page using an account and password, the server will verify the user's credentials (account and password). If the verification is successful, the server will generate a user token and return it to the terminal. The user token is usually an encrypted string that contains the user's identity information and some other verification data, such as the validity period.
[0097] Furthermore, the terminal sends the user token to the server in a request to obtain a file download license, and the server extracts the user token and further extracts the user information and authorization information in the user token. The authorization information may specifically include information such as whether the user has the file download permission, the scope of the permission, the validity period, and the access level.
[0098] Furthermore, the server determines whether the user has the file download authority based on the authorization information, and when it is determined that the user has the file download authority, executes the step of generating a file download license based on the user information and the file information.
[0099] The beneficial effect of this embodiment is that the application can extract authorization information based on the user token, and generate a file download license when it is determined that the user has download authority, thereby ensuring the security of file downloading.
[0100] In one embodiment, generating a file download license according to user information and file information includes: performing a hash calculation according to user information, file information, a timestamp of an acquisition request, and a preset hash algorithm to obtain the file download license.
[0101] Among them, the hash algorithm is a process that converts input data of any length (usually called a message) into a fixed-length output (called a hash value or hash value) through a certain algorithm. This process is irreversible, that is, it is usually impossible to restore the original input data from the hash value.
[0102] Specifically, the hash algorithm used in the present application may be SHA-256, which is a cryptographic hash function used to generate a fixed-length digest of a message. It can convert data of any length (such as files, messages, etc.) into a hash value of a fixed length (256 bits, i.e., 32 bytes). This hash value is usually expressed as 64 hexadecimal characters.
[0103] Among them, the user information can be a user ID, and the file information can be a file ID. Specifically, the present application can use SHA-256 to hash the user ID, the timestamp of the acquisition request, and the file ID. Specifically, the present application can concatenate the user ID, the timestamp of the acquisition request, and the file ID into a string, and then generate a 256-bit hash value as the file download license through the SHA-256 algorithm. The code generated in this way is irreversible and has high security.
[0104] The beneficial effect of this embodiment is that the file download license is generated by the SHA-256 algorithm, so that the generated file download license has strong timeliness and randomness, is difficult to forge, and effectively prevents other persons from forging the file download license.
[0105] In one of the embodiments, the file downloading method may further include: after it is found that the file downloading license exists in the cache, setting the file downloading license to an invalid state or destroying it.
[0106] In this application, after the file download license is generated, the file download license is stored in the cache and the validity period of the file download license is set. Specifically, this application can cache in the cache in the form of a key-value pair. Among them, the key is the file download license, and the value can be the user ID, the file ID, and the timestamp of the acquisition request.
[0107] Furthermore, after finding out that the file download license exists in the cache, the present application may set the file download license to an invalid state, that is, set the file download license to expire, or destroy the file download license.
[0108] The beneficial effect of this embodiment is that by setting a validity period for the file download license, it is possible to prevent other persons from stealing the file download license, thereby further improving the security of file downloading.
[0109] In one embodiment, Figure 3 As shown, a file download method is provided, which is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:
[0110] Step S31: submitting a request for obtaining a file download license to a server in response to a file download instruction.
[0111] Step S32: receiving the file download license returned by the server, and generating a uniform resource locator for file download according to the file download license.
[0112] Step S33: Send a file download request to the server according to the uniform resource locator of the file download.
[0113] Step S34, receiving the file to be downloaded returned by the server, and executing file download according to the file to be downloaded.
[0114] Among them, the present application implements the file downloading method of the present application through data interaction between the terminal and the server.
[0115] In one embodiment, please refer to Figure 4 , Figure 4 FIG. 1 is a schematic diagram of the interaction between a terminal and a server in an embodiment. Figure 4 In the process, the terminal receives the file download instruction and submits a request to obtain the file download license to the server. After receiving the request, the server generates a file download license based on the acquisition, and stores the file download license and related information in the cache in the form of a key-value pair, and sets a validity period. The server returns the file download license to the terminal, and the terminal generates a file download URL (Uniform Resource Locator) based on the file download license. The web page calls the browser, and the web page uses the URL The tag sends a file download request, the server receives the file download request, parses the file download license in the file download request, checks whether the file download license information exists in the cache, and if so, executes the file download. If not, a question box pops up to refuse the download.
[0116] In one embodiment, generating a uniform resource locator for file download according to the file download license may include: adding the file download license as a query parameter to the uniform resource locator for file download, or adding the file download license as a part of the path to the uniform resource locator for file download.
[0117] Among them, the Uniform Resource Locator is a method of indicating the location of information on the World Wide Web service program of the Internet, also known as a "URL".
[0118] Specifically, the present application generates a uniform resource locator for file download according to the file download license, which may include:
[0119] 1. Determine the base URL format
[0120] This application predefines the base URL format for the file download service. For example, the base URL may be https: / / example.com / download / , which means that all file download requests must be sent to the interface related to the / download / path under this domain name.
[0121] 2. Add file download license
[0122] Add the file download license as a parameter to the base URL. There are two common ways to add it. One is as a query parameter. For example, if the file download license is ABC123, add ? licenseCode=ABC123 after the base URL. The final URL may be https: / / example.com / download / ? licenseCode=ABC123. The other is as part of the path. For example, if the base URL is https: / / example.com / download / , adding the file download license will turn it into https: / / example.com / download / ABC123. The specific method to use depends on the interface design requirements of the server.
[0123] 3. Add possible additional parameters
[0124] In addition to adding a file download license, you may also need to add other parameters, such as file type, file version, etc. These parameters are added in a similar way to the file download license.
[0125] In one of the embodiments, sending a file download request to a server according to a uniform resource locator for file download may include: creating a hyperlink tag, setting the value of a hyperlink reference attribute of the hyperlink tag to the uniform resource locator for file download, and triggering the file download request according to the set hyperlink tag.
[0126] Among them, the hyperlink tag refers to the HTML (HyperText Markup Language) The tag is used to define a hyperlink to link from one page to another. When a user clicks on the link, the browser will jump to the page pointed to by the link.
[0127] Specifically, the present application sends a file download request to a server according to a uniform resource locator for file download, which may include:
[0128] 1. Create Label
[0129] This application can dynamically create a Label.
[0130] 2. Settings Tag attributes
[0131] href attribute (hyperlink reference attribute): Assign the previously assembled uniform resource locator containing the file download license to The href attribute of the tag.
[0132] 3. Trigger download operation
[0133] This application can Tags are added to the document object model, and then simulate user click operations. Add the tag to the element of the page, and then use a.click() to simulate a click, so that the browser will respond according to The href attribute of the tag initiates a file download request.
[0134] This application uses When the tag sends a file download request, the browser will take over the download task. The tag triggers the browser's native download mechanism, which is independent of the page's JavaScript runtime environment. The browser will handle file downloads in the background. Unlike fetch or axios, which are requests initiated by JavaScript code, their execution is closely related to the life cycle of the page. Once the tab download is taken over by the browser, changes in the page status (such as the user leaving the page or jumping to other pages) usually do not affect the download of the file, because the browser will manage the download task itself and download the file from the server to the local computer. The page's JavaScript is not required to continuously maintain the download status. Therefore, during the download process, the user does not need to stay on the page all the time.
[0135] Therefore, this application uses The tag sends a file download request to solve the problem that users cannot leave the page, wait for a long time and do not know the download progress when using fetch and axios to download.
[0136] In one embodiment, Figure 5 As shown, a file downloading device is provided, comprising: a first receiving module 51, an acquiring module 52, a generating module 53, a sending module 54, a second receiving module 55, a query module 56 and a downloading module 57, wherein:
[0137] A first receiving module 51 is used to receive a request for obtaining a file download license submitted by a terminal in response to a file download instruction;
[0138] An acquisition module 52, used to extract user information and file information according to an acquisition request;
[0139] A generating module 53, used to generate a file download license according to user information and file information;
[0140] A sending module 54, used to send the file download license to the terminal, so that the terminal generates a file download request according to the file download license;
[0141] The second receiving module 55 is used to receive a file download request sent by the terminal and extract a file download license;
[0142] A query module 56, used to query whether there is a file download license in the pre-created cache;
[0143] The download module 57 is used to download the file when there is a file download license.
[0144] In one embodiment, the above-mentioned acquisition module 52 can extract the user token in the acquisition request, obtain user information and authorization information based on the user token, determine whether the user has the file download permission based on the authorization information, and when the user has the download permission, execute the step of generating a file download license based on the user information and file information.
[0145] In one embodiment, the generation module 53 may perform hash calculation according to user information, file information, a timestamp of the acquisition request and a preset hash algorithm to obtain the file download license.
[0146] In one embodiment, the query module 56 may set the file download license to an invalid state or destroy it after finding that the file download license exists in the cache.
[0147] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a file download method is implemented.
[0148] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: receiving a request for obtaining a file download license submitted by a terminal in response to a file download instruction, extracting user information and file information according to the acquisition request, generating a file download license according to the user information and the file information, sending the file download license to the terminal so that the terminal generates a file download request according to the file download license, receiving the file download request sent by the terminal, extracting the file download license, querying whether the file download license exists in a pre-created cache, and downloading the file when the file download license exists.
[0149] In one embodiment, when the processor executes a computer program to implement the above-mentioned steps of extracting user information and file information according to an acquisition request, the following steps are specifically implemented: extracting the user token in the acquisition request, obtaining user information and authorization information according to the user token, and when the processor executes the computer program, the following steps are also specifically implemented: determining whether the user has file download permission according to the authorization information, and when the user has download permission, executing the step of generating a file download license according to the user information and file information.
[0150] In one embodiment, when the processor executes a computer program to implement the above-mentioned step of generating a file download license based on user information and file information, the following steps are specifically implemented: performing a hash calculation based on user information, file information, a timestamp of the acquisition request and a preset hash algorithm to obtain a file download license.
[0151] In one embodiment, when the processor executes the computer program, the following steps are specifically implemented: after it is found that the file download license exists in the cache, the file download license is set to an invalid state or destroyed.
[0152] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: receiving a request for obtaining a file download license submitted by a terminal in response to a file download instruction, extracting user information and file information according to the acquisition request, generating a file download license according to the user information and the file information, sending the file download license to the terminal so that the terminal generates a file download request according to the file download license, receiving the file download request sent by the terminal, extracting the file download license, querying whether the file download license exists in a pre-created cache, and downloading the file when the file download license exists.
[0153] In one embodiment, when a computer program is executed by a processor to implement the above-mentioned steps of extracting user information and file information according to an acquisition request, the following steps are specifically implemented: extracting the user token in the acquisition request, obtaining user information and authorization information according to the user token; when the computer program is executed by the processor, the following steps are also specifically implemented: determining whether the user has file download permission according to the authorization information, and when the user has download permission, executing the step of generating a file download license according to the user information and file information.
[0154] In one embodiment, when the computer program is executed by the processor to implement the above-mentioned step of generating a file download license based on user information and file information, the following steps are specifically implemented: performing a hash calculation based on user information, file information, a timestamp of the acquisition request and a preset hash algorithm to obtain a file download license.
[0155] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented: after it is found that there is a file download license in the cache, the file download license is set to an invalid state or destroyed.
[0156] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the above-mentioned computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0157] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0158] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A file downloading method, characterized in that: The method comprises: A receiving terminal submits a request for obtaining a file download license in response to a file download instruction; Extracting user information and file information according to the acquisition request; Generate the file download license according to the user information and file information; sending the file download license to the terminal so that the terminal generates a file download request according to the file download license; receiving the file download request sent by the terminal, and extracting the file download license; Querying whether the file download license exists in a pre-created cache; When the file download license exists, the file download is performed.
2. The method according to claim 1, characterized in that The extracting user information and file information according to the acquisition request includes: Extract the user token in the acquisition request; Acquire user information and authorization information according to the user token; The method further comprises: Determining whether the user has the file download permission according to the authorization information; When the user has the download authority, the step of generating the file download license according to the user information and the file information is performed.
3. The method according to claim 1 or 2, characterized in that: The generating the file download license according to the user information and the file information includes: A hash calculation is performed according to the user information, the file information, the timestamp of the acquisition request and a preset hash algorithm to obtain the file download license.
4. The method according to claim 1, characterized in that: The method further comprises: After it is found that the file download license exists in the cache, the file download license is set to an invalid state or destroyed.
5. A file downloading method, characterized in that: The method comprises: Submitting a request for obtaining a file download license to a server in response to a file download instruction; receiving a file download license returned by the server, and generating a uniform resource locator for file download according to the file download license; Sending a file download request to the server according to the uniform resource locator of the file download; Receive the file to be downloaded returned by the server, and execute file download according to the file to be downloaded.
6. The method according to claim 5, characterized in that The step of generating a uniform resource locator for file download according to the file download license comprises: Add the file download license as a query parameter to the uniform resource locator of the file download; Alternatively, the file download license is added as a part of the path into the uniform resource locator of the file download.
7. The method according to claim 5, characterized in that The sending a file download request to the server according to the uniform resource locator of the file download comprises: Create hyperlink tags; Setting the value of the hyperlink reference attribute of the hyperlink tag to the uniform resource locator of the file download; The file download request is triggered according to the set hyperlink tag.
8. A file downloading device, characterized in that: The device comprises: A first receiving module, configured to receive a request for obtaining a file download license submitted by a terminal in response to a file download instruction; An acquisition module, used to extract user information and file information according to the acquisition request; A generating module, used for generating the file download license according to the user information and the file information; A sending module, used for sending the file download license to the terminal, so that the terminal generates a file download request according to the file download license; A second receiving module, configured to receive the file download request sent by the terminal and extract the file download license; A query module, used for querying whether the file download license exists in a pre-created cache; The download module is used to download the file when the file download license exists.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.