File uploading / downloading method, apparatus and device
Patent Information
- Application Number
- CN202510336827.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2026-09-22
AI Technical Summary
[0004]本发明的主要目的在于提供一种文件上传/下载方法、装置和设备,旨在解决服务器中存储空间的消耗过大,负担过重的问题
[0006]本申请实施例中先对压缩包进行解压,将压缩包内的子文件上传到服务器的存储器中,并删除服务器内的压缩包和子文件,避免了在服务器内同时存储压缩包和子文件带来的存储空间的消耗问题,至少可节约50%的存储空间,降低了服务器的负担。且将压缩包的标识与子文件的标识的对应关系,以及子文件的标识与子文件的属性信息的对应关系存储在服务器的数据库中,便于后续根据服务器中的信息对子文件进行组包。
Smart Images

Figure CN122802493A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, and device for uploading / downloading files. Background Technology
[0002] The current file upload service involves clicking to upload a compressed file, which is then uploaded to the server. The server's database then decompresses the compressed file to obtain its sub-files. Simultaneously, sub-files with extensions such as .dll, .exe, and .sys are whitelisted and saved to prevent them from being considered suspicious. This practice increases the consumption of storage space on the server, thereby increasing the server's workload.
[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this invention is to provide a file upload / download method, apparatus, and device, which aims to solve the problem of excessive storage space consumption and heavy burden on servers.
[0005] To achieve the above objectives, the present invention provides a file upload method applied to a server, comprising: receiving an uploaded compressed package; decompressing the compressed package to obtain sub-files; extracting attribute information and an identifier of the sub-files; uploading the correspondence between the sub-files and the sub-file identifiers to the server's storage; storing the correspondence between the identifiers of the compressed package and the identifiers of the sub-files, and the correspondence between the identifiers of the sub-files and the attribute information of the sub-files, in the server's database; and deleting the compressed package and the sub-files.
[0006] In this embodiment, the compressed package is first decompressed, and the sub-files within the compressed package are uploaded to the server's storage. The compressed package and sub-files are then deleted from the server, avoiding the storage space consumption problem caused by simultaneously storing the compressed package and sub-files on the server. This saves at least 50% of storage space and reduces the server's burden. Furthermore, the mapping between the compressed package's identifier and the sub-file's identifier, as well as the mapping between the sub-file's identifier and its attribute information, is stored in the server's database, facilitating subsequent reassembly of the sub-files based on the information stored on the server.
[0007] Optionally, before uploading the correspondence between the sub-file and its identifier to the server's storage, the method further includes: determining whether the server's storage already contains a sub-file with the same content as the sub-file; if not, uploading the correspondence between the sub-file and its identifier to the server's storage.
[0008] In this embodiment, before uploading a sub-file, it is first determined whether a sub-file with the same content is already stored in the server's storage. If the same sub-file exists, there is no need to store it again. In other words, the server only stores one copy of the sub-file with the same content, further reducing the server's storage burden. Especially for compressed packages containing multiple sub-files with the same content, only one sub-file needs to be stored, greatly reducing the server's storage burden.
[0009] Optionally, before decompressing the compressed package to obtain sub-files, the method further includes: determining whether the file size of the compressed package is less than or equal to a first preset value; and if the file size of the compressed package is determined to be less than or equal to the first preset value, then performing the step of decompressing the compressed package to obtain sub-files.
[0010] In this embodiment, the size of the compressed file is measured to measure the size of the sub-files. The compressed file is only decompressed when its size is less than or equal to a first preset value, i.e., when the sub-files do not excessively occupy server storage space. This avoids the situation where the server cannot store the sub-files after decompression, thus preventing server memory overload and server crash.
[0011] Optionally, after decompressing the compressed package to obtain the sub-file, the method further includes: saving the compressed package and the decompressed sub-file in the temporary directory of the server; deleting the compressed package and the sub-file includes: deleting the compressed package and the sub-file from the temporary directory of the server.
[0012] Optionally, after receiving the uploaded compressed package, the method further includes: extracting the identifier and attribute information of the compressed package; and storing the correspondence between the identifier and the attribute information of the compressed package in the database of the server. This facilitates subsequent repackaging of sub-files.
[0013] To achieve the above objectives, the present invention also provides a file download method applied to a server, comprising: responding to a received file download request, the file download request including an identifier of a compressed package to be downloaded; querying the server for an identifier of a sub-file corresponding to the identifier of the compressed package to be downloaded, and attribute information of the sub-file corresponding to the identifier of the sub-file, wherein the server pre-stores a correspondence between the identifier of the compressed package and the identifier of the sub-file, and a correspondence between the identifier of the sub-file and the attribute information of the sub-file; downloading the sub-file from the server's storage according to the identifier of the sub-file, wherein the server's storage pre-stores a correspondence between the sub-file and the identifier of the sub-file; assembling the sub-file and the attribute information of the sub-file into a compressed package; and generating a download link according to the storage address of the compressed package in the server.
[0014] Optionally, the server further stores a correspondence between the identifier of the compressed package and the attribute information of the compressed package; the step of assembling the sub-files and their attribute information to obtain a compressed package includes: searching for the corresponding attribute information of the compressed package in the server's database according to the identifier of the compressed package to be downloaded; and assembling the sub-files and their attribute information according to the attribute information of the compressed package to obtain a compressed package.
[0015] Optionally, after generating the download link based on the storage address of the compressed package on the server, the method further includes: deleting the sub-file and the compressed package from the server.
[0016] In addition, to achieve the above objectives, the present invention also proposes a file upload / download device, which includes a memory, a processor, and a file upload / download program stored on the memory and executable on the processor, the file upload / download program being configured to implement the method described above.
[0017] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a file upload / download program, which, when executed by a processor, implements the method described above.
[0018] Furthermore, to achieve the above objectives, the present invention also proposes a file upload device, comprising: a receiving module, a processing module, and a storage module; the receiving module is used to receive uploaded compressed packages; the processing module is used to decompress the compressed packages to obtain sub-files, extract the attribute information and identifiers of the sub-files, and upload the correspondence between the sub-files and the sub-file identifiers to the storage module; the processing module is used to store the correspondence between the identifiers of the compressed packages and the identifiers of the sub-files, and the correspondence between the identifiers of the sub-files and the attribute information of the sub-files, in the database of the server; and delete the compressed packages and the sub-files.
[0019] Furthermore, to achieve the above objectives, the present invention also proposes a file download device, comprising: a processing module, a storage module, a download module, and a generation module; the processing module is used to respond to a received file download request, the file download request including an identifier of a compressed package to be downloaded, querying the database of a server for the identifier of a sub-file corresponding to the identifier of the compressed package to be downloaded, and the attribute information of the sub-file corresponding to the identifier of the sub-file, wherein the database of the server pre-stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file; the download module is used to download the sub-file from the storage module according to the identifier of the sub-file, wherein the storage module pre-stores the correspondence between the sub-file and the identifier of the sub-file; the processing module is used to assemble the sub-file and the attribute information of the sub-file into a compressed package; the generation module is used to generate a download link according to the storage address of the compressed package in the storage module. Attached Figure Description
[0020] Figure 1 This is a schematic diagram of the hardware operating environment of the file upload / download device involved in the embodiments of the present invention;
[0021] Figure 2 This is a flowchart illustrating the first embodiment of the file upload method of the present invention;
[0022] Figure 3 This is a flowchart illustrating a second embodiment of the file upload method of the present invention;
[0023] Figure 4 This is a flowchart illustrating a third embodiment of the document download method of the present invention;
[0024] Figure 5 This is a flowchart illustrating the fourth embodiment of the document download method of the present invention;
[0025] Figure 6 This is a schematic diagram of the file upload device of the present invention;
[0026] Figure 7 This is a schematic diagram of the document download device of the present invention.
[0027] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0028] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0029] Reference Figure 1 , Figure 1 This is a schematic diagram of the hardware operating environment of the file upload / download device involved in the embodiments of the present invention.
[0030] like Figure 1 As shown, the file upload / download device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen, and optionally, it may also include a standard wired interface or a wireless interface. In this invention, the wired interface of the user interface 1003 may be a USB interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (RAM) or a non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0031] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the file upload / download device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0032] like Figure 1 As shown, the memory 1005, which is identified as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a file upload / download program.
[0033] exist Figure 1In the file upload / download device shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the user device; the file upload / download device calls the file upload / download program stored in the memory 1005 through the processor 1001 and executes the file upload / download method provided in the embodiment of the present invention.
[0034] Based on the above hardware structure, an embodiment of the file upload / download method of the present invention is proposed.
[0035] The current file upload service involves clicking to upload a compressed file, which is then uploaded to the server. The server then decompresses the compressed file to extract its sub-files. Sub-files with extensions like .dll, .exe, and .sys are whitelisted and saved to prevent them from being flagged as suspicious. This results in the server storing not only the uploaded compressed file but also its decompressed sub-files, significantly increasing server storage space consumption and workload.
[0036] To address this, this application proposes a file upload method applied to a server, comprising: receiving an uploaded compressed package; decompressing the compressed package to obtain sub-files; extracting attribute information and identifiers of the sub-files; uploading the correspondence between the sub-files and their identifiers to the server's storage; storing the correspondence between the compressed package identifiers and the sub-file identifiers, and the correspondence between the sub-file identifiers and their attribute information, in the server's database; and deleting the compressed package and the sub-files.
[0037] In this embodiment, the compressed package is first decompressed, and the sub-files within the compressed package are uploaded to the server's storage. The compressed package and sub-files are then deleted from the server, avoiding the storage space consumption problem caused by simultaneously storing the compressed package and sub-files on the server. This saves at least 50% of storage space and reduces the server's burden. Furthermore, the mapping between the compressed package's identifier and the sub-file's identifier, as well as the mapping between the sub-file's identifier and its attribute information, is stored in the server's database, facilitating subsequent reassembly of the sub-files based on the information stored on the server.
[0038] The file upload method provided by the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0039] Figure 2 This is a flowchart illustrating the first embodiment of the file upload method of the present invention. The file upload method in this embodiment includes:
[0040] Step S201: Receive the uploaded compressed package.
[0041] Taking the example of an electronic device uploading a compressed file to the backend server of an APP, on the electronic device, the user clicks to upload the compressed file, which is then uploaded from the electronic device to the backend server, and the backend server can then receive the uploaded compressed file.
[0042] Step S202: Decompress the compressed package to obtain sub-files.
[0043] After receiving the compressed file, decompress it to obtain multiple sub-files (including the contents of each sub-file). Specifically, the file format can be extracted, and the corresponding decompression tool can be selected based on the format to ensure successful decompression. For example, if the compressed file is in zip format, 7-zip can be used; if it is in rar format, WinRAR can be used.
[0044] Optionally, before decompressing the compressed file to obtain sub-files, the method further includes: determining whether the file size of the compressed file is less than or equal to a first preset value; and if the file size of the compressed file is determined to be less than or equal to the first preset value, then performing the step of decompressing the compressed file to obtain sub-files.
[0045] If the compressed file is too large, the decompressed sub-files will occupy even more memory, potentially causing the server to crash due to insufficient storage space. This embodiment measures the size of the sub-files by considering the size of the compressed file. Decompression is only performed when the compressed file size is less than or equal to a first preset value—that is, when the sub-files do not excessively occupy server storage space. This avoids situations where the server cannot store the decompressed sub-files, preventing server memory overload and crashes.
[0046] The first preset value can be set according to the server's memory size, but it must be less than half of the server's memory size. This is because the server needs to temporarily store the compressed file and its decompressed sub-files. The size of the sub-files is generally larger than the size of the compressed file. Therefore, the server can only temporarily store the compressed file and its decompressed sub-files if the size of the compressed file is less than half of the server's memory size. For example, if the server's memory size is 200GB, the first preset value should be less than 100GB, such as 50GB or 20GB.
[0047] Optionally, during the decompression of the compressed package, if the number of levels in the compressed package is greater than or equal to a second preset value, the decompression is stopped and the decompressed sub-files are deleted; if the number of levels in the compressed package is less than the second preset value, the compressed package is decompressed again to obtain sub-files.
[0048] This is because when the compressed package has too many layers, the time required to assemble the package is longer, and the possibility of errors during the assembly process is greater. Therefore, in order to avoid this situation, in this embodiment, when the number of layers in the compressed package is greater than or equal to the second preset value, that is, when the number of layers in the compressed package is not too many, the compressed package is decompressed to obtain sub-files, so as to avoid the assembly time being too long or the possibility of assembly errors being too high.
[0049] The second preset value can be set by the user based on experience.
[0050] Step S203: Extract the attribute information of the sub-files and the identifier of the sub-files.
[0051] After decompressing the compressed package to obtain sub-files, the attribute information and identifiers of each sub-file are extracted one by one. The attribute information of a sub-file includes at least: the sub-file name and its specific path, and may also include: the sub-file size; the sub-file identifier includes its hash value, which is generated based on the sub-file's content. Sub-files with the same content but different filenames can generate the same hash value. Optionally, the hash value can be an MD5 hash.
[0052] Step S204: Upload the correspondence between the sub-files and their identifiers to the server's storage.
[0053] The sub-files obtained after decompressing the received compressed package are temporarily stored in the server's temporary directory, not directly in the server's storage. The temporary directory is a location in the server's file system used to store temporary files, which are typically created by applications during runtime but do not need to be stored permanently. Server storage refers to devices or services used for long-term data storage, including hard drives, solid-state drives, network-attached storage (NAS), storage area networks (SANs), and cloud storage services.
[0054] In this step, the correspondence between the sub-files (including the specific content of the sub-files) and the sub-file identifiers is uploaded from the server's temporary directory to the server's storage.
[0055] Taking the hash value as an example, the correspondence between the sub-files stored in the memory and the sub-file identifiers can be shown in Table 1 below:
[0056]
[0057]
[0058] Step S205: Store the correspondence between the identifier of the compressed package and the identifier of the sub-file, as well as the correspondence between the identifier of the sub-file and the attribute information of the sub-file, in the database of the server.
[0059] To facilitate the subsequent assembly of sub-files, the server's database also stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, as well as the correspondence between the identifier of the sub-file and the attribute information of the sub-file. These two correspondences can be stored in different tables or in the same table.
[0060] Taking the hash value as an example, the storage format of compressed package 1 and compressed package 2 in the database can be shown in Table 2 below:
[0061]
[0062] Optionally, after receiving the uploaded compressed package in step S201, the method further includes: extracting the identifier and attribute information of the compressed package; and storing the correspondence between the identifier and the attribute information of the compressed package in the database of the server.
[0063] To facilitate subsequent assembly of sub-files, the server also stores a mapping between compressed file identifiers and their attribute information. This attribute information may include the compressed file's format type and size. This mapping can be stored separately or together with the mappings described above.
[0064] Taking the hash value as an example, the storage format of compressed package 1 and compressed package 2 in the database can be shown in Table 3 below:
[0065]
[0066]
[0067] Step S206: Delete the compressed file and its sub-files.
[0068] In this embodiment, the correspondence between sub-files and their identifiers is uploaded to the server's storage, and the correspondence between the identifier of the compressed package and the identifier of the sub-files, as well as the correspondence between the identifier of the sub-files and their attribute information, is stored in the server's database. Then, the compressed package and sub-files are deleted from the server's temporary directory. This avoids the storage space consumption problem caused by storing the compressed package and sub-files on the server at the same time, saving at least 50% of the storage space and reducing the server's burden.
[0069] Figure 3 This is a flowchart illustrating a second embodiment of the file upload method of the present invention. The file upload method in this embodiment includes:
[0070] Step S301: Receive the uploaded compressed package.
[0071] Step S302: Decompress the compressed package to obtain sub-files.
[0072] Step S303: Extract the attribute information of the sub-files and the identifier of the sub-files.
[0073] In this embodiment, steps S301 to S303 are the same as steps S201 to S203 in the first embodiment described above. To avoid repetition, they will not be described again here.
[0074] Step S304: Determine whether the server's memory already contains a subfile with the same content as the subfile. If not, proceed to step S305; if yes, proceed to step S306.
[0075] Before uploading a subfile, the system checks if the server already has a subfile with the same content. If a subfile already exists, it doesn't need to be stored again. In other words, the server only stores one copy of each subfile with identical content, further reducing the server's storage burden. This is especially true for compressed files containing multiple subfiles with the same content; only one copy needs to be stored, significantly reducing the server's storage load.
[0076] During the judgment process, the hash values of each sub-file can be searched one by one in the memory. Since the content of a sub-file corresponds uniquely to its hash value, if the hash value of a sub-file appears in the memory, it indicates that the content of the sub-file must be stored in the memory.
[0077] Step S305: Upload the correspondence between the sub-files and their identifiers to the server's storage.
[0078] If no identical sub-file exists, the correspondence between the sub-file and its identifier is uploaded to the server's storage. Step S305 can be referred to step S204 in the first embodiment, and will not be repeated here to avoid repetition.
[0079] Step S306: Store the correspondence between the identifier of the compressed package and the identifier of the sub-file, as well as the correspondence between the identifier of the sub-file and the attribute information of the sub-file, in the database of the server.
[0080] If identical sub-files exist, there is no need to store them repeatedly. After the hash values of each sub-file are searched in the memory one by one, the correspondence between the identifier of the compressed package and the identifier of the sub-file, as well as the correspondence between the identifier of the sub-file and the attribute information of the sub-file, are stored in the server's database. Step S306 can be referred to step S205 of the first embodiment, and will not be repeated here to avoid repetition.
[0081] Step S307: Delete the compressed file and its sub-files.
[0082] Step S307 can be referred to step S206 of the first embodiment, and will not be repeated here to avoid repetition.
[0083] In this embodiment, before uploading a sub-file, it is first determined whether a sub-file with the same content is already stored in the server's storage. If the same sub-file exists, there is no need to store it again. In other words, the server only stores one copy of the sub-file with the same content, further reducing the server's storage burden. Especially for compressed packages containing multiple sub-files with the same content, only one sub-file needs to be stored, greatly reducing the server's storage burden.
[0084] Figure 4 This is a flowchart illustrating a third embodiment of the file download method of the present invention. In this embodiment, the file download method includes:
[0085] Step S401: In response to the received file download request, query the server's database for the identifier of the sub-file corresponding to the identifier of the compressed package to be downloaded, as well as the attribute information of the sub-file corresponding to the identifier of the sub-file.
[0086] The file download request includes the identifier of the compressed package to be downloaded; the server's database pre-stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, as well as the correspondence between the identifier of the sub-file and the attribute information of the sub-file, as detailed in Table 2.
[0087] Taking an electronic device requesting a download of a compressed file from the backend server of an app as an example, on the electronic device, the user clicks to download the compressed file. Based on the compressed file's identifier, a file download request is generated and sent from the electronic device to the backend server. The backend server receives the file download request and, in response, queries its database for the identifier of the sub-file corresponding to the identifier of the compressed file to be downloaded, as well as the attribute information of the sub-file corresponding to that identifier. The sub-file's attribute information includes at least: the sub-file's name and its specific path, and may also include: the sub-file's size.
[0088] For example, if the identifier of the compressed package to be downloaded is the hash value of compressed package 1, then the hash values of sub-files 1-4, as well as the attribute information of sub-files 1-4, are found in Table 2 stored in the server's memory.
[0089] Step S402: Download the sub-file from the server's storage based on the sub-file's identifier.
[0090] The server's memory pre-stores the correspondence between sub-files and their identifiers, as detailed in Table 1.
[0091] After retrieving the identifier of the sub-file corresponding to the identifier of the compressed package to be downloaded from the server's database, the sub-file is downloaded from the server's storage to the server's temporary directory based on the sub-file's identifier. For example, if the identifier of the compressed package to be downloaded is the hash value of compressed package 1, and the hash value of compressed package 1 found in the database corresponds to the hash values of sub-files 1-4, then the specific contents of sub-files 1-4 can be found in Table 1 stored in the server's storage, and the specific contents of sub-files 1-4 are downloaded from the server's storage to the server's temporary directory.
[0092] In practice, during the download of a sub-file from the server's storage based on its hash value (i.e., identifier), after downloading a sub-file, a hash value is generated based on the sub-file's content. This generated hash value is then compared with the stored hash value to determine if they are the same. If they are the same, it indicates that the generated hash value and the stored hash value are identical, and the downloaded sub-file content is correct. If they are different, it indicates that the generated hash value and the stored hash value are not identical, and the downloaded sub-file content is inaccurate. In this case, the user needs to be notified on the electronic device that a download error has occurred.
[0093] Step S403: Assemble the sub-files and their attribute information to obtain a compressed package.
[0094] After obtaining the sub-files and their attribute information, the sub-files and their attribute information can be packaged into a compressed package, which is then stored in the server's storage.
[0095] Step S404: Generate a download link based on the storage address of the compressed package on the server.
[0096] Unlike the current process where the server directly sends a compressed file to the electronic device upon receiving a file download request, in this embodiment, after receiving a file download request, the server needs to execute steps S401 to S403 to assemble the file into a compressed file. Then, based on the storage address of the compressed file in the server's memory, a download link is generated. The user can then click the download link on the electronic device to download the desired compressed file. In other words, in this file download method, after the user clicks the download link, they need to wait for a period of time before the electronic device displays the download link, and only after clicking the link can the download operation be completed.
[0097] Optionally, after generating the download link based on the storage address of the compressed package on the server, step S404 further includes deleting the sub-files and compressed package from the server to further reduce the server's memory burden.
[0098] Figure 5This is a flowchart illustrating a third embodiment of the file download method of the present invention. In this embodiment, the file download method includes:
[0099] Step S501: In response to the received file download request, query the server's database for the identifier of the sub-file corresponding to the identifier of the compressed package to be downloaded, as well as the attribute information of the sub-file corresponding to the identifier of the sub-file.
[0100] Step S502: Download the sub-file from the server's storage based on the sub-file's identifier.
[0101] The steps S501-S502 described above are the same as steps S401-S402 in the third embodiment, and will not be repeated here to avoid repetition.
[0102] Step S503: Based on the identifier of the compressed package to be downloaded, search for the attribute information of the corresponding compressed package in the server's database.
[0103] The server's database also pre-stores the correspondence between compressed file identifiers and their attribute information, as detailed in Table 3. The compressed file attribute information may include the compressed file format type and the compressed file size.
[0104] For example, if the identifier of the compressed package to be downloaded is the hash value of compressed package 1, then the attribute information of compressed package 1 can be obtained by looking up Table 3.
[0105] It is worth noting that step S503 can be executed simultaneously with step S501, and there is no strict execution order. Figure 5 This is an example provided for the convenience of drawing.
[0106] Step S504: Based on the attribute information of the compressed package, assemble the sub-files and their attribute information to obtain a compressed package.
[0107] Based on the attributes of the compressed file, the sub-files and their attributes are grouped together to form a compressed file. For example, the compressed file's attributes include its format type. Based on the attributes of the sub-files (including their paths and filenames), each sub-file is stored according to its specific path and filename to form a single file. Then, a suitable compression tool is selected based on the compressed file's format type to compress the individual files, resulting in the compressed file. For example, if the compressed file's format is zip, 7-zip can be used; if the compressed file's format is rar, WinRAR can be used.
[0108] Step S505: Generate a download link based on the storage address of the compressed package on the server.
[0109] A download link is generated based on the storage address of the compressed file in the server's memory. Users can click the download link on their electronic devices to download the compressed file they want.
[0110] The file upload and download methods provided in this application significantly save storage space, ensure file integrity, and optimize user experience by retaining only the decompressed sub-files and providing packaged download services. This makes this application have broad application prospects and important practical value in the field of file management and storage.
[0111] This invention also proposes a storage medium storing a file upload / download program, which, when executed by a processor, implements a file upload / download method as described in any of the above embodiments.
[0112] Reference Figure 6 The present invention also proposes a file upload device 600, which includes a receiving module 610, a processing module 620, and a storage module 630.
[0113] The receiving module 610 is used to receive uploaded compressed packages.
[0114] The processing module 620 is used to decompress the compressed package to obtain sub-files, extract the attribute information of the sub-files and the identifier of the sub-files, and upload the correspondence between the sub-files and the sub-file identifiers to the storage module 630.
[0115] The processing module 620 stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, as well as the correspondence between the identifier of the sub-file and the attribute information of the sub-file, in the database of the file upload device 600; and deletes the compressed package and the sub-file.
[0116] Optionally, the processing module 620 is used to determine whether a subfile with the same content as the subfile has been stored in the storage module 630; if not, the correspondence between the subfile and the identifier of the subfile is uploaded to the storage module 630.
[0117] Optionally, before the processing module 620 decompresses the compressed package to obtain sub-files, it determines whether the file size of the compressed package is less than or equal to a first preset value; if it determines that the file size of the compressed package is less than or equal to the first preset value, then the step of decompressing the compressed package to obtain sub-files is performed.
[0118] Optionally, after the processing module 620 decompresses the compressed package to obtain sub-files, it is also used to save the compressed package and the decompressed sub-files in a temporary directory; specifically, the processing module 620 is used to delete the compressed package and sub-files from the temporary directory.
[0119] Optionally, after receiving the uploaded compressed package, the processing module 620 is also used to extract the identifier and attribute information of the compressed package; and to store the correspondence between the identifier and the attribute information of the compressed package in the database of the file upload device 600.
[0120] Other embodiments or specific implementations of the file upload device described in this invention can be found in the above-described file upload method embodiments, and will not be repeated here.
[0121] Reference Figure 7 The present invention also proposes a file download device 700, which includes a processing module 710, a storage module 720, a download module 730, and a generation module 740.
[0122] The processing module 710 is used to respond to a received file download request, which includes the identifier of a compressed package to be downloaded, and to query the database of the file download device 700 for the identifier of a sub-file corresponding to the identifier of the compressed package to be downloaded, as well as the attribute information of the sub-file corresponding to the identifier of the sub-file. The database of the file download device 700 pre-stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, as well as the correspondence between the identifier of the sub-file and the attribute information of the sub-file.
[0123] The download module 730 is used to download a sub-file from the storage module 720 according to the sub-file's identifier, wherein the storage module 720 pre-stores the correspondence between sub-files and their identifiers;
[0124] Processing module 710 is used to assemble sub-files and their attribute information into a compressed package;
[0125] The generation module 740 is used to generate a download link based on the storage address of the compressed package in the file download device 700.
[0126] Optionally, the database of the file download device 700 also stores the correspondence between the identifier of the compressed package and the attribute information of the compressed package.
[0127] The processing module 710 is used to search for the attribute information of the corresponding compressed package in the database of the file download device 700 according to the identifier of the compressed package to be downloaded; and to assemble the sub-files and their attribute information into a compressed package according to the attribute information of the compressed package.
[0128] Optionally, after generating a download link based on the storage address of the compressed package in the file download device 700, the processing module 710 is also used to delete sub-files and compressed packages from the file download device 700.
[0129] Other embodiments or specific implementations of the file download device described in this invention can be found in the above-described embodiments of the file download methods, and will not be repeated here.
[0130] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0131] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0132] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0133] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
[0134] This invention discloses A1, a file upload method applied to a server, comprising:
[0135] Receive uploaded compressed files;
[0136] The compressed package is decompressed to obtain sub-files;
[0137] Extract the attribute information of the sub-file and the identifier of the sub-file;
[0138] The correspondence between the sub-files and their identifiers is uploaded to the server's storage.
[0139] The correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file are stored in the database of the server;
[0140] Delete the compressed file and the sub-files.
[0141] A2. The method as described in A1, before uploading the correspondence between the sub-file and the identifier of the sub-file to the server's storage, further includes:
[0142] Determine whether the server's memory already contains a subfile with the same content as the subfile;
[0143] If not stored, the correspondence between the sub-file and its identifier is uploaded to the server's storage.
[0144] A3. The method as described in A1 or A2, before decompressing the compressed package to obtain the sub-files, further includes:
[0145] Determine whether the file size of the compressed package is less than or equal to a first preset value;
[0146] If the file size of the compressed package is determined to be less than or equal to a first preset value, then the step of decompressing the compressed package to obtain sub-files is performed.
[0147] A4. The method as described in any one of A1 to A3, further comprising, after decompressing the compressed package to obtain the sub-files:
[0148] The compressed package and the decompressed sub-files are saved in the temporary directory of the server;
[0149] Deleting the compressed file and the sub-files includes: deleting the compressed file and the sub-files from the temporary directory of the server.
[0150] A5. The method as described in any one of A1 to A4, further comprising, after receiving the uploaded compressed package:
[0151] Extract the identifier and attribute information of the compressed file;
[0152] The correspondence between the identifier of the compressed package and the attribute information of the compressed package is stored in the database of the server.
[0153] This invention also discloses B1. A file download method, applied to a server, comprising:
[0154] In response to a received file download request, the file download request includes an identifier of a compressed package to be downloaded. The server queries the database for the identifier of a sub-file corresponding to the identifier of the compressed package to be downloaded, and the attribute information of the sub-file corresponding to the identifier of the sub-file. The database of the server pre-stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file.
[0155] The sub-file is downloaded from the server's storage according to its identifier, wherein the server's storage pre-stores the correspondence between sub-files and their identifiers;
[0156] The sub-files and their attribute information are packaged together to obtain a compressed package;
[0157] A download link is generated based on the storage address of the compressed file on the server.
[0158] B12. As described in B1, the server further stores the correspondence between the identifier of the compressed package and the attribute information of the compressed package;
[0159] The process of assembling the sub-files and their attribute information to obtain a compressed package includes:
[0160] Based on the identifier of the compressed package to be downloaded, the corresponding attribute information of the compressed package is searched in the database of the server;
[0161] Based on the attribute information of the compressed package, the sub-files and their attribute information are grouped together to obtain a compressed package.
[0162] B3. The method as described in B1 or B2, after generating the download link based on the storage address of the compressed package on the server, further includes:
[0163] Delete the sub-file and the compressed package from the server.
[0164] The present invention also discloses C1. A file upload / download device, the file upload / download device comprising: a memory, a processor, and a file upload / download program stored on the memory and executable on the processor, wherein when the file upload / download program is executed by the processor, it implements a file upload method as described in any one of A1 to A5, or implements a file download method as described in any one of B1 to B3.
[0165] The present invention also discloses D1. a storage medium storing a file upload / download program, wherein the file upload / download program, when executed by a processor, is a file upload method as described in any one of A1 to A5, or a file download method as described in any one of B1 to B3.
[0166] The present invention also discloses E1. A file upload device, comprising: a receiving module, a processing module, and a storage module;
[0167] The receiving module is used to receive uploaded compressed packages;
[0168] The processing module is used to decompress the compressed package to obtain sub-files, extract the attribute information of the sub-files and the identifier of the sub-files, and upload the correspondence between the sub-files and the sub-file identifiers to the storage module;
[0169] The processing module is used to store the correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file in the database of the file upload device; and delete the compressed package and the sub-file.
[0170] E2. The apparatus as described in E1, wherein the processing module is configured to determine whether a sub-file with the same content as the sub-file has already been stored in the storage module; if not, the correspondence between the sub-file and the identifier of the sub-file is uploaded to the storage module.
[0171] E3. In the apparatus described in E1 or E2, before the processing module decompresses the compressed package to obtain sub-files, it determines whether the file size of the compressed package is less than or equal to a first preset value; if it is determined that the file size of the compressed package is less than or equal to the first preset value, the step of decompressing the compressed package to obtain sub-files is then performed.
[0172] E4. The apparatus as described in any one of E1 to E3, wherein after the processing module decompresses the compressed package to obtain a sub-file, it is further configured to save the compressed package and the decompressed sub-file in a temporary directory;
[0173] The processing module is specifically used to delete the compressed package and the sub-files from the temporary directory.
[0174] E5. In any one of E1 to E4, after receiving the uploaded compressed package, the processing module is further configured to extract the identifier of the compressed package and the attribute information of the compressed package; and store the correspondence between the identifier of the compressed package and the attribute information of the compressed package in the database of the file upload device.
[0175] The present invention also discloses F1. a file download device, comprising: a processing module, a storage module, a download module and a generation module;
[0176] The processing module is used to respond to a received file download request, the file download request including the identifier of a compressed package to be downloaded, querying the database of the file download device for the identifier of a sub-file corresponding to the identifier of the compressed package to be downloaded, and the attribute information of the sub-file corresponding to the identifier of the sub-file. The database of the file download device pre-stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file.
[0177] The download module is used to download the sub-file from the storage module according to the identifier of the sub-file, wherein the storage module pre-stores the correspondence between sub-files and sub-file identifiers;
[0178] The processing module is used to assemble the sub-files and their attribute information into a compressed package;
[0179] The generation module is used to generate a download link based on the storage address of the compressed package on the file download device.
[0180] F2. The device as described in F1, wherein the database of the file download device further stores the correspondence between the identifier of the compressed package and the attribute information of the compressed package;
[0181] The processing module is used to search for the attribute information of the corresponding compressed package in the database of the file download device according to the identifier of the compressed package to be downloaded; and to assemble the sub-files and their attribute information into a compressed package according to the attribute information of the compressed package.
[0182] F3. The apparatus as described in F1 or F2, wherein after generating a download link based on the storage address of the compressed package in the file download device, the processing module is further configured to delete the sub-file and the compressed package from the file download device.
Claims
1. A file upload method, characterized in that, Applied to servers, including: Receive uploaded compressed files; The compressed package is decompressed to obtain sub-files; Extract the attribute information of the sub-file and the identifier of the sub-file; The correspondence between the sub-files and their identifiers is uploaded to the server's storage. The correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file are stored in the database of the server; Delete the compressed file and the sub-files.
2. The method as described in claim 1, characterized in that, Before uploading the correspondence between the sub-files and their identifiers to the server's storage, the method further includes: Determine whether the server's memory already contains a subfile with the same content as the subfile; If not stored, the correspondence between the sub-file and its identifier is uploaded to the server's storage.
3. The method as described in claim 1 or 2, characterized in that, Before decompressing the compressed package to obtain sub-files, the process also includes: Determine whether the file size of the compressed package is less than or equal to a first preset value; If the file size of the compressed package is determined to be less than or equal to a first preset value, then the step of decompressing the compressed package to obtain sub-files is performed.
4. The method according to any one of claims 1 to 3, characterized in that, After decompressing the compressed package to obtain sub-files, the process further includes: The compressed package and the decompressed sub-files are saved in the temporary directory of the server; Deleting the compressed file and the sub-files includes: deleting the compressed file and the sub-files from the temporary directory of the server.
5. The method according to any one of claims 1 to 4, characterized in that, After receiving the uploaded compressed package, the process also includes: Extract the identifier and attribute information of the compressed file; The correspondence between the identifier of the compressed package and the attribute information of the compressed package is stored in the database of the server.
6. A file download method, characterized in that, Applied to servers, including: In response to a received file download request, the file download request includes an identifier of a compressed package to be downloaded. The server queries the database for the identifier of a sub-file corresponding to the identifier of the compressed package to be downloaded, and the attribute information of the sub-file corresponding to the identifier of the sub-file. The database of the server pre-stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file. The sub-file is downloaded from the server's storage according to its identifier, wherein the server's storage pre-stores the correspondence between sub-files and their identifiers; The sub-files and their attribute information are packaged together to obtain a compressed package; A download link is generated based on the storage address of the compressed file on the server.
7. The method as described in claim 6, characterized in that, The server also stores the correspondence between the identifier of the compressed package and the attribute information of the compressed package; The process of assembling the sub-files and their attribute information to obtain a compressed package includes: Based on the identifier of the compressed package to be downloaded, the corresponding attribute information of the compressed package is searched in the database of the server; Based on the attribute information of the compressed package, the sub-files and their attribute information are grouped together to obtain a compressed package.
8. A file upload / download device, characterized in that, The file upload / download device includes: a memory, a processor, and a file upload / download program stored on the memory and executable on the processor. When the file upload / download program is executed by the processor, it implements the file upload method as described in any one of claims 1 to 5, or, as described in any one of claims 6 to 7, the file download method.
9. A file upload device, characterized in that, include: The system includes a receiving module, a processing module, and a storage module. The receiving module is used to receive uploaded compressed packages; The processing module is used to decompress the compressed package to obtain sub-files, extract the attribute information of the sub-files and the identifier of the sub-files, and upload the correspondence between the sub-files and the sub-file identifiers to the storage module; The processing module is used to store the correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file in the database of the file upload device; and delete the compressed package and the sub-file.
10. A file downloading device, characterized in that, include: Processing module, storage module, download module, and generation module; The processing module is used to respond to a received file download request, the file download request including the identifier of a compressed package to be downloaded, querying the database of the file download device for the identifier of a sub-file corresponding to the identifier of the compressed package to be downloaded, and the attribute information of the sub-file corresponding to the identifier of the sub-file. The database of the file download device pre-stores the correspondence between the identifier of the compressed package and the identifier of the sub-file, and the correspondence between the identifier of the sub-file and the attribute information of the sub-file. The download module is used to download the sub-file from the storage module according to the identifier of the sub-file, wherein the storage module pre-stores the correspondence between sub-files and sub-file identifiers; The processing module is used to assemble the sub-files and their attribute information into a compressed package; The generation module is used to generate a download link based on the storage address of the compressed package on the file download device.