See the effect first:
As a professional freeloader, how can I be satisfied with only using Oracle's four free instances? Of course, I also need to make use of the object storage with 20GB of free space. Recently, I have picked up my blog, which has been abandoned for many years, and decided to use it as the image hosting service for my blog.
Prerequisites#
- An Oracle Cloud account (credit card verification is required, which is already difficult to apply for in mainland China).
- A good scientific environment.
Preparation of Oracle Object Storage Bucket#
- Go to the Oracle Cloud Object Storage management interface and create a new bucket.
The default configuration is sufficient. After creating the bucket, edit its visibility. You can choose either public or private.
Public: All files are allowed to be read.
Private: Partial files can be made public using pre-authenticated requests (recommended).
- Create a pre-authenticated request.
Select objects with a prefix and fill in "images" as the prefix. This prefix needs to match the one configured in PicGo later, otherwise there may be permission issues. The access type can be set to read-only by default, and the expiration time should be set for multiple years if possible.
Copy and save the URL. This is the BaseURL for accessing the corresponding prefix directory of the bucket.
Upload an image to test if it can be accessed.
As you can see, due to the permission settings of the bucket, accessing the image using the URL path is not possible.
It needs to be replaced with the URL prefix of the pre-authenticated request created just now:
https://objectstorage.ap-chuncheon-1.oraclecloud.com/p/xxx/n/{namespace}/b/blog/o/images/2022-05-23.png
- Bucket Endpoint
The endpoint for Oracle's object storage ishttps://{namespace}.compat.objectstorage.{region}.oraclecloud.com/
.- namespace: The namespace field in the bucket information.
- region: This is the region of your Oracle account, usually reflected in the address of your OCI console. For example, in my case, it is
ap-chuncheon-1
.
- namespace: The namespace field in the bucket information.
- Apply for Oracle Account Access Key and Secret Key
Click on the avatar in the upper right corner, go to "My Profile", and select "Customer Keys" to generate a key.
Save the generated key. This key is theSecretAccessKey
of your account.
TheAccessKeyID
can be found on the list page. Copy and save it as well.
Install and Configure PicGo and S3 Plugin#
With the preparations completed, let's configure the image hosting tool. There are two options:
- With a GUI: PicGo
- With CLI: PicGo-Core
Both options are similar in terms of configuration, but the difference lies in whether a GUI is provided.
Install Node.js Environment#
Install according to the official website of Node.js.
Install PicGo-Core#
npm install picgo -g
or using Yarn
yarn global add picgo
Verify the installation
picgo -h
If the installation is successful, the following result will be displayed:
Add S3 Plugin#
The S3 plugin theoretically supports all object storage services compatible with the S3 API. For more details, please refer to the plugin's homepage.
picgo add s3
After successful installation, the configuration file will contain the following information:
Configure the S3 Plugin#
{
"picBed": {
"uploader": "aws-s3",
"current": "aws-s3",
"aws-s3": {
"accessKeyID": "{ak}",
"secretAccessKey": "{sk}",
"bucketName": "{bucket}",
"region": "{region}",
"uploadPath": "images/{year}/{month}/{md5}.{extName}",
"endpoint": "https://{namespace}.compat.objectstorage.{region}.oraclecloud.com/",
"acl": "public-read",
"pathStyleAccess": true,
"urlPrefix": "https://objectstorage.ap-chuncheon-1.oraclecloud.com/p/{publicKey}/n/{namespace}/b/blog/o",
"disableBucketPrefixToURL": true
}
},
"picgoPlugins": {
"picgo-plugin-s3": true
}
}
In the above configuration, except for the uploadPath
field, all other placeholders "{}" should be replaced with the corresponding values:
- ak: The
AccessKeyID
of your Oracle account obtained earlier. - sk: The
SecretAccessKey
of your Oracle account obtained earlier. - bucket: The name of the bucket. In my case, it is
blog
. - region: The
region
obtained earlier. In my case, it isap-chuncheon-1
. - The placeholders in the
uploadPath
field do not need to be modified. Make sure that the prefix "images" matches the prefix used in the "pre-authenticated request" section. - namespace: The
namespace
obtained earlier. - urlPrefix: This field is the URL prefix obtained from the "pre-authenticated request" section.
- disableBucketPrefixToURL: This field must be set to true, otherwise the bucket prefix will be automatically added to the uploaded URL, resulting in access failure. For more details, please refer to this issue.
Verify the Configuration#
Use a screenshot tool to capture an image to the clipboard.
picgo upload
Upload the image from the clipboard.
The image link can be accessed successfully.
At this point, the basic functionality of the image hosting service has been achieved. It can be used with any text editor, but it may be a bit cumbersome. It would be better if the uploaded image could be displayed immediately after successful upload. Next, we will use Obsidian with the corresponding plugin to achieve the above functionality.
Install and Configure Obsidian#
Download and install Obsidian.
Disable safe mode and search for "Image auto upload Plugin" to install the plugin.
Configure the plugin.
Select PicGo-Core
as the default uploader.
Conclusion#
With this, the tutorial on using Oracle as an object storage service is complete. However, there are still some shortcomings, such as the suboptimal image access performance due to the lack of CDN support in Oracle's object storage, resulting in different access experiences in different regions. In the next chapter, we will use CloudFlare to accelerate our image access and discuss the method of uploading GIFs in special cases.