Files
learn-file-storage-s3-golan…/handler_upload_thumbnail.go
Daniel Hjartland 75be79c6cf initial commit
2025-01-02 16:32:57 +01:00

38 lines
885 B
Go

package main
import (
"fmt"
"net/http"
"github.com/bootdotdev/learn-file-storage-s3-golang-starter/internal/auth"
"github.com/google/uuid"
)
func (cfg *apiConfig) handlerUploadThumbnail(w http.ResponseWriter, r *http.Request) {
videoIDString := r.PathValue("videoID")
videoID, err := uuid.Parse(videoIDString)
if err != nil {
respondWithError(w, http.StatusBadRequest, "Invalid ID", err)
return
}
token, err := auth.GetBearerToken(r.Header)
if err != nil {
respondWithError(w, http.StatusUnauthorized, "Couldn't find JWT", err)
return
}
userID, err := auth.ValidateJWT(token, cfg.jwtSecret)
if err != nil {
respondWithError(w, http.StatusUnauthorized, "Couldn't validate JWT", err)
return
}
fmt.Println("uploading thumbnail for video", videoID, "by user", userID)
// TODO: implement the upload here
respondWithJSON(w, http.StatusOK, struct{}{})
}