Automatic Review for User-Uploaded Images

Enable automatic review for uploaded images with Tencent Cloud COS/CDN: current setup, review config, and caveats.

Apr 29, 2024 · 2 min read · 297 Words · -Views -Comments · Digital Life
🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

Recently, I received news that the image upload feature in my project needs to undergo security review. After solving this problem, I’m marking it down here.

I’m currently using Tencent Cloud’s COS-CDN, so I’ll use this product as an example to introduce the process.

Current COS usage

Images are currently uploaded via COS, which returns a path after storage. I use COS with a bound domain name through CDN for users to access.

Review configuration

  1. COS supports configuring automatic image review. Since my COS also contains other resources, I enabled COS path restrictions for automatic image review—for example, only images in the /user-images path are reviewed.
  2. Since my image upload function was already online before, I needed to handle two types of images: existing and new ones
    1. Existing images are reviewed by configuring a task for COS to review them again
    2. For new images, I use the COS SDK, which automatically triggers review after upload
  3. Configure actions for non-compliant reviews. Considering that user images might be misjudged or the current standards are too strict, I configured the system to automatically move non-compliant images to a specified directory so there’s still a chance to recover them.
  4. Since the review is configured to be post-upload, the COS upload environment doesn’t know if the image is non-compliant. Therefore, if you want to notify users about non-compliant images in your project, you still need to call the review API yourself or configure a review callback API. Otherwise, the upload will succeed without any violation notification, but the image will return 404 when accessed because it was processed after the post-upload review.

Final Thoughts

Now I understand how to use image review and have solved the requirement. However, I have to say that these needs are really driven by the domestic environment…

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover