CN106844766A - The method and device of a kind of compressed file decompression - Google Patents
The method and device of a kind of compressed file decompression Download PDFInfo
- Publication number
- CN106844766A CN106844766A CN201710099690.4A CN201710099690A CN106844766A CN 106844766 A CN106844766 A CN 106844766A CN 201710099690 A CN201710099690 A CN 201710099690A CN 106844766 A CN106844766 A CN 106844766A
- Authority
- CN
- China
- Prior art keywords
- file
- decompressed
- decompression
- folder
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/18—File system types
- G06F16/182—Distributed file systems
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/174—Redundancy elimination performed by the file system
- G06F16/1744—Redundancy elimination performed by the file system using compression, e.g. sparse files
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开了一种压缩文件解压的方法,网盘服务端获取待解压文件的文件信息;上述网盘服务端根据上述文件信息,调用解压应用程序编程接口对上述待解压文件进行解压操作,得到解压文件。通过获得待解压文件的文件信息,上述待解压文件存储于上述网盘服务端上,上述网盘服务端可以通过调用解压应用程序编程接口来对待解压文件进行解压操作,以实现在网盘服务端上解压压缩文件。此外,本发明还公开了一种压缩文件解压的装置,与上述方法有一一对应的优点。
The invention discloses a method for decompressing a compressed file. The network disk server obtains the file information of the file to be decompressed; the network disk server calls the decompression application programming interface to perform the decompression operation on the above-mentioned file to be decompressed according to the above file information, and obtains unzip files. By obtaining the file information of the file to be decompressed, the above-mentioned file to be decompressed is stored on the above-mentioned network disk server, and the above-mentioned network disk server can decompress the file to be decompressed by calling the decompression application programming interface, so as to realize the decompression operation on the network disk server. Unzip the compressed file on . In addition, the invention also discloses a device for decompressing compressed files, which has the advantages of one-to-one correspondence with the above method.
Description
技术领域technical field
本发明涉及云存储领域,特别是涉及一种压缩文件解压的方法以及装置。The invention relates to the field of cloud storage, in particular to a method and device for decompressing compressed files.
背景技术Background technique
随着网络技术和云技术的不断发展,云技术的应用也越来越广泛。With the continuous development of network technology and cloud technology, the application of cloud technology is becoming more and more extensive.
云存储是云技术的应用之一,其可以将文件存储至网盘服务器,即用户可以将各种各样的文件或数据上传至云端服务器,进行相应存储。云端存储可以保证文件永不丢失,也可以进行数据同步等。云端存储的文件是各式各样的,其中就包括压缩文件,例如Zip压缩文件。当用户将压缩文件存储于网盘服务器上之后,可能需要对压缩文件进行查看,进一步地,也可能需要将压缩文件进行解压,以进行后续操作。Cloud storage is one of the applications of cloud technology, which can store files to the network disk server, that is, users can upload various files or data to the cloud server for corresponding storage. Cloud storage can ensure that files will never be lost, and data synchronization can also be performed. There are various kinds of files stored in the cloud, including compressed files, such as Zip compressed files. After storing the compressed file on the network disk server, the user may need to view the compressed file, and further, may also need to decompress the compressed file for subsequent operations.
但是,现有技术中还无法在网盘服务器解压压缩文件,故如何在网盘服务器上解压压缩文件是本领域亟待解决的问题。However, in the prior art, the compressed file cannot be decompressed on the network disk server, so how to decompress the compressed file on the network disk server is an urgent problem in the art.
发明内容Contents of the invention
本发明的目的是提供一种压缩文件解压的方法以及装置,目的在于解决现有技术中网盘服务器无法解压压缩文件的问题。The purpose of the present invention is to provide a method and device for decompressing compressed files, aiming to solve the problem that the network disk server cannot decompress compressed files in the prior art.
为解决上述技术问题,本发明提供一种压缩文件解压的方法,该方法包括:In order to solve the above-mentioned technical problems, the present invention provides a method for decompressing compressed files, the method comprising:
网盘服务端获取待解压文件的文件信息;The network disk server obtains the file information of the file to be decompressed;
所述网盘服务端根据所述文件信息,调用解压应用程序编程接口对所述待解压文件进行解压操作,得到解压文件。According to the file information, the network disk server invokes a decompression application programming interface to perform a decompression operation on the file to be decompressed to obtain the decompressed file.
可选地,所述网盘服务端根据所述文件信息,调用解压应用程序编程接口对所述待解压文件进行解压操作,得到解压文件包括:Optionally, the network disk server calls a decompression application programming interface to decompress the file to be decompressed according to the file information, and the obtained decompressed file includes:
所述网盘服务端对所述待解压文件内所包含的待解压对象进行循环遍历,判断当前待解压对象的类别,所述待解压对象为文件或文件夹;The network disk server loops through the objects to be decompressed contained in the file to be decompressed, and judges the category of the current object to be decompressed, and the object to be decompressed is a file or a folder;
当所述待解压对象为文件夹时,创建文件夹,并对所述待解压对象进行解压操作,得出解压后的文件夹数据;When the object to be decompressed is a folder, create a folder, and perform a decompression operation on the object to be decompressed to obtain decompressed folder data;
当所述待解压对象为文件时,对所述待解压对象进行解压操作,得出解压后的文件数据。When the object to be decompressed is a file, a decompression operation is performed on the object to be decompressed to obtain decompressed file data.
可选地,在所述网盘服务端根据所述文件信息,调用解压应用程序编程接口对所述待解压文件进行解压操作,得到解压文件之后还包括:Optionally, according to the file information, the network disk server calls the decompression application programming interface to decompress the file to be decompressed, and after obtaining the decompressed file, it also includes:
所述网盘服务端将所述文件数据和所述文件夹数据存储至指定存储队列。The network disk server stores the file data and the folder data in a specified storage queue.
可选地,在所述网盘服务端将所述文件数据和所述文件夹数据存储至指定存储队列之后还包括:Optionally, after the network disk server stores the file data and the folder data in a specified storage queue, it also includes:
所述网盘服务端对所述指定存储队列进行循环遍历,找出所述文件数据所在文件夹的预设的第一文件夹ID信息,找出所述文件夹数据对应的预设的第二文件夹ID信息,并将所述第一文件夹ID信息和所述第二文件ID信息存储至数据库;The network disk server loops through the specified storage queue, finds out the preset first folder ID information of the folder where the file data is located, and finds out the preset second folder ID information corresponding to the folder data. folder ID information, and store the first folder ID information and the second file ID information in a database;
根据第一预设存储格式,将所述文件数据存储至数据库,以得出所述解压文件的目录结构关系。According to the first preset storage format, the file data is stored in the database, so as to obtain the directory structure relationship of the decompressed files.
可选地,在所述根据第二预设存储格式,将所述文件夹数据存储至所述数据库,以得出所述解压文件的目录结构关系之后还包括:Optionally, after storing the folder data in the database according to the second preset storage format to obtain the directory structure relationship of the decompressed files, the method further includes:
所述网盘服务端获取用户的文件列表查看指令;The network disk server obtains the user's file list viewing instruction;
根据所述文件列表查看指令,从所述数据库中读取所述目录结构关系,以使所述用户查看到相应的文件列表。According to the file list viewing instruction, the directory structure relationship is read from the database, so that the user can view the corresponding file list.
可选地,所述解压应用程序编程接口为Java zip API。Optionally, the decompression application programming interface is Java zip API.
此外,本发明还提供了一种压缩文件解压的装置,该装置包括:In addition, the present invention also provides a device for decompressing compressed files, which device includes:
网盘服务端获取模块,用于获取待解压文件的文件信息;The network disk server obtains the module, which is used to obtain the file information of the file to be decompressed;
网盘服务端解压模块,用于根据所述文件信息,调用解压应用程序编程接口对所述待解压文件进行解压操作,得到解压文件。The network disk server decompression module is used to call the decompression application programming interface to decompress the file to be decompressed according to the file information to obtain the decompressed file.
可选地,所述网盘服务端解压模块包括:Optionally, the network disk server decompression module includes:
遍历判断单元,用于对所述待解压文件内所包含的待解压对象进行循环遍历,判断当前待解压对象的类别,所述待解压对象为文件或文件夹;The traversal judging unit is used to loop through the objects to be decompressed contained in the file to be decompressed, and judge the category of the current object to be decompressed, and the object to be decompressed is a file or a folder;
创建解压单元,用于当所述待解压对象为文件夹时根,创建文件夹,并对所述待解压对象进行解压操作,得出解压后的文件夹数据;Create a decompression unit for creating a folder when the object to be decompressed is a folder, and perform a decompression operation on the object to be decompressed to obtain decompressed folder data;
解压单元,用于当所述待解压对象为文件时,对所述待解压对象进行解压操作,得出解压后的文件数据。The decompression unit is configured to perform a decompression operation on the object to be decompressed to obtain decompressed file data when the object to be decompressed is a file.
可选地,还包括:Optionally, also include:
网盘服务端存储模块,用于将所述文件数据和所述文件夹数据存储至指定存储队列。The network disk server storage module is configured to store the file data and the folder data in a designated storage queue.
可选地,还包括:Optionally, also include:
网盘服务端寻找存储模块,用于对所述指定存储队列进行循环遍历,找出所述文件数据所在文件夹的预设的第一文件夹ID信息,找出所述文件夹数据对应的预设的第二文件夹ID信息,并将所述第一文件夹ID信息和所述第二文件ID信息存储至数据库;The network disk server searches for a storage module, which is used to loop through the specified storage queue, find out the preset first folder ID information of the folder where the file data is located, and find out the preset folder data corresponding to the folder. Set the second folder ID information, and store the first folder ID information and the second file ID information into the database;
网盘服务端第一存储模块,用于根据第一预设存储格式,将所述文件数据存储至数据库,以得出所述解压文件的目录结构关系。The first storage module of the network disk server is configured to store the file data in the database according to the first preset storage format, so as to obtain the directory structure relationship of the decompressed files.
本发明所提供的一种压缩文件解压的方法以及装置,网盘服务端获取待解压文件的文件信息;上述网盘服务端根据上述文件信息,调用解压应用程序编程接口对上述待解压文件进行解压操作,得到解压文件。通过获得待解压文件的文件信息,上述待解压文件存储于上述网盘服务端上,上述网盘服务端可以通过调用解压应用程序编程接口来对待解压文件进行解压操作,以实现在网盘服务端上解压压缩文件。In the method and device for decompressing compressed files provided by the present invention, the network disk server obtains the file information of the file to be decompressed; the above-mentioned network disk server calls the decompression application programming interface to decompress the above-mentioned file to be decompressed according to the above file information Operation to get the decompressed file. By obtaining the file information of the file to be decompressed, the above-mentioned file to be decompressed is stored on the above-mentioned network disk server, and the above-mentioned network disk server can decompress the file to be decompressed by calling the decompression application programming interface, so as to realize the decompression operation on the network disk server. Unzip the compressed file on .
附图说明Description of drawings
为了更清楚的说明本发明实施例或现有技术的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单的介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the following will briefly introduce the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only For some embodiments of the present invention, those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1为本发明实施例所提供的压缩文件解压方法的一种具体实施方式的流程示意图;Fig. 1 is a schematic flow chart of a specific implementation of the compressed file decompression method provided by the embodiment of the present invention;
图2为本发明实施例所提供的Zip文件解压代码片段;Fig. 2 is the Zip file decompression code segment that the embodiment of the present invention provides;
图3为本发明实施例所提供的文件表数据字典;Fig. 3 is the file table data dictionary provided by the embodiment of the present invention;
图4为本发明实施例所提供的文件夹表数据字典;Fig. 4 is the folder table data dictionary provided by the embodiment of the present invention;
图5为本发明实施例所提供的目录结构生成流程图的一种具体实施方式的流程示意图;FIG. 5 is a schematic flowchart of a specific implementation of the directory structure generation flowchart provided by the embodiment of the present invention;
图6为本发明实施例所提供的目录结构生成代码片段;Fig. 6 generates code fragments for the directory structure provided by the embodiment of the present invention;
图7为本发明实施例所提供的压缩文件解压装置的结构框图。Fig. 7 is a structural block diagram of an apparatus for decompressing compressed files provided by an embodiment of the present invention.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本发明方案,下面结合附图和具体实施方式对本发明作进一步的详细说明。显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to enable those skilled in the art to better understand the solution of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. Apparently, the described embodiments are only some of the embodiments of the present invention, but not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
请参见图1,图1为本发明实施例所提供的压缩文件解压方法的一种具体实施方式的流程示意图,该解压方法包括以下步骤:Please refer to Fig. 1, Fig. 1 is a schematic flow chart of a specific implementation of the compressed file decompression method provided by the embodiment of the present invention, the decompression method includes the following steps:
步骤101:网盘服务端获取待解压文件的文件信息;Step 101: the network disk server obtains the file information of the file to be decompressed;
需要说明的是,上述待解压文件存储于上述网盘服务端上。上述文件信息可以包括表征上述待解压文件内所包含的各个文件的信息,以及上述待解压文件的整体信息,例如,文件信息可以包括待解压文件的名称信息、存储路径信息以及待解压文件内所包含的各个文件的名称信息等等。It should be noted that the above-mentioned file to be decompressed is stored on the above-mentioned network disk server. The above-mentioned file information may include information that characterizes each file included in the above-mentioned file to be decompressed, and the overall information of the above-mentioned file to be decompressed. For example, the file information may include name information, storage path information, and The name information of each file included and so on.
上述待解压文件即压缩文件的格式可以是任意地,例如为Zip格式。The format of the above-mentioned file to be decompressed, that is, the compressed file can be arbitrary, for example, it is in Zip format.
可以理解的是,在进行解压操作之前,网盘服务端可以提前获取存储于网盘服务端上,需要解压的压缩文件的具体信息,以便后续解压过程可以进行相应的操作。It can be understood that, before performing the decompression operation, the network disk server can obtain in advance the specific information of the compressed file stored on the network disk server and needs to be decompressed, so that the subsequent decompression process can perform corresponding operations.
步骤102:所述网盘服务端根据所述文件信息,调用解压应用程序编程接口对所述待解压文件进行解压操作,得到解压文件。Step 102: According to the file information, the network disk server invokes a decompression application programming interface to decompress the file to be decompressed to obtain the decompressed file.
可以理解的是,上述解压应用程序编程接口可以具体为Java zip API,此时上述待解压文件为Zip压缩文件,上述网盘服务端可以利用Java的Zip压缩文件操作相应API,利用对应的解压缩技术,以实现文件的解压工作;上述解压应用程序编程接口也可以具体为其它类型的API,此时相应的解压过程也会有所不同,在此不再赘述。It can be understood that the above-mentioned decompression application programming interface can be specifically Java zip API, and at this time the above-mentioned file to be decompressed is a Zip compressed file, and the above-mentioned network disk server can use the Java Zip compressed file to operate the corresponding API, and use the corresponding decompression technology to realize the decompression work of the file; the above decompression application programming interface can also be specifically other types of API, and the corresponding decompression process will be different at this time, and will not be repeated here.
文件解压过程可以是对待解压文件内的每一个文件进行解压缩操作,并将解压出来的文件存储至指定保存路径。The file decompression process may be to decompress each file in the file to be decompressed, and store the decompressed files to a specified storage path.
由于待解压文件内所包含的待解压对象可能是文件,也可能是文件夹,不同的待解压对象,解压操作也会不同,故可以对待解压文件内的所有实体解压时,先判断待解压对象的类别,再进行相应解压操作。Since the object to be decompressed in the file to be decompressed may be a file or a folder, the decompression operation will be different for different objects to be decompressed, so when decompressing all the entities in the decompressed file, first judge the object to be decompressed category, and then perform the corresponding decompression operation.
在本发明的一些实施例中,文件解压过程可以具体为:所述网盘服务端对所述待解压文件内所包含的待解压对象进行循环遍历,判断当前待解压对象的类别,所述待解压对象为文件或文件夹;当所述待解压对象为文件夹时,创建文件夹,并对所述待解压对象进行解压操作,得出解压后的文件夹数据;当所述待解压对象为文件时,对所述待解压对象进行解压操作,得出解压后的文件数据。In some embodiments of the present invention, the file decompression process may be specifically: the network disk server loops through the objects to be decompressed contained in the file to be decompressed, and judges the type of the object to be decompressed currently, and the object to be decompressed is determined. The object to be decompressed is a file or a folder; when the object to be decompressed is a folder, a folder is created, and the object to be decompressed is decompressed to obtain decompressed folder data; when the object to be decompressed is When extracting a file, perform a decompression operation on the object to be decompressed to obtain decompressed file data.
具体地,,当判断出当前遍历的待解压对象为文件时,则可以直接对该待解压对象进行解压操作,并且可以将解压之后的文件数据写入磁盘;而当判断出当前遍历的待解压对象为文件夹时,则可以先创建一个文件夹,而文件夹的创建可以根据解压前所获取的文件信息,例如,文件信息表明待解压对象文件夹的名称为A,创建的文件夹的名称也应为A,文件创建后再进行相应的解压操作。Specifically, when it is determined that the currently traversed object to be decompressed is a file, the object to be decompressed can be directly decompressed, and the decompressed file data can be written to the disk; and when it is judged that the currently traversed object to be decompressed When the object is a folder, you can create a folder first, and the creation of the folder can be based on the file information obtained before decompression. For example, the file information indicates that the name of the object folder to be decompressed is A, and the name of the created folder is It should also be A, and the corresponding decompression operation will be performed after the file is created.
当上述待解压文件为Zip压缩文件,解压应用程序编程接口具体为Java zip API时,其解压过程可以利用ZipFile类和ZipEntry类,来实现Zip压缩文件的解压操作,而循环遍历待解压文件可以具体由while循环实现。其利用Java语言来解压Zip文件的实现代码具体可以参见图2,图2为本发明实施例所提供的Zip文件解压代码片段。When the above-mentioned file to be decompressed is a Zip compressed file, and the decompression application programming interface is specifically the Java zip API, the decompression process can utilize the ZipFile class and the ZipEntry class to realize the decompression operation of the Zip compressed file, and the cyclic traversal of the files to be decompressed can be specifically Implemented by while loop. The implementation code for decompressing the Zip file using the Java language can be specifically referred to in FIG. 2 . FIG. 2 is a code fragment for decompressing the Zip file provided by the embodiment of the present invention.
将待解压文件进行解压缩之后,得到解压后的文件数据,最终可以等到一个与待解压文件相应的解压后的文件夹,该文件夹独立与待解压文件,例如,待解压文件为A.Zip,解压后得到的文件夹名称可以为A,此时A文件夹和A.Zip压缩文件相互独立,即解压后多出了一个A文件夹。After the file to be decompressed is decompressed, the decompressed file data is obtained, and finally a decompressed folder corresponding to the file to be decompressed can be obtained, which is independent of the file to be decompressed, for example, the file to be decompressed is A.Zip , the name of the folder obtained after decompression can be A. At this time, the A folder and the A.Zip compressed file are independent of each other, that is, there is an extra A folder after decompression.
待所有的待解压对象解压完成后,可以将所有的解压后的实体文件存储至指定存储队列,故在本发明的一些实施例中,在所述网盘服务端根据所述文件信息,调用解压应用程序编程接口对所述待解压文件进行解压操作,得到解压文件之后还包括:所述网盘服务端将所述文件数据和所述文件夹数据存储至指定存储队列。After the decompression of all the objects to be decompressed is completed, all the decompressed entity files can be stored in the designated storage queue, so in some embodiments of the present invention, the network disk server calls the decompressed file according to the file information. The application programming interface performs a decompression operation on the file to be decompressed, and after obtaining the decompressed file, it further includes: the network disk server storing the file data and the folder data in a designated storage queue.
需要说明的是,上述指定存储队列可以具体为Java List集合。It should be noted that, the above specified storage queue may specifically be a Java List collection.
将解压后的文件数据和文件夹数据存储至队列中,可以便于后续目录结构关系的生成。Storing the decompressed file data and folder data in the queue can facilitate the generation of subsequent directory structure relationships.
在将解压出的文件实体存储至队列后,可以对队列中的文件实体进行遍历,以得出各个实体之间的关系,即目录层级关系。After the decompressed file entities are stored in the queue, the file entities in the queue can be traversed to obtain the relationship between each entity, that is, the directory hierarchy relationship.
故在本发明的一些实施例中,在所述网盘服务端将所述文件数据和所述文件夹数据存储至指定存储队列之后还包括:所述网盘服务端对所述指定存储队列进行循环遍历,找出所述文件数据所在文件夹的预设的第一文件夹ID信息,找出所述文件夹数据对应的预设的第二文件夹ID信息,并将所述第一文件夹ID信息和所述第二文件ID信息存储至数据库;根据第一预设存储格式,将所述文件数据存储至数据库,以得出所述解压文件的目录结构关系。Therefore, in some embodiments of the present invention, after the network disk server stores the file data and the folder data in the specified storage queue, it further includes: the network disk server performs the specified storage queue Loop through, find out the preset first folder ID information of the folder where the file data is located, find out the preset second folder ID information corresponding to the folder data, and store the first folder storing the ID information and the second file ID information in a database; storing the file data in the database according to a first preset storage format, so as to obtain the directory structure relationship of the decompressed files.
需要说明的是,上述指定存储队列可以为一个已定义有先进先出策略的队列,该队列中可以存储解压出来的文件夹对象,以及待解压文件所在的文件夹对象。It should be noted that the above designated storage queue may be a queue defined with a first-in-first-out policy, and the decompressed folder object and the folder object where the file to be decompressed are located can be stored in the queue.
上述循环遍历可以利用while循环具体实现,其过程可以具体为:将待解压文件所在的文件夹对象存储至队列中,循环遍历队列中的对象,可以首先遍历队首元素文件夹,即遍历该文件夹下的所有子文件。继而在子文件中寻找出解压出来的文件,进而判断当前子文件是否为文件夹,若是,则将该文件夹对象存储至队列,并将文件夹信息存储至数据库,以及该文件夹对应的ID信息存储至数据库,上述文件夹信息可以包括文件夹名称、保存路径以及所属文件夹等信息;若否,则表明当前子文件为文件,则可以将该文件存储至数据库,并将与该文件对应的ID信息一并存入数据库。利用遍历循环,找出各个文件实体之间的层级关系,进而得出解压后的文件的目录结构关系。The above-mentioned loop traversal can be implemented using a while loop. The process can be specifically: store the folder object where the file to be decompressed is located in the queue, and loop through the objects in the queue. You can first traverse the first element folder of the queue, that is, traverse the file All subfolders under the folder. Then find the decompressed file in the sub-file, and then judge whether the current sub-file is a folder, if so, store the folder object in the queue, and store the folder information in the database, and the ID corresponding to the folder The information is stored in the database, and the above-mentioned folder information can include information such as the folder name, the saving path, and the folder to which it belongs; if not, it indicates that the current sub-file is a file, and the file can be stored in the database, and will be corresponding to the file. The ID information is stored in the database together. Using the traversal loop to find out the hierarchical relationship between each file entity, and then obtain the directory structure relationship of the decompressed file.
需要说明的是,上述第一文件夹ID信息可以是指所解压出来的文件对象所在的文件夹信息。上述第二文件夹ID信息可以是指所解压出来的文件夹对象的文件夹信息。It should be noted that the above first folder ID information may refer to folder information where the decompressed file object is located. The above-mentioned second folder ID information may refer to the folder information of the decompressed folder object.
可以理解的是,可以预先建立文件夹对象和对应ID的对应关系,其具体可以通过定义一个Map对象,该Map对象的键-值对可以为文件夹对象-对应的ID。进一步地,可以将ID存储至Map对象中,而也可以从Map对象中读取到所需ID。It can be understood that the corresponding relationship between the folder object and the corresponding ID can be established in advance. Specifically, a Map object can be defined, and the key-value pair of the Map object can be the folder object-corresponding ID. Further, the ID can be stored in the Map object, and the required ID can also be read from the Map object.
上述第一预设存储格式可以是指将文件数据存储至数据库时的格式,即预先设定文件数据的存储格式,例如,可以将文件数据存储至文件表,存储时将文件名称、文件描述、文件大小以及文件所对应的文件夹ID等信息存储至文件表里。The above-mentioned first preset storage format may refer to the format when the file data is stored in the database, that is, the storage format of the file data is preset, for example, the file data may be stored in the file table, and the file name, file description, Information such as the file size and the folder ID corresponding to the file is stored in the file table.
对于解压出来的文件夹数据,可以将文件夹存储至文件夹表。可以将文件夹名称、文件夹大小以及文件夹描述等信息一同存储至文件夹表。For the extracted folder data, the folder can be stored in the folder table. Information such as folder name, folder size, and folder description can be stored in the folder table.
为了更好地存储所解压出来的数据,可以预先对文件表以及文件夹表进行预先设计,则需要预先定义相应的文件表数据字典和文件夹表数据字典,即预先定义各个字段,例如id、nam、size…等字段。具体定义可以参见图3和图4,图3为本发明实施例所提供的文件表数据字典,图4为本发明实施例所提供的文件夹表数据字典。In order to better store the decompressed data, the file table and folder table can be pre-designed, and the corresponding file table data dictionary and folder table data dictionary need to be defined in advance, that is, each field is pre-defined, such as id, nam, size... and other fields. For specific definitions, please refer to FIG. 3 and FIG. 4 . FIG. 3 is the file table data dictionary provided by the embodiment of the present invention, and FIG. 4 is the folder table data dictionary provided by the embodiment of the present invention.
为了更好地介绍目录结构关系的生成过程,下面将结合图5和图6,对压缩文件为Zip文件,编程实现语言为Java的目录结构关系生成过程进行相应介绍,图5为本发明实施例所提供的目录结构生成流程图的一种具体实施方式的流程示意图,图6为本发明实施例所提供的目录结构生成代码片段。In order to better introduce the generation process of the directory structure relationship, below in conjunction with Fig. 5 and Fig. 6, the compressed file is a Zip file, and the programming implementation language is a corresponding introduction to the generation process of the directory structure relationship of Java, and Fig. 5 is an embodiment of the present invention A schematic flowchart of a specific implementation of the provided directory structure generation flowchart, and FIG. 6 is a code fragment for directory structure generation provided by an embodiment of the present invention.
如图5所示,首先需要获取到待解压Zip文件zipFile以及其父文件夹rootFolder;继而进行Zip文件的解压操作,并将解压出来的所有文件对象存储至集合filelist中;然后预先定义Map<File,String>idMap,即将键-值对定义为为文件夹对象-对应ID,定义一个存储文件夹对象的队列Queue<File>queue,该队列遵循先进先出策略;queue.enqueue(rootFolder),rootFolder入队,idMap.put(rootFolder,rootId),rootFolder及其对应的ID,即将队首的文件夹存储至队列中,获取到相应文件夹对应的ID;进而判断queue.isEmpty()?,即判断当前队列是否为空,若为空时,则表示当前层级关系已读完,则结束进程,若不为空,则进入下一步;As shown in Figure 5, first you need to obtain the Zip file zipFile to be decompressed and its parent folder rootFolder; then perform the decompression operation of the Zip file, and store all the decompressed file objects in the collection filelist; then pre-define Map<File ,String>idMap, which defines the key-value pair as folder object-corresponding ID, defines a queue Queue<File>queue for storing folder objects, and the queue follows the first-in-first-out strategy; queue.enqueue(rootFolder), rootFolder Join the team, idMap.put(rootFolder, rootId), rootFolder and its corresponding ID, that is, store the folder at the head of the team in the queue, and obtain the ID corresponding to the corresponding folder; then judge queue.isEmpty()? , that is to judge whether the current queue is empty, if it is empty, it means that the current hierarchical relationship has been read, and the process will end, if it is not empty, it will enter the next step;
接着进行数据读取,将读取到的ID存储至数据库,即File fr=queue.dequeue(),String id=idMap.get(fr);然后进行遍历循环,即For循环遍历fr所有子文件frsub,判断frsub是否为刚解压出来的文件;判断遍历是否结束,若遍历结束,则重新返回队列是否为空,若遍历不结束,则判断当前文件是否为刚解压出来的文件,即判断当前解压出来的文件是否已经存在,即fileList.contains(frsub)?;若不存在,则判断当前文件是文件还是文件夹,即frsub.isDirectory()?;当为文件时,则将文件信息存储至文件表,即saveFile(user,frsub,id);当为文件夹时,将文件夹信息存储至文件夹表,即queue.enqueue(frsub),Serializable,key=saveDir(user,frsub,id),idMap.put(frsub,key.toString())。Then read the data, and store the read ID into the database, that is, File fr=queue.dequeue(), String id=idMap.get(fr); , to judge whether frsub is the file just decompressed; judge whether the traversal is over, if the traversal is over, then return whether the queue is empty, if the traversal is not over, then judge whether the current file is the file just decompressed, that is, judge the current decompressed file Does the file already exist, ie fileList.contains(frsub)? ; If it does not exist, judge whether the current file is a file or a folder, that is, frsub.isDirectory()? ;When it is a file, store the file information in the file table, that is, saveFile(user,frsub,id); when it is a folder, store the folder information in the folder table, that is, queue.enqueue(frsub), Serializable ,key=saveDir(user,frsub,id),idMap.put(frsub,key.toString()).
可以理解的是,上文只是对目录结构生成的流程进行大概说明,具体实现可以参见附图以及相应的代码段,在此不再赘述。It can be understood that the above is only a general description of the process of generating the directory structure. For specific implementation, please refer to the accompanying drawings and corresponding code segments, and details will not be repeated here.
在将解压出来的文件信息以及文件夹信息存储至数据库后,可以得出各个文件以及文件夹之间的层级关系,即解压文件的目录层级关系,也即可以从数据库中读取到所需的目录结构关系。After the decompressed file information and folder information are stored in the database, the hierarchical relationship between each file and folder can be obtained, that is, the directory hierarchical relationship of the decompressed file, that is, the required information can be read from the database. Directory structure relationship.
故在本发明的一些实施例中,在所述根据第一预设存储格式,将所述文件数据存储至数据库,以得出所述解压文件的目录结构关系之后还包括:所述网盘服务端获取用户的文件列表查看指令;根据所述文件列表查看指令,从所述数据库中读取所述目录结构关系,以使所述用户查看到相应的文件列表。Therefore, in some embodiments of the present invention, after storing the file data in the database according to the first preset storage format to obtain the directory structure relationship of the decompressed file, it further includes: the network disk service The terminal obtains the user's file list viewing instruction; according to the file list viewing instruction, the directory structure relationship is read from the database, so that the user can view the corresponding file list.
可以理解的是,在接收到用户的文件列表查看指令后,即用户想要查看解压后文件的文件列表时,可以从数据库中读取到相应的目录结构关系,然后可以将对应的目录结构关系展示给用户。It can be understood that after receiving the user's file list viewing instruction, that is, when the user wants to view the file list of the decompressed file, the corresponding directory structure relationship can be read from the database, and then the corresponding directory structure relationship can be displayed to the user.
本发明实施例所提供的压缩文件解压的方法,网盘服务端获取待解压文件的文件信息;上述网盘服务端根据上述文件信息,调用解压应用程序编程接口对上述待解压文件进行解压操作,得到解压文件。通过获得待解压文件的文件信息,上述待解压文件存储于上述网盘服务端上,上述网盘服务端可以通过调用解压应用程序编程接口来对待解压文件进行解压操作,以实现在网盘服务端上解压压缩文件。可见,该方法实现了在网盘服务端解压压缩文件的过程。In the method for decompressing a compressed file provided in the embodiment of the present invention, the network disk server obtains the file information of the file to be decompressed; the above-mentioned network disk server calls the decompression application programming interface to perform the decompression operation on the above-mentioned file to be decompressed according to the above-mentioned file information, to get the unzipped file. By obtaining the file information of the file to be decompressed, the above-mentioned file to be decompressed is stored on the above-mentioned network disk server, and the above-mentioned network disk server can decompress the file to be decompressed by calling the decompression application programming interface, so as to realize the decompression operation on the network disk server. Unzip the compressed file on . It can be seen that this method realizes the process of decompressing compressed files on the network disk server.
下面对本发明实施例提供的压缩文件解压装置进行介绍,下文描述的压缩文件解压装置与上文描述的压缩文件解压方法可相互对应参照。The compressed file decompression device provided by the embodiment of the present invention is introduced below. The compressed file decompression device described below and the compressed file decompression method described above can be referred to in correspondence.
图7为本发明实施例所提供的压缩文件解压装置的结构框图,参照图7压缩文件解压装置可以包括:Fig. 7 is the structural block diagram of the compressed file decompression device provided by the embodiment of the present invention, with reference to Fig. 7 compressed file decompression device can comprise:
网盘服务端获取模块701,用于获取待解压文件的文件信息;The network disk service end acquisition module 701 is used to obtain the file information of the file to be decompressed;
网盘服务端解压模块702,用于根据所述文件信息,调用解压应用程序编程接口对所述待解压文件进行解压操作,得到解压文件。The network disk server decompression module 702 is configured to call the decompression application programming interface to decompress the file to be decompressed according to the file information to obtain the decompressed file.
可选地,所述网盘服务端解压模块包括:Optionally, the network disk server decompression module includes:
遍历判断单元,用于对所述待解压文件内所包含的待解压对象进行循环遍历,判断当前待解压对象的类别,所述待解压对象为文件或文件夹;The traversal judging unit is used to loop through the objects to be decompressed contained in the file to be decompressed, and judge the category of the current object to be decompressed, and the object to be decompressed is a file or a folder;
创建解压单元,用于当所述待解压对象为文件夹时根,创建文件夹,并对所述待解压对象进行解压操作,得出解压后的文件夹数据;Create a decompression unit for creating a folder when the object to be decompressed is a folder, and perform a decompression operation on the object to be decompressed to obtain decompressed folder data;
解压单元,用于当所述待解压对象为文件时,对所述待解压对象进行解压操作,得出解压后的文件数据。The decompression unit is configured to perform a decompression operation on the object to be decompressed to obtain decompressed file data when the object to be decompressed is a file.
可选地,还包括:Optionally, also include:
网盘服务端存储模块,用于将所述文件数据和所述文件夹数据存储至指定存储队列。The network disk server storage module is configured to store the file data and the folder data in a designated storage queue.
可选地,还包括:Optionally, also include:
网盘服务端寻找存储模块,用于对所述指定存储队列进行循环遍历,找出所述文件数据所在文件夹的预设的第一文件夹ID信息,找出所述文件夹数据对应的预设的第二文件夹ID信息,并将所述第一文件夹ID信息和所述第二文件ID信息存储至数据库;The network disk server searches for a storage module, which is used to loop through the specified storage queue, find out the preset first folder ID information of the folder where the file data is located, and find out the preset folder data corresponding to the folder. Set the second folder ID information, and store the first folder ID information and the second file ID information into the database;
网盘服务端第一存储模块,用于根据第一预设存储格式,将所述文件数据存储至数据库,以得出所述解压文件的目录结构关系。The first storage module of the network disk server is configured to store the file data in the database according to the first preset storage format, so as to obtain the directory structure relationship of the decompressed files.
本发明实施例所提供的压缩文件解压的装置,通过获得待解压文件的文件信息,上述待解压文件存储于上述网盘服务端上,上述网盘服务端可以通过调用解压应用程序编程接口来对待解压文件进行解压操作,以实现在网盘服务端上解压压缩文件。可见,该装置实现了在网盘服务端解压压缩文件的过程。The compressed file decompression device provided by the embodiment of the present invention obtains the file information of the file to be decompressed, and the above-mentioned file to be decompressed is stored on the above-mentioned network disk server, and the above-mentioned network disk server can be treated by calling the decompression application programming interface Decompress the file and perform the decompression operation to realize the decompression of the compressed file on the network disk server. It can be seen that the device realizes the process of decompressing compressed files on the network disk server.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same or similar parts of each embodiment can be referred to each other. As for the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and for the related information, please refer to the description of the method part.
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Professionals can further realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software or a combination of the two. In order to clearly illustrate the possible For interchangeability, in the above description, the composition and steps of each example have been generally described according to their functions. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present invention.
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be directly implemented by hardware, software modules executed by a processor, or a combination of both. Software modules can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other Any other known storage medium.
以上对本发明所提供的压缩文件解压的方法以及装置进行了详细介绍。本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以对本发明进行若干改进和修饰,这些改进和修饰也落入本发明权利要求的保护范围内。The method and device for decompressing compressed files provided by the present invention have been introduced in detail above. In this paper, specific examples are used to illustrate the principle and implementation of the present invention, and the descriptions of the above embodiments are only used to help understand the method and core idea of the present invention. It should be pointed out that for those skilled in the art, without departing from the principles of the present invention, some improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710099690.4A CN106844766A (en) | 2017-02-23 | 2017-02-23 | The method and device of a kind of compressed file decompression |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710099690.4A CN106844766A (en) | 2017-02-23 | 2017-02-23 | The method and device of a kind of compressed file decompression |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN106844766A true CN106844766A (en) | 2017-06-13 |
Family
ID=59134492
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201710099690.4A Pending CN106844766A (en) | 2017-02-23 | 2017-02-23 | The method and device of a kind of compressed file decompression |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN106844766A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107918654A (en) * | 2017-11-16 | 2018-04-17 | 联想(北京)有限公司 | File decompression method, apparatus and electronic equipment |
| CN109032506A (en) * | 2018-06-27 | 2018-12-18 | 郑州云海信息技术有限公司 | A kind of memory system data compression method, system and equipment and storage medium |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102054038A (en) * | 2010-12-30 | 2011-05-11 | 东莞宇龙通信科技有限公司 | File decompression method and device and mobile terminal |
| CN102868765A (en) * | 2012-10-09 | 2013-01-09 | 乐视网信息技术(北京)股份有限公司 | Method and system for uploading files |
| CN103491169A (en) * | 2013-09-24 | 2014-01-01 | 长沙裕邦软件开发有限公司 | Method and system for uploading and downloading files |
| TW201445322A (en) * | 2013-05-28 | 2014-12-01 | Univ Nat Taipei Technology | A cloud computing-based architecture for the storage, browse and processing of images |
| CN104484174A (en) * | 2014-12-12 | 2015-04-01 | 北京国双科技有限公司 | Processing method and processing device for compressed file with RAR (Roshal A Rchive) format |
| CN105631342A (en) * | 2015-12-22 | 2016-06-01 | 北京无线电计量测试研究所 | Penetration test method in allusion to mobile geographic information security of underground pipelines |
| JP6011349B2 (en) * | 2013-01-11 | 2016-10-19 | 富士通株式会社 | Storage apparatus and data compression method |
-
2017
- 2017-02-23 CN CN201710099690.4A patent/CN106844766A/en active Pending
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102054038A (en) * | 2010-12-30 | 2011-05-11 | 东莞宇龙通信科技有限公司 | File decompression method and device and mobile terminal |
| CN102868765A (en) * | 2012-10-09 | 2013-01-09 | 乐视网信息技术(北京)股份有限公司 | Method and system for uploading files |
| JP6011349B2 (en) * | 2013-01-11 | 2016-10-19 | 富士通株式会社 | Storage apparatus and data compression method |
| TW201445322A (en) * | 2013-05-28 | 2014-12-01 | Univ Nat Taipei Technology | A cloud computing-based architecture for the storage, browse and processing of images |
| CN103491169A (en) * | 2013-09-24 | 2014-01-01 | 长沙裕邦软件开发有限公司 | Method and system for uploading and downloading files |
| CN104484174A (en) * | 2014-12-12 | 2015-04-01 | 北京国双科技有限公司 | Processing method and processing device for compressed file with RAR (Roshal A Rchive) format |
| CN105631342A (en) * | 2015-12-22 | 2016-06-01 | 北京无线电计量测试研究所 | Penetration test method in allusion to mobile geographic information security of underground pipelines |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107918654A (en) * | 2017-11-16 | 2018-04-17 | 联想(北京)有限公司 | File decompression method, apparatus and electronic equipment |
| CN107918654B (en) * | 2017-11-16 | 2020-07-24 | 联想(北京)有限公司 | File decompression method and device and electronic equipment |
| CN109032506A (en) * | 2018-06-27 | 2018-12-18 | 郑州云海信息技术有限公司 | A kind of memory system data compression method, system and equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106878428A (en) | Method and device for file upload | |
| KR102450303B1 (en) | Apparatus and method for maintaining a message thread with opt-in permanence for entries | |
| WO2017059798A1 (en) | Methods, apparatus, and system for serialization and deserialization, and electronic devices | |
| WO2015043512A1 (en) | Picture management method and device | |
| CN103902589B (en) | Management method and device for downloaded files | |
| CN104753540A (en) | Data compression method, data decompression method and device | |
| US10650085B2 (en) | Providing interactive preview of content within communication | |
| CN111950247A (en) | A Configuration-Based Method for Generating Word Documents | |
| CN103699597A (en) | Method for downloading file through browser and browser | |
| CN104331343B (en) | File backup method and system | |
| WO2022082891A1 (en) | Big data acquisition method and system, and computer device and storage medium thereof | |
| CN107357808B (en) | Data management method, device and equipment | |
| CN114157917B (en) | Video editing method, device and terminal equipment | |
| CN106844766A (en) | The method and device of a kind of compressed file decompression | |
| US8984028B2 (en) | Systems and methods for storing data and eliminating redundancy | |
| CN107122381B (en) | File generation method and device and data analysis method and device | |
| CN107885829A (en) | Object storage docking Hadoop renaming method, apparatus, equipment and storage medium | |
| CN109842644B (en) | Parameter expansion method and system, cloud computing management platform assembly and user terminal | |
| CN105279247A (en) | Expression library generation method and device | |
| CN106933826B (en) | Data preprocessing method and device | |
| JP2017517162A (en) | Asset collection service by content capture | |
| CN103885970B (en) | Image display method and device | |
| US11182551B2 (en) | System and method for determining document version geneology | |
| CN107070987A (en) | Data capture method and system for distributed objects storage system | |
| CN107193848A (en) | Cartography incremental updating method and device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170613 |