adding decompress

This commit is contained in:
2020-07-07 15:03:33 -04:00
parent c07e09d155
commit ebd6e095f7
77 changed files with 185 additions and 50 deletions

View File

@@ -5,7 +5,6 @@ import (
"compress/gzip"
"encoding/binary"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -68,19 +67,15 @@ func ExpandToIntArray(length int64, arry []byte, intArray *[]int64) error {
// return fileName, nil
// }
func ConvertFileForStorage(file *database.File, folder string) error {
fileBytes, err := ioutil.ReadFile(file.Path)
// ConvertFileForStorage opens the original file and dumps the bytes to pgzip to compress it for storage
func ConvertFileForStorage(file *database.File, folder string) (fileName string, err error) {
filename := folder + string(filepath.Separator) + file.Name //fileName is under the object folder then the hash, then the filename
err = CompressFile(filename)
if err != nil {
return err
return filename, err
}
fmt.Println("REMOVE: ", fileBytes)
filename := folder + string(filepath.Separator) + file.Name
err = ioutil.WriteFile(filename, fileBytes, 0666)
if err != nil {
return err
}
return nil
fmt.Println("Compressed and written", file.Path)
return filename, nil
}
func IsDirectory(path string) (bool, error) {