How to store remote attachments to your OSS instance with Discuz

Last Updated: May 04, 2017

Preface

The website remote attachment function refers to directly storing uploaded attachments to a remote storage server, which is usually a remote FTP server, over the FTP.

Currently, Discuz forums, PHPWind forums, and WordPress websites support the remote attachment function.

This document instructs you on storing remote attachments from a Discuz-based forum.

Preparation

Apply for an OSS account and create a public-read bucket. You must set the permission to public-read because it must allow anonymous access.

Procedures

Here the Discuz version we use is Discuz! X3.1 and the detailed configuration process is shown below.

  • Log on to the Discuz website and go to the management interface. Click Global and then Upload Settings.

  • Select Remote Attachments and configure the function.

  1. Set “Enable remote attachment” to Yes.

  2. Set “Enable SSL connection” to “No“.

  3. Set the “FTP Server Address”, that is, the address that runs the OSS-FTP. Generally, this is “127.0.0.1“.

  4. Set “FTP service port No.” to the default “2048“.

  5. Set “FTP Account” in the format of AccessKeyID/BucketName, where “/“ does not mean “or“.

  6. Set “FTP Password” to AccessKeySecret.

  7. Set “Passive Mode Connection” to the default “Yes“.

  1. Set “Remote Attachment Directory” to “.“, that is, to create a directory for upload under the root directory of the bucket.

  2. Set “Remote URL” to http://BucketName.Endpoint.

Here, we will test the bucket test-hz-jh-002 from the Hangzhou region. Therefore, we enter http://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.com, where the BucketName must match the endpoint.

  1. Set the timeout time to 0, that is, to use the default setting of the service.

  2. After the configuration is complete, click “Test Remote Attachment”. If the test is successful, an information box will be displayed.

  • Verification

Ok, now let’s publish a post on the forum to test the function. On any board, create a post and upload an image as attachment in the post.

Right-click the image and select “Open image in new tab”.

In the browser, you can see the image URL is http://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.com/forum/201512/18/171012mzvkku2z3na2w2wa.png. This indicates that the image has been uploaded to test-hz-jh-002 in the OSS.

Thank you! We've received your feedback.