Skip to Main Content
In some situation, it's necessary to store a whole folder into a database and provide random access to any file in it. This paper puts forward a new method to store a folder as a whole and access its file randomly in a database based on the integration of BLOB, Stream and Serialization technology. First, the folder is packed up, resulting in a file stream and a directory structure object. Then, the directory structure object is serialized to a directory structure stream. Finally, the file stream and directory structure stream are saved as BLOB data in a database respectively. When reading from the database, we first read the directory structure BLOB data as a stream, and deserialize it to the directory structure object. Then, with the information in the directory structure object, we can choose which file to access and ascertain its location and size in the folder's file BLOB data. Finally, we read the corresponding data section out of the database and realize the random access of a file.