Add more things for file handling
This commit is contained in:
parent
c813c4784a
commit
1fcf47bffc
14 changed files with 284 additions and 59 deletions
|
@ -1,8 +1,9 @@
|
|||
package media
|
||||
|
||||
import (
|
||||
"git.mstar.dev/mstar/linstrom/config"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/config"
|
||||
)
|
||||
|
||||
// WARN: These types need to always be in sync with linstrom-transcoder/transcode/transcoder.go
|
||||
|
@ -22,7 +23,11 @@ type TranscodeReply struct {
|
|||
|
||||
// addFileWithTranscoder will try to transcode the given file using the helper application.
|
||||
// If the transcode fails, it uploads the file as is
|
||||
func (s *Server) addFileWithTranscoder(filename, userId, filepath string) error {
|
||||
func (s *Server) addFileWithTranscoder(
|
||||
filename, userId, filepath string,
|
||||
blurred bool,
|
||||
altText string,
|
||||
) (string, error) {
|
||||
args := TranscodeArgs{
|
||||
Secret: config.GlobalConfig.Transcoder.Secret,
|
||||
Filename: filepath,
|
||||
|
@ -30,11 +35,11 @@ func (s *Server) addFileWithTranscoder(filename, userId, filepath string) error
|
|||
reply := TranscodeReply{}
|
||||
err := s.transcoderClient.Call("Transcoder.Transcode", &args, &reply)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
if reply.Error != nil {
|
||||
log.Warn().Err(reply.Error).Msg("Transcoder failed, uploading raw file")
|
||||
return s.addFileAsIs(filename, userId, filepath, nil)
|
||||
return s.addFileAsIs(filename, userId, filepath, nil, blurred, altText)
|
||||
}
|
||||
return s.addFileAsIs(filename, userId, reply.Filename, &reply.Mimetype)
|
||||
return s.addFileAsIs(filename, userId, reply.Filename, &reply.Mimetype, blurred, altText)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue