shaejah6

Hướng dẫn sinh thumbnail

Aug 20th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. 1. Tạo campaign
  2. - Lưu JSON + HTML content
  3. - Tạo một unique key dạng UUID cho mỗi campaign, ví dụ: 8cb39c20-3ad5-47e3-8ca5-e90c58bf19c3
  4.  
  5. 2. Tạo link preview campaign
  6. Link này sẽ view nội dung HTML của campaign như một website hoàn chỉnh
  7. https://api.gobysend.com/campaign/preview/8cb39c20-3ad5-47e3-8ca5-e90c58bf19c3
  8.  
  9. (Mục đích là link này không dò ra được bởi người khác. Trong trường hợp campaign chưa publish mà người khác dò được link có thể bị lộ mất chiến dịch chuẩn bị quảng bá)
  10.  
  11. 3. Khi lưu campaign thì gọi service thum.io để sinh thumbnail
  12. https://image.thum.io/get/auth/10919-e49d55e4-5c58-4f31-a3bd-463a89e62619/https://api.gobysend.com/campaign/preview/8cb39c20-3ad5-47e3-8ca5-e90c58bf19c3
  13.  
  14. - Tải thumbnail về thành base64
  15. $imageContent = bas64_encode(....);
  16.  
  17. - Sử dụng Laravel để upload lên Goby's CDN
  18. $pathToThumb = 'campaigns/' . $accountId . '/thumbnails/' . $campaign->uuid . '.jpg';
  19. Storage::disk('publicB2')->put($pathToThumb, $imageContent);
  20.  
  21. - Lưu thumb URL vào bảng cp_campaigns
  22. $campaign->thumbnail = config('filesystems.cdnLinks.publicB2') . $pathToThumb;
  23. $campaign->save();
  24.  
  25. 4. Ở client muốn preview thì chỉ việc view link:
  26. $url = $campaign->thumbnail;
Add Comment
Please, Sign In to add comment