Frequently Asked Questions
Installation
Can't find Content Management in the Cloud Console or WeChat IDE Cloud Development Console?
Unlike the original open-source version CMS and CMS cloud templates, Content Management is a built-in system of the cloud backend and requires activating the cloud backend before use.
Go to Content Management
Features
What are the differences and connections between Cloud Database and Content Management?
Differences
Positioning and Features:
- Cloud Database: Focuses on the structure, relationships, and operations of data. It provides a series of database operation functions, such as CRUD (Create, Read, Update, Delete), and supports advanced queries and validation. This type of application is primarily used for data maintenance and management, ensuring data integrity and consistency.
- Content Management: Focuses on the presentation and editing of content. Its intuitive visual interface allows non-technical users to manage content conveniently. It is suitable for managing various types of content, such as text, images, files, etc., and supports editing in rich text and Markdown formats.
Use Cases:
- Cloud Database: Suitable for scenarios requiring fine-grained control over data structures and relationships, such as enterprise-level applications, data analysis, and complex data operations.
- Content Management: Suitable for scenarios requiring rapid setup of content presentation and editing platforms, such as news websites, blogs, and e-commerce platforms.
Contact
- Data Sharing: Both Cloud Database and Content Management can access and operate data in the CloudBase database. Content data in Content Management applications can be accessed and manipulated through CloudBase's multi-end SDKs.
- Integration Capabilities: Content Management can seamlessly integrate with the CloudBase ecosystem, supporting integration with other CloudBase components such as cloud functions, triggers, and APIs, thereby enabling more complex business logic.
- User Experience: Content Management reduces the complexity of content management through its intuitive visual editing interface, enhancing operational efficiency; while Cloud Database ensures data accuracy and timeliness with its robust data manipulation capabilities.
In short, Cloud Database primarily serves developers, focusing on fine-grained management of data models; whereas Content Management applications are more oriented towards operational staff, emphasizing rapid content editing and utilization. Content Management is built upon specific data models. While the two differ in functionality and objectives, they exhibit close connections and complementarity.
How to convert cloud:// to https URL
File fields, image fields, and multimedia fields store user-uploaded resources as cloud file IDs in the cloud://
format for security purposes. Similarly, images uploaded in rich text and Markdown fields follow this convention. Conversion may be required when using these resources (components like the Mini Program's image
natively support cloud file IDs).
If you need to convert cloud:// to https links, you can refer to the following two methods:
Method 1: Invoke the sdk without modifying cloud storage permissions
Use the sdk to invoke the getTempFileURL method to obtain temporary access links for cloud storage files, converting private cloud://xxxx protocol addresses to standard http protocol addresses. Refer to the following implementation method.
Note: If the cloud://xxx protocol address is incorrect or lacks access permissions, this method will not return an address. Do not arbitrarily modify the default permissions of cloud storage.
- Web
- WeChat Mini Program
- Node.js
//Step 1: Introduce the Web SDK.
import tcb from '@cloudbase/js-sdk';
//Step two: perform initialization.
const app = tcb.init({
env: 'your-env-id',
});
//Step three: authenticate. The following is not complete code; you need to select a login method. For details, refer to "Quick Start" - "Authentication and Examples".
const auth = app.auth({
persistence: 'local', //remains valid for 30 days until the user explicitly logs out or changes the password.
});
const transformImgUrl = async (fileList) => {
const res = await app.getTempFileURL({
fileList,
});
const urlList = res.fileList?.map((i) => i.tempFileURL);
// fileList returns an array of objects with the following structure
// [{
// fileID: 'cloud://webtestjimmy-5328c3.7765-webtestjimmy-5328c3-1251059088/Tencent Cloud.png', // File ID.
// tempFileURL: '', // Temporary file network connection.
// maxAge: 120 * 60 * 1000, // Validity period.
// }]
return urlList;
};
const urlList = transformImgUrl(['cloud://a/b/c', 'cloud://d/e/f']);
console.log(urlList);
// ['https://a/b/c', 'https://d/e/f']
//First, use wx.cloud.init for initialization. There is no need to import the SDK again on the mini program side, and authentication is not required.
const transformImgUrl = async (fileList) => {
const res = await wx.cloud.getTempFileURL({
fileList,
});
const urlList = res.fileList?.map((i) => i.tempFileURL);
// fileList returns an array of objects with the following structure
// [{
// fileID: 'cloud://webtestjimmy-5328c3.7765-webtestjimmy-5328c3-1251059088/Tencent Cloud.png', // File ID.
// tempFileURL: '', // Temporary file network connection.
// maxAge: 120 * 60 * 1000, // Validity period.
// }]
return urlList;
};
const urlList = transformImgUrl(['cloud://a/b/c', 'cloud://d/e/f']);
console.log(urlList);
// ['https://a/b/c', 'https://d/e/f']
const tcb = require('@cloudbase/node-sdk');
const app = tcb.init();
const transformImgUrl = async (fileList) => {
const res = await app.getTempFileURL({
fileList,
});
const urlList = res.fileList?.map((i) => i.tempFileURL);
// fileList returns an array of objects with the following structure
// [{
// fileID: 'cloud://webtestjimmy-5328c3.7765-webtestjimmy-5328c3-1251059088/Tencent Cloud.png', // File ID.
// tempFileURL: '', // Temporary file network connection.
// maxAge: 120 * 60 * 1000, // Validity period.
// }]
return urlList;
};
const urlList = transformImgUrl(['cloud://a/b/c', 'cloud://d/e/f']);
console.log(urlList);
// ['https://a/b/c', 'https://d/e/f']
Method 2: Set cloud storage permissions to public read and convert file URLs via regex
Note: If the cloud://xxx protocol address is incorrect or lacks access permissions, the address converted by this method will be inaccessible. Setting cloud storage permissions to public read carries risks; modify permissions cautiously.
const transformImgUrl = (value) => {
const regex = /^(cloud):\/\/([0-9\-A-Za-z]+)?\.([0-9\-A-Za-z]+)\/(.*)/;
let matched = value.match(regex);
if (matched) {
const [_, protocol, envid, origin, path] = matched;
return protocol === 'cloud'
? `https://${origin}.tcb.qcloud.la/${path}`
: '';
}
};
Rich Text Content Conversion
For converting rich text content containing images, refer to the following solution:
In content management, the image address stored for uploaded images is a cloud protocol address. For custom image display handling, refer to the following methods.
- Define the transformValue method to match image-containing content via regular expressions and convert the image URLs.
export const transformValue = async (value, transformImgUrl) => {
// Regular expression for matching img
const regex = new RegExp(/<img [^>]*src=\\*"([^"]*?)\\*"/g);
// Match img tags with cloud protocol image addresses using regex
const imgList = value?.match(regex) || [];
let imgUrl = imgList
.map((i) => i.replace(regex, '$1'))
.filter((j) => j.includes('cloud://'));
if (imgUrl.length) {
// Convert image URL
imgUrl = await transformImgUrl(imgUrl);
}
let tempValue = value;
if (imgList && imgList.length > 0) {
// Set the obtained http address to the image's src for display
imgList.forEach((img, index) => {
const url = img.replace(regex, '$1');
if (imgList[index]) {
tempValue = tempValue.replace(new RegExp(url, 'g'), imgUrl[index]);
}
});
}
return tempValue;
};
- Call the transformValue event to obtain the converted rich text value
Fees
The Content Management application is activated at no additional cost as it is a default system application in the cloud console. Once you activate a cloud development environment, you can access and use Content Management in the cloud console. You only pay for the cloud resources you consume. View detailed information in the Billing Center.