Skip to main content

Thực hành Cloudinary

Thực tế cần làm để sử dụng "Cloudinary" upload hình ảnh, video, tài liệu lên "Cloudinary" rồi lấy link gắn vào bài viết. Áp dụng đúng theo hướng dẫn của cách này hoàn toàn thành công!

Tham khảo từ bài viết này:

https://dev.to/evansitworld/upload-images-with-nodejs-and-express-to-the-cloud-using-cloudinary-26e4

1)Bước đầu tiên là tạo acc trong "cloudinary" qua link này: https://cloudinary.com/ Ta sẽ có 1 Acc với 3 tham số sau: -Cloud name: axxx... -API key: 66....73:pq... -API secret: IX_19cD... Gom gọn như(vd): CLOUDINARY_URL=cloudinary://66....73:pq...IX_19cD...@axxx...

2)Tham khảo bài tập ví dụ thực hành "Cloudinary" tải ảnh lên... như trong link GitHub: https://github.com/evans646/Cloudinary-Demo

Cụ thể:

-Tạo 1 repository trong D: qua giòng lệnh trong Terminal:

git clone https://github.com/evans646/Cloudinary-Demo.git

Tiếp:

cd Cloudinary-Demo

Tiếp:

npm install

Xong chạy thử:

npm run start 

Đến đây cấu trúc trong Visual Stududio sẽ có dạng:

alt text

Gõ vào Terminal:

npm start

để xem thử trong trình duyệt ở link: http://localhost:8080/ , ta sẽ thấy có dạng:

alt text

Nếu báo lỗi là còn thiếu "nodemon", ta gõ trong Terminal lệnh sau để cài:

npm install -g nodemon

Tiếp theo, từ thư mục gốc, ta cài "cloudinary":

npm install  cloudinary

Tiếp theo:

npm install multer-storage-cloudinary

Tiếp theo:

npm install dotenv

Đến bước tạo folder "storage" bằng lệnh:

npm install dotenv

Rồi tạo file "storage.js" trong "storage" (storage/storage.js)

..... XEM MẪU THEO LINK: "F:\1CLOUDINARYmau"

VIDEO THAM KHẢO THÊM::

Cách dùng CLOUDINARY

https://cloudinary.com/documentation/upload_images

YOUTUBE SỬ DỤNG CLOUDINARY

https://www.youtube.com/watch?v=2Z1oKtxleb4