-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace minio with aliyun oss
- Loading branch information
Showing
16 changed files
with
221 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package oss | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/bytecamp-galaxy/mini-tiktok/pkg/conf" | ||
"io" | ||
) | ||
|
||
func UploadFile(bucketName string, objectName string, reader io.Reader) (err error) { | ||
v := conf.Init() | ||
switch bucketName { | ||
case v.GetString("aliyun-oss.video-bucket-name"): | ||
err = videoBucket.PutObject(objectName, reader) | ||
case v.GetString("aliyun-oss.cover-bucket-name"): | ||
err = coverBucket.PutObject(objectName, reader) | ||
default: | ||
return errors.New("bucket name does not exist") | ||
} | ||
return | ||
} | ||
|
||
func GetFileUrl(bucketName string, objectName string) string { | ||
v := conf.Init() | ||
return fmt.Sprintf("https://%s.%s/%s", | ||
bucketName, | ||
v.GetString("endpoint"), | ||
objectName) | ||
} | ||
|
||
func VideoSnapshot(playUrl string) string { | ||
return fmt.Sprintf("%d?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast", | ||
playUrl) | ||
} |
Oops, something went wrong.