Creating a script to view your DreamObjects data in a browser

DreamObjects cluster migration

DreamHost is currently in the process of migrating all DreamObjects accounts to a new hardware platform.

Please review this article to identify the cluster your DreamObjects account currently resides on and the features it supports.

Overview

The following describes how to view all of your DreamObjects data within a web page. In order for the data to display, it must be publicly accessible.

Only follow the steps below if you are sure you want all of the data in a specific DreamObjects bucket to be accessible by anyone.

If you want certain objects hidden, set them as PRIVATE. 

Please note that the PRIVATE object names will still be viewable in a browser, however, clicking on the object will display an AccessDenied error.

Data uploaded to DreamObjects can only be viewed using an S3-compatible client or in the DreamHost panel.

You also have the option to view your data on a web page using the script below. This allows you to view a directory-structured list of your data which you can click through to view.

The code example in this article was taken from a third-party script.  View the following link for a full explanation of all fields and additional variables you can use:

Two ways to use this script

You can use this script in one of two ways.

  • Add the file to your DreamObjects bucket
  • Add the file to your website

The script functions the same either way. The only difference is that if you want to add the navigation script to your website, you must also enable CORS on your DreamObjects bucket as shown below.

Step 1 — Update your bucket and objects to PUBLIC permissions

In order for the script below to function, your bucket and all of its contents must be set to PUBLIC permissions. 

You can then use a tool like aws-cli to update all permissions on all objects by running a single command.

If you want certain objects hidden, set them as PRIVATE. 

Please note that the PRIVATE object names will still be viewable in a browser, however, clicking on the object will display an AccessDenied error.

Step 2 — Create the script

  1. Visit the following link to download the script to your computer:
  2. Open the file in a text editor of your choice.
  3. Using the code shown at the top of the script, change the text my-bucket to the name of the bucket you wish to display.
    <script type="text/javascript">
      var S3BL_IGNORE_PATH = true;
      var BUCKET_URL = 'https://objects-us-east-1.dream.io/my-bucket';
      var S3B_ROOT_DIR = '';
      var S3B_SORT = 'A2Z';
    </script>
  4. Save the file.

Step 3 — Upload the script

Choose one of the following locations to upload the script. You will then visit this URL to view the listing of your DreamObjects data.

Uploading the script to your DreamObjects bucket

Use this example if you want the directory listing to show when you visit a link in your DreamObjects bucket.

  1. Upload the script to the top level of your DreamObjects bucket.
  2. Make sure the file has PUBLIC permissions.
  3. Visit the file link. For example, if your bucket was named my-bucket and the file you uploaded was dholist.html, you would visit the following link.
    • https://objects-us-east-1.dream.io/my-bucket/dholist.html

A directory listing of your objects displays.

Uploading the script to your website

Use this example if you want the directory listing to show when you visit a link on your website.

There are a few extra steps that are required in order to run the file on your website. This is because the data is being pulled from DreamObjects, but your website does not have permission to display it. In order to give your website permission, you must enable CORS on your DreamObjects bucket.

View the following file for instructions on how to enable CORS on your bucket:

The aws-cli version is recommended due to its simplicity:

You can then visit the file on your website (http://example.com/dholist.html) to view a directory listing of your DreamObjects data.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?