video aspect ratios categorized

This commit is contained in:
2025-03-16 10:24:09 +02:00
parent 1d0c56f493
commit 3c13056111
2 changed files with 57 additions and 1 deletions

View File

@@ -113,9 +113,29 @@ func (cfg *apiConfig) handlerUploadVideo(w http.ResponseWriter, r *http.Request)
return
}
ratio, err := getVideoAspectRatio(tempFile.Name())
if err != nil {
respondWithError(w, http.StatusInternalServerError, "Couldn't get aspect ratio", err)
return
}
var prefix string
switch ratio {
case "16:9":
prefix = "landscape"
break
case "9:16":
prefix = "portrait"
break
default:
prefix = "other"
break
}
tempFile.Seek(0, io.SeekStart)
fileName := videoPathName + extension
fileName := prefix + "/" + videoPathName + extension
_, err = cfg.s3Client.PutObject(context.Background(), &s3.PutObjectInput{
Bucket: &cfg.s3Bucket,