-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cloudinary service changed to s3 in instructor auth
- Loading branch information
Showing
9 changed files
with
52 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,6 @@ [email protected] | |
EMAIL_PASSWORD=your-email-password | ||
FROM_EMAIL = your-from-email | ||
|
||
CLOUDINARY_CLOUD_NAME = your-cloud-name | ||
CLOUDINARY_API_KEY = your-cloud-api-key | ||
CLOUDINARY_API_SECRET = your-cloud-secret | ||
|
||
AWS_ACCESS_KEY = access-key | ||
AWS_SECRET_KEY = secret-key | ||
AWS_BUCKET_REGION = bucket-region | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +0,0 @@ | ||
import { v2 as cloudinary } from 'cloudinary'; | ||
import multer from 'multer'; | ||
import { RequestHandler } from 'express'; | ||
import { CloudinaryStorage } from 'multer-storage-cloudinary'; | ||
import configKeys from '../../../config'; | ||
|
||
// Cloudinary configuration | ||
cloudinary.config({ | ||
cloud_name: configKeys.CLOUDINARY_CLOUD_NAME, | ||
api_key: configKeys.CLOUDINARY_API_KEY, | ||
api_secret: configKeys.CLOUDINARY_API_SECRET | ||
}); | ||
|
||
// Function to configure Multer for handling single or multiple images | ||
function configureMulter(field: string, limit: number, resourceType: string, allowedFormats: string[]): RequestHandler { | ||
const storageOptions = { | ||
cloudinary: cloudinary, | ||
params: { | ||
resource_type: resourceType, | ||
allowed_formats: allowedFormats, | ||
folder: 'Tutor-Trek' // Specify the folder where the images or videos will be stored in Cloudinary | ||
} | ||
}; | ||
|
||
const storage = new CloudinaryStorage(storageOptions); | ||
return multer({ storage: storage }).array(field, limit); | ||
} | ||
|
||
// Function to configure Multer for handling images | ||
function configureImageMulter(field: string, limit: number): RequestHandler { | ||
const resourceType = 'image'; // Specify the resource type as 'image' for images | ||
const allowedFormats = ['jpg', 'jpeg', 'png']; | ||
|
||
return configureMulter(field, limit, resourceType, allowedFormats); | ||
} | ||
|
||
// Function to configure Multer for handling videos | ||
function configureVideoMulter(field: string, limit: number): RequestHandler { | ||
const resourceType = 'video'; // Specify the resource type as 'video' for videos | ||
const allowedFormats = ['mp4', 'mov']; // Add supported video formats here | ||
|
||
return configureMulter(field, limit, resourceType, allowedFormats); | ||
} | ||
|
||
// Function to configure Multer for handling both image and video uploads | ||
function configureImageAndVideoMulter(field: string, limit: number): RequestHandler { | ||
const resourceType = 'auto'; // Specify the resource type as 'auto' to handle both images and videos | ||
const allowedFormats = ['jpg', 'jpeg', 'png', 'mp4', 'mov']; // Add supported formats for both images and videos | ||
|
||
return configureMulter(field, limit, resourceType, allowedFormats); | ||
} | ||
|
||
export const uploadSingleImage: RequestHandler = configureImageMulter('image', 1); | ||
export const uploadMultipleImages: RequestHandler = configureImageMulter('images', 5); | ||
|
||
export const uploadSingleVideo: RequestHandler = configureVideoMulter('video', 1); | ||
export const uploadMultipleVideos: RequestHandler = configureVideoMulter('videos', 5); | ||
|
||
export const uploadImageAndVideo: RequestHandler = configureImageAndVideoMulter('files', 2); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1699,21 +1699,6 @@ chownr@^2.0.0: | |
resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" | ||
integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== | ||
|
||
cloudinary-core@^2.13.0: | ||
version "2.13.0" | ||
resolved "https://registry.yarnpkg.com/cloudinary-core/-/cloudinary-core-2.13.0.tgz#b59f90871b6c708c3d0735b9be47ac08181c57fb" | ||
integrity sha512-Nt0Q5I2FtenmJghtC4YZ3MZZbGg1wLm84SsxcuVwZ83OyJqG9CNIGp86CiI6iDv3QobaqBUpOT7vg+HqY5HxEA== | ||
|
||
cloudinary@^1.37.2: | ||
version "1.39.0" | ||
resolved "https://registry.yarnpkg.com/cloudinary/-/cloudinary-1.39.0.tgz#3f4a103ab36daae85705d9240d17b3583978eea2" | ||
integrity sha512-xVCzduGsEgYWe/xnbB6rrx56NCvPtqJGh+G6aTSdattxpuewgFH9S/7JCIatLQcBw2JzkJKAYJ1wdRg/QiRFlw== | ||
dependencies: | ||
cloudinary-core "^2.13.0" | ||
core-js "^3.30.1" | ||
lodash "^4.17.21" | ||
q "^1.5.1" | ||
|
||
[email protected]: | ||
version "1.1.2" | ||
resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz#88ddaa46906e303b5de30d3153b7d9fe0a0c19ac" | ||
|
@@ -1801,11 +1786,6 @@ cookie@~0.4.1: | |
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" | ||
integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== | ||
|
||
core-js@^3.30.1: | ||
version "3.32.0" | ||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.32.0.tgz#7643d353d899747ab1f8b03d2803b0312a0fb3b6" | ||
integrity sha512-rd4rYZNlF3WuoYuRIDEmbR/ga9CeuWX9U05umAvgrrZoHY4Z++cp/xwPQMvUpBB4Ag6J8KfD80G0zwCyaSxDww== | ||
|
||
core-util-is@~1.0.0: | ||
version "1.0.3" | ||
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" | ||
|
@@ -2829,11 +2809,6 @@ multer-s3@^3.0.1: | |
html-comment-regex "^1.1.2" | ||
run-parallel "^1.1.6" | ||
|
||
multer-storage-cloudinary@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/multer-storage-cloudinary/-/multer-storage-cloudinary-4.0.0.tgz#afc9e73c353668c57dda5b73b7bb84bae6635f6f" | ||
integrity sha512-25lm9R6o5dWrHLqLvygNX+kBOxprzpmZdnVKH4+r68WcfCt8XV6xfQaMuAg+kUE5Xmr8mJNA4gE0AcBj9FJyWA== | ||
|
||
multer@^1.4.5-lts.1: | ||
version "1.4.5-lts.1" | ||
resolved "https://registry.yarnpkg.com/multer/-/multer-1.4.5-lts.1.tgz#803e24ad1984f58edffbc79f56e305aec5cfd1ac" | ||
|
@@ -3040,11 +3015,6 @@ punycode@^2.1.0, punycode@^2.1.1: | |
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" | ||
integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== | ||
|
||
q@^1.5.1: | ||
version "1.5.1" | ||
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" | ||
integrity sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== | ||
|
||
[email protected]: | ||
version "6.11.0" | ||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" | ||
|