@@ -45,7 +45,7 @@ export class ContentController {
4545 const file = files . thumbnail [ 0 ] ;
4646 const fileName = file . newFilename ;
4747 const fileType = file . mimetype ;
48- const filePath = file . filepath ; // Use 'filepath' for formidable v2+
48+ const filePath = file . filepath ;
4949
5050 try {
5151 if ( ! filePath ) {
@@ -54,10 +54,10 @@ export class ContentController {
5454
5555 // Pass the file object with the correct path to StorageService
5656 const response = await StorageService . uploadFile (
57- { ...file , path : filePath } , // Ensure 'path' is set if your StorageService expects it
57+ { ...file , path : filePath } ,
5858 "thumbnails" ,
5959 fileName ,
60- fileType ,
60+ fileType
6161 ) ;
6262 res . status ( 201 ) . json ( response ) ;
6363 } catch ( error : any ) {
@@ -86,15 +86,16 @@ export class ContentController {
8686
8787 static async editContent ( req : Request , res : Response ) {
8888 console . log ( "Fetching Content..." ) ;
89- const { contentId, userId } = req . params ;
90- const { data } = req . body ;
89+ const { contentId } = req . params ;
90+ const data = req . body ;
91+ const uid = req . user ?. uid ;
9192
9293 try {
9394 // const confirmation = await axios.get(`${apiURL}/content/${contentId}`)
9495 const confirmation = await ContentService . getContent ( contentId ) ;
9596 const owner_id = confirmation ?. creatorUID ;
9697
97- if ( userId == owner_id ) {
98+ if ( uid == owner_id ) {
9899 //check whether they are allowed to edit the content
99100 const response = await ContentService . editContent ( contentId , data ) ;
100101 res . status ( 200 ) . json ( response ) ;
@@ -104,7 +105,7 @@ export class ContentController {
104105 } catch ( error : any ) {
105106 console . log ( error ) ;
106107 res
107- . status ( 401 )
108+ . status ( 500 )
108109 . json ( { error : error . message || "Failed to edit content" } ) ;
109110 }
110111 }
@@ -156,7 +157,7 @@ export class ContentController {
156157 file ,
157158 "thumbnails" ,
158159 fileName ,
159- fileType ,
160+ fileType
160161 ) ;
161162
162163 const updateData = JSON . parse ( fields . data ) ;
0 commit comments