Compare commits

..

No commits in common. "aeba225c87119087077fe88a9f6b68debe341553" and "9d259925f89b815f76acfafb77fd7d143d9a92af" have entirely different histories.

2 changed files with 3 additions and 16 deletions

View File

@ -1991,9 +1991,7 @@ func (s *S5API) downloadFile(jc jape.Context) {
return return
} }
if len(file.Mime()) > 0 {
jc.ResponseWriter.Header().Set("Content-Type", file.Mime()) jc.ResponseWriter.Header().Set("Content-Type", file.Mime())
}
http.ServeContent(jc.ResponseWriter, jc.Request, file.Name(), file.Modtime(), file) http.ServeContent(jc.ResponseWriter, jc.Request, file.Name(), file.Modtime(), file)
} }

View File

@ -188,7 +188,7 @@ func (t *TusHandler) Uploads(ctx context.Context, uploaderID uint) ([]models.Tus
return uploads, nil return uploads, nil
} }
func (t *TusHandler) CreateUpload(ctx context.Context, hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string, mimeType string) (*models.TusUpload, error) { func (t *TusHandler) CreateUpload(ctx context.Context, hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error) {
upload := &models.TusUpload{ upload := &models.TusUpload{
Hash: hash, Hash: hash,
UploadID: uploadID, UploadID: uploadID,
@ -196,7 +196,6 @@ func (t *TusHandler) CreateUpload(ctx context.Context, hash []byte, uploadID str
UploaderIP: uploaderIP, UploaderIP: uploaderIP,
Uploader: models.User{}, Uploader: models.User{},
Protocol: protocol, Protocol: protocol,
MimeType: mimeType,
} }
result := t.db.WithContext(ctx).Create(upload) result := t.db.WithContext(ctx).Create(upload)
@ -513,17 +512,7 @@ func (t *TusHandler) worker() {
continue continue
} }
var mimeType string _, err = t.CreateUpload(ctx, decodedHash.HashBytes(), info.Upload.ID, uploaderID, uploaderIP, t.storageProtocol.Name())
for _, field := range []string{"mimeType", "mimetype", "filetype"} {
typ, ok := info.Upload.MetaData[field]
if ok {
mimeType = typ
break
}
}
_, err = t.CreateUpload(ctx, decodedHash.HashBytes(), info.Upload.ID, uploaderID, uploaderIP, t.storageProtocol.Name(), mimeType)
mutex.(*sync.Mutex).Unlock() mutex.(*sync.Mutex).Unlock()
if err != nil { if err != nil {
errorResponse.Body = "Could not create tus upload" errorResponse.Body = "Could not create tus upload"