File tree Expand file tree Collapse file tree 5 files changed +15
-10
lines changed
Expand file tree Collapse file tree 5 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { Request } from "express";
1616import mediaService from "./service" ;
1717import { getMediaCount as getCount , getTotalSpace } from "./queries" ;
1818import { getSubscriptionStatus } from "@medialit/models" ;
19+ import { getSignatureFromReq } from "../signature/utils" ;
1920
2021function validateUploadOptions ( req : Request ) : Joi . ValidationResult {
2122 const uploadSchema = Joi . object ( {
@@ -69,7 +70,7 @@ export async function uploadMedia(
6970 access,
7071 caption,
7172 group,
72- signature : req . query . signature ,
73+ signature : getSignatureFromReq ( req ) ,
7374 } ) ;
7475
7576 const media = await mediaService . getMediaDetails ( {
Original file line number Diff line number Diff line change @@ -16,9 +16,11 @@ import {
1616} from "./handlers" ;
1717import signatureMiddleware from "../signature/middleware" ;
1818import storage from "./storage-middleware" ;
19+ import { getSignatureFromReq } from "../signature/utils" ;
1920
2021const router = express . Router ( ) ;
2122
23+ router . options ( "/create" , cors ( ) ) ;
2224router . post (
2325 "/create" ,
2426 cors ( ) ,
@@ -31,10 +33,7 @@ router.post(
3133 } ,
3234 } ) ,
3335 ( req : Request , res : Response , next : ( ...args : any [ ] ) => void ) => {
34- const signature =
35- req . query . signature ||
36- req . headers [ "x-medialit-signature" ] ||
37- req . headers [ "X-Medialit-Signature" ] ;
36+ const signature = getSignatureFromReq ( req ) ;
3837 if ( signature ) {
3938 signatureMiddleware (
4039 req as Request & { user : any ; apikey : string } ,
Original file line number Diff line number Diff line change 11import { Request , Response } from "express" ;
22import { PRESIGNED_URL_INVALID } from "../config/strings" ;
33import * as preSignedUrlService from "./service" ;
4+ import { getSignatureFromReq } from "./utils" ;
45
56export default async function signature (
67 req : Request & { user ?: any ; apikey ?: string } ,
78 res : Response ,
89 next : ( ...args : any [ ] ) => void ,
910) {
10- const signature =
11- req . query . signature ||
12- req . headers [ "x-medialit-signature" ] ||
13- req . headers [ "X-Medialit-Signature" ] ;
11+ const signature = getSignatureFromReq ( req ) ;
1412
1513 const response = await preSignedUrlService . getUserAndGroupFromPresignedUrl (
1614 signature as string ,
Original file line number Diff line number Diff line change 1+ export function getSignatureFromReq ( req : any ) {
2+ return (
3+ req . query . signature ||
4+ req . headers [ "x-medialit-signature" ] ||
5+ req . headers [ "X-Medialit-Signature" ]
6+ ) ;
7+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ import { server } from "./tus-server";
44
55const router = express . Router ( ) ;
66
7- router . all ( "/create/resumable{*splat} " , cors ( ) , server . handle . bind ( server ) ) ;
7+ router . all ( "/create/resumable* " , cors ( ) , server . handle . bind ( server ) ) ;
88
99export default router ;
You can’t perform that action at this time.
0 commit comments