tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Storing Ghost Attachment to COS

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-03-25 15:16:26

Overview

Ghost is a Node.js-based framework for quickly building a blog website. You can use its official CLI tool to quickly generate your personal website and deploy it in CVM or Docker.
As a blog website, attachment upload is a necessary feature. Ghost stores attachments locally by default. This document describes how to save an attachment in COS through the plugin. Saving forum attachments in COS has the following benefits:
Higher reliability for your attachments.
No need to prepare additional storage capacity on your server for forum attachments.
Faster access to image attachments through the COS server rather than taking up downstream bandwidth/increasing the traffic on your own server.
Accelerated forum user access to image attachments through CDN.

Preparations

Building a Ghost website

1. Install the Node.js environment.
2. Install ghost-cli.
npm install ghost-cli@latest -g
3. Create a project and run the following command in the project's root directory:
ghost install local
After successful creation, the project structure is as shown below:

4. Open the browser and access localhost:2368. On the sign-up page, sign up for an account and go to the management backend.


Creating a COS bucket

1. In the COS console, create a bucket with access permissions of public read/private write as instructed in Creating Bucket.
2. Click Security Management > CORS (Cross-Origin Resource Sharing) and add a CORS configuration as instructed in Setting Cross-Origin Resource Sharing (CORS). You can use the following configuration to facilitate debugging:

Associating Ghost with a COS Bucket

Note:
We recommend you use a sub-account key and follow the principle of least privilege to reduce risks. For information about how to obtain a sub-account key, see Access Key.
1. Add the following configuration to the config.development.json configuration file in the Ghost project's root directory:
"storage": {
"active": "ghost-cos-store",
"ghost-cos-store": {
"BasePath": "ghost/", // You can change it to your directory name. If you leave it empty, the root directory will be used by default.
"SecretId": "AKID*************",
"SecretKey": "***************",
"Bucket": "xxx-125********",
"Region": "**-*******"
}
}
The parameters are described as follows:
Configuration Item
Value
BasePath
The COS path where files are stored. You can modify it as needed. If you leave it empty, the root directory will be used by default.
SecretId
Enter the access key information, which can be created and obtained on the Manage API Key page.
SecretKey
Your access key information, which can be created and obtained on the Manage API Key page.
Bucket
The name customized during bucket creation such as `examplebucket-1250000000`.
Region
The region selected during bucket creation
2. Create a custom storage directory and run the following command in the project's root directory:
mkdir -p content/adapters/storage
3. Install the ghost-cos-store plugin provide by Tencent Cloud.
3.1 Install it through npm.
npm install ghost-cos-store
3.2 Create the ghost-cos-store.js file with the following content in the storage directory:
// content/adapters/storage/ghost-cos-store.js
module.exports = require('ghost-cos-store');
3.3 Run git clone for installation.
cd content/adapters/storage
git clone https://github.com/tencentyun/ghost-cos-store.git
cd ghost-cos-store
npm i
3.4 After the installation, restart Ghost.
ghost restart

Publishing a Post and Testing Upload

1. In the Ghost console, click + to publish a post.

2. Click + to upload an image. From the packets captured by the browser, you can see that the upload request succeeds and the COS URL of the image is returned.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan