-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from harshbhar0629/Feat/ImageUpload-Cloudinary
Feat/Image Upload Cloudinary
- Loading branch information
Showing
7 changed files
with
90 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** @format */ | ||
|
||
const cloudinary = require("cloudinary").v2; //! Cloudinary is being required | ||
|
||
exports.cloudinaryConnect = () => { | ||
try { | ||
cloudinary.config({ | ||
// Configuring the Cloudinary to Upload MEDIA | ||
cloud_name: process.env.CLOUD_NAME, | ||
api_key: process.env.CLOUD_API_KEY, | ||
api_secret: process.env.CLOUD_SECRET, | ||
}); | ||
console.log("Cloud connect successfully") | ||
} catch (error) { | ||
console.log("Error in connection of cloud"); | ||
console.log(error.message); | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** @format */ | ||
|
||
const cloudinary = require("cloudinary").v2; | ||
|
||
exports.uploadImageToCloudinary = async (file, folder, height, quality) => { | ||
const options = { folder }; | ||
if (height) { | ||
options.height = height; | ||
} | ||
if (quality) { | ||
options.quality = quality; | ||
} | ||
|
||
options.resource_type = "auto"; | ||
|
||
return await cloudinary.uploader.upload(file.tempFilePath, options); | ||
}; |
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