C# Class SQLServerFileSystemTools, SQL-Server-File-System-Tools

Tools for working with files and SQL Server. Includes storage compression and encryption. This is a set of stored procedures that allow you to store files in a database with the option to compress into a zip compatiable stream or encrypt with Rijndael or both. It can output to the file system compressed or decompressed. it can output to a sql record type decompressed
显示文件 Open project: SQLServerIO/SQL-Server-File-System-Tools

Public Methods

Method Description
ExtractFileToDisk ( long fileId, string location ) : void

Retrieves file from database uncompresses and decrypts it if it needs to.

ExtractFileToDiskCompressed ( long fileId, string location ) : void

Retrieves file from database raw compressed form with .zip extention

ExtractFileToDiskEncrypted ( long fileId, string location ) : void

Retrieves file from database raw encrypted form .enc extention

ExtractFileToDiskEncryptedCompressed ( long fileId, string location ) : void

Retrieves file from database raw encrypted and compressed form with .zip.enc extention

ExtractFileToRecord ( long fileId ) : void

Retrieves file from database output to recordset decrypts and decompresses file if needed.

ExtractFileToRecordCompressed ( long fileId ) : void

Retrieves file from database as sql recordset in raw compressed form

ExtractFileToRecordEncrypted ( long fileId ) : void

Retrieves file from database as sql recordset in raw encrypted form

ExtractFileToRecordEncryptedCompressed ( long fileId ) : void

Retrieves file from database as sql recordset in raw encrypted and compressed form

StoreAllFilesInPath ( string filesLocaton, string fileSuffix ) : void

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database unencrypted and uncompressed.

StoreAllFilesInPathCompressed ( string filesLocaton, string fileSuffix, int compressionLevel ) : void

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database unencrypted and compressed.

StoreAllFilesInPathEncrypted ( string filesLocaton, string fileSuffix ) : void

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database encrypted and uncompressed.

StoreAllFilesInPathEncryptedCompressed ( string filesLocaton, string fileSuffix, int compressionLevel ) : void

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database encrypted and compressed.

StoreFileCompressed ( string fileLocation, int compressionLevel, long &returnFileId ) : void

Load file from filesystem into database unencrypted and compressed

StoreFileEncrypted ( string fileLocation, long &returnFileId ) : void

Load file from filesystem into database encrypted and uncompressed

StoreFileEncryptedCompressed ( string fileLocation, int compressionLevel, long &returnFileId ) : void

Load file from filesystem into database encrypted and compressed

StorePassPhrase ( string password ) : void

Hashes and stores a passphrase in the database for encryption/decryption

Private Methods

Method Description
DecryptStream ( byte dataStream, string password ) : byte[]

Decrypt byte array

EncryptStream ( byte dataStream, string password ) : byte[]

Encrypt byte array

GetFileNameWithPath ( string location, string fileName ) : string

Creates path if it doesn't exists. Deletes any files with same name as output file.

GetMd5Hash ( string input ) : string

Generate 256 bit MD5 hash

RandomASCIIString ( int length ) : string

Generate random ASCII string

StoreFile ( string fileLocation, long &returnFileId ) : void
ZipCompress ( string fileName, int compressionLevel ) : byte[]

Stores incomming data as standard zip file into byte array

ZipDecompress ( byte compressedData, int origionalFileSize ) : byte[]

uncompresses zip data from byte array

xp_getfiledetails ( string filePath ) : void

Method Details

ExtractFileToDisk() public static method

Retrieves file from database uncompresses and decrypts it if it needs to.
public static ExtractFileToDisk ( long fileId, string location ) : void
fileId long file id
location string Location to extract to
return void

ExtractFileToDiskCompressed() public static method

Retrieves file from database raw compressed form with .zip extention
public static ExtractFileToDiskCompressed ( long fileId, string location ) : void
fileId long file id
location string Location to extract to
return void

ExtractFileToDiskEncrypted() public static method

Retrieves file from database raw encrypted form .enc extention
public static ExtractFileToDiskEncrypted ( long fileId, string location ) : void
fileId long file id
location string Location to extract to
return void

ExtractFileToDiskEncryptedCompressed() public static method

Retrieves file from database raw encrypted and compressed form with .zip.enc extention
public static ExtractFileToDiskEncryptedCompressed ( long fileId, string location ) : void
fileId long file id
location string Location to extract to
return void

ExtractFileToRecord() public static method

Retrieves file from database output to recordset decrypts and decompresses file if needed.
public static ExtractFileToRecord ( long fileId ) : void
fileId long file id
return void

ExtractFileToRecordCompressed() public static method

Retrieves file from database as sql recordset in raw compressed form
public static ExtractFileToRecordCompressed ( long fileId ) : void
fileId long file id
return void

ExtractFileToRecordEncrypted() public static method

Retrieves file from database as sql recordset in raw encrypted form
public static ExtractFileToRecordEncrypted ( long fileId ) : void
fileId long file id
return void

ExtractFileToRecordEncryptedCompressed() public static method

Retrieves file from database as sql recordset in raw encrypted and compressed form
public static ExtractFileToRecordEncryptedCompressed ( long fileId ) : void
fileId long file id
return void

StoreAllFilesInPath() public static method

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database unencrypted and uncompressed.
public static StoreAllFilesInPath ( string filesLocaton, string fileSuffix ) : void
filesLocaton string The files locaton.
fileSuffix string The file suffix.
return void

StoreAllFilesInPathCompressed() public static method

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database unencrypted and compressed.
public static StoreAllFilesInPathCompressed ( string filesLocaton, string fileSuffix, int compressionLevel ) : void
filesLocaton string The files locaton.
fileSuffix string The file suffix.
compressionLevel int The storetype.
return void

StoreAllFilesInPathEncrypted() public static method

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database encrypted and uncompressed.
public static StoreAllFilesInPathEncrypted ( string filesLocaton, string fileSuffix ) : void
filesLocaton string The files locaton.
fileSuffix string The file suffix.
return void

StoreAllFilesInPathEncryptedCompressed() public static method

Loads files from a path with filtering * for all flles in directory txt, doc, etc to filter by file type calls Loadfile to store the files in the database encrypted and compressed.
public static StoreAllFilesInPathEncryptedCompressed ( string filesLocaton, string fileSuffix, int compressionLevel ) : void
filesLocaton string The files locaton.
fileSuffix string The file suffix.
compressionLevel int The storetype.
return void

StoreFileCompressed() public static method

Load file from filesystem into database unencrypted and compressed
public static StoreFileCompressed ( string fileLocation, int compressionLevel, long &returnFileId ) : void
fileLocation string The files locaton.
compressionLevel int The files locaton.
returnFileId long Return of the inserted FileId
return void

StoreFileEncrypted() public static method

Load file from filesystem into database encrypted and uncompressed
public static StoreFileEncrypted ( string fileLocation, long &returnFileId ) : void
fileLocation string The files locaton.
returnFileId long Return of the inserted FileId
return void

StoreFileEncryptedCompressed() public static method

Load file from filesystem into database encrypted and compressed
public static StoreFileEncryptedCompressed ( string fileLocation, int compressionLevel, long &returnFileId ) : void
fileLocation string The files locaton.
compressionLevel int The files locaton.
returnFileId long
return void

StorePassPhrase() public static method

Hashes and stores a passphrase in the database for encryption/decryption
public static StorePassPhrase ( string password ) : void
password string Passphrase
return void