|
@@ -1,8 +1,10 @@
|
|
package logic
|
|
package logic
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "compress/gzip"
|
|
"context"
|
|
"context"
|
|
"errors"
|
|
"errors"
|
|
|
|
+ "io/ioutil"
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"bytes"
|
|
"bytes"
|
|
@@ -45,6 +47,9 @@ func (l *SaveFileLogic) SaveFile(in *filesystem.SaveFileReq) (*filesystem.FileOp
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if len(in.RawFileContent) > 0 {
|
|
|
|
+ in.RawFileContent, _ = decompress(in.RawFileContent)
|
|
|
|
+ }
|
|
// 设置文件元信息:过期时间为2049年1月10日 23:00:00 GMT,访问权限为公共读,自定义元信息为MyProp(取值MyPropVal)。
|
|
// 设置文件元信息:过期时间为2049年1月10日 23:00:00 GMT,访问权限为公共读,自定义元信息为MyProp(取值MyPropVal)。
|
|
// expires := time.Date(2049, time.January, 10, 23, 0, 0, 0, time.UTC)
|
|
// expires := time.Date(2049, time.January, 10, 23, 0, 0, 0, time.UTC)
|
|
options := []oss.Option{
|
|
options := []oss.Option{
|
|
@@ -62,3 +67,12 @@ func (l *SaveFileLogic) SaveFile(in *filesystem.SaveFileReq) (*filesystem.FileOp
|
|
}
|
|
}
|
|
return &filesystem.FileOpResp{State: true, FileId: in.FileId}, nil
|
|
return &filesystem.FileOpResp{State: true, FileId: in.FileId}, nil
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func decompress(data []byte) ([]byte, error) {
|
|
|
|
+ r, err := gzip.NewReader(bytes.NewBuffer(data))
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ defer r.Close()
|
|
|
|
+ return ioutil.ReadAll(r)
|
|
|
|
+}
|