This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
forked from sudo-puritin/diy-tutorial-video
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thinh Nguyen D
committed
Sep 30, 2024
1 parent
5dd4af8
commit 0910942
Showing
9 changed files
with
58 additions
and
17 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 |
---|---|---|
@@ -1 +1,4 @@ | ||
REACT_APP_BACKEND_API = "https://diy-backend.onrender.com/api" | ||
REACT_APP_BACKEND_API = "https://diy-backend.onrender.com/api" | ||
|
||
REACT_APP_CLOUDINARY_CLOUD_NAME="dguiswfoo" | ||
REACT_APP_CLOUDINARY_UPLOAD_PRESET="kyowgelt" |
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 +1,7 @@ | ||
export const BASE_URL = process.env.REACT_APP_BACKEND_API; | ||
|
||
export const CLOUDINARY_CLOUD_NAME = | ||
process.env.REACT_APP_CLOUDINARY_CLOUD_NAME; | ||
|
||
export const CLOUDINARY_UPLOAD_PRESET = | ||
process.env.REACT_APP_CLOUDINARY_UPLOAD_PRESET; |
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,5 +1,5 @@ | ||
export const API = { | ||
REGISTER: "/users", | ||
LOGIN: "/users/login", | ||
GET_USER_INFO: "/user/currentUser", | ||
GET_USER_INFO: "/users/currentUser", | ||
}; |
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
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,25 @@ | ||
import { CLOUDINARY_CLOUD_NAME, CLOUDINARY_UPLOAD_PRESET } from "../app/config"; | ||
import axios from "axios"; | ||
|
||
export const cloudinaryUpload = async (image) => { | ||
if (!image) return ""; | ||
|
||
try { | ||
const formData = new FormData(); | ||
|
||
formData.append("file", image); | ||
formData.append("upload_preset", CLOUDINARY_UPLOAD_PRESET); | ||
console.log("🚀 Puritin ~ cloudinaryUpload ~ formData:", formData); | ||
|
||
const response = await axios({ | ||
url: `https://api.cloudinary.com/v1_1/${CLOUDINARY_CLOUD_NAME}/image/upload`, | ||
data: formData, | ||
headers: { "Content-Type": "multipart/form-data" }, | ||
}); | ||
|
||
const imageUrl = response.data.secure_url; | ||
return imageUrl; | ||
} catch (error) { | ||
console.log("🚀 Puritin ~ cloudinaryUpload ~ error:", error); | ||
} | ||
}; |