mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-11 12:17:44 +02:00
fix: do not cache m3u8 files
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -84,7 +84,7 @@ func getObjectKeyFromPath(s string) string {
|
||||
}
|
||||
|
||||
// PutFile uploads file to the datalake
|
||||
func (d *DatalakeStorage) PutFile(ctx context.Context, fileName string) error {
|
||||
func (d *DatalakeStorage) PutFile(ctx context.Context, fileName string, options PutOptions) error {
|
||||
// #nosec
|
||||
file, err := os.Open(fileName)
|
||||
if err != nil {
|
||||
@@ -127,6 +127,9 @@ func (d *DatalakeStorage) PutFile(ctx context.Context, fileName string) error {
|
||||
req.Header.SetMethod(fasthttp.MethodPost)
|
||||
req.Header.Add("Authorization", "Bearer "+d.token)
|
||||
req.Header.SetContentType(writer.FormDataContentType())
|
||||
if options.NoCache {
|
||||
req.Header.Add("Cache-Control", "max-age=0, must-revalidate")
|
||||
}
|
||||
req.SetBody(body.Bytes())
|
||||
|
||||
if err := d.client.Do(req, res); err != nil {
|
||||
|
||||
@@ -84,7 +84,7 @@ func (u *S3Storage) DeleteFile(ctx context.Context, fileName string) error {
|
||||
}
|
||||
|
||||
// PutFile uploads file to the s3 storage
|
||||
func (u *S3Storage) PutFile(ctx context.Context, fileName string) error {
|
||||
func (u *S3Storage) PutFile(ctx context.Context, fileName string, options PutOptions) error {
|
||||
var _, objectKey = filepath.Split(fileName)
|
||||
var logger = u.logger.With(zap.String("upload", u.bucketName), zap.String("fileName", fileName))
|
||||
|
||||
|
||||
@@ -37,9 +37,14 @@ type BlobInfo struct {
|
||||
ETag string
|
||||
}
|
||||
|
||||
// PutOptions represents options for the PutFile operation
|
||||
type PutOptions struct {
|
||||
NoCache bool
|
||||
}
|
||||
|
||||
// Storage represents file-based storage
|
||||
type Storage interface {
|
||||
PutFile(ctx context.Context, fileName string) error
|
||||
PutFile(ctx context.Context, fileName string, options PutOptions) error
|
||||
DeleteFile(ctx context.Context, fileName string) error
|
||||
GetFile(ctx context.Context, fileName, destination string) error
|
||||
StatFile(ctx context.Context, fileName string) (*BlobInfo, error)
|
||||
|
||||
@@ -316,7 +316,10 @@ func (u *uploaderImpl) uploadAndDelete(f string) {
|
||||
for attempt := range u.options.RetryCount {
|
||||
logger = logger.With(zap.Int("attempt", attempt))
|
||||
var putCtx, putCancel = context.WithTimeout(u.uploadCtx, u.options.Timeout)
|
||||
var err = u.storage.PutFile(putCtx, f)
|
||||
var putOptions = storage.PutOptions{
|
||||
NoCache: u.shouldDeleteOnStop(f),
|
||||
}
|
||||
var err = u.storage.PutFile(putCtx, f, putOptions)
|
||||
putCancel()
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user