initial commit
This commit is contained in:
37
handler_upload_thumbnail.go
Normal file
37
handler_upload_thumbnail.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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{}{})
|
||||
}
|
||||
Reference in New Issue
Block a user