Waffle.Storage.AliyunOss (waffle_aliyun_oss v0.3.0)

The module to facilitate integratin with Aliyun OSS through Aliyun.Oss

config :waffle,
  storage: Waffle.Storage.AliyunOss,
  bucket: {:system, "ALIYUN_OSS_BUCKET"}

Along with any configuration necessary for Aliyun.Oss.

Aliyun.Oss is used to support Aliyun OSS.

To store your attachments in Aliyun OSS, you'll need to provide necessary configs(bucket, endpoint, and credentials) in your application config:

config :waffle,
  bucket: "uploads",
  endpoint: "some.endpoint.com",
  access_key_id: "ALIYUN_ACCESS_KEY_ID",
  access_key_secret: "ALIYUN_ACCESS_KEY_SECRET"

You may also set them from an environment variable:

config :waffle,
  bucket: {:system, "OSS_BUCKET"},
  endpoint: {:system, "OSS_ENDPOINT"},
  access_key_id: {:system, "ALIYUN_ACCESS_KEY_ID"},
  access_key_secret: {:system, "ALIYUN_ACCESS_KEY_SECRET"}

You can set them in the uploader definition file to override the global configurations like this:

def bucket, do: "some_custom_bucket_name"
def endpoint, do: "some_custom_endpoint"
def access_key_id, do: "your_aliyun_access_key_id"
def access_key_id, do: "your_aliyun_access_key_secret"

access-control-permissions

Access Control Permissions

Waffle defaults all uploads to default(Inherit from the bucket). In cases where it is desired to have your uploads public, you may set the ACL at the module level (which applies to all versions):

@acl :public_read

Or you may have more granular control over each version. As an example, you may wish to explicitly only make public a thumbnail version of the file:

def acl(:thumb, _), do: :public_read

Supported access control lists for Aliyun OSS are:

ACLPermissions Added to ACL
:defaultInherit from the Bucket ACL.
:privateOwner gets FULL CONTROL. No one else has access rights (default).
:public_readOwner gets FULL CONTROL. The others get READ access.
:public_read_writeOwner gets FULL CONTROL. The others get READ and WRITE access.
Granting this on a bucket is generally not recommended.

For more information on the behavior of each of these, please consult Aliyun's documentation for ACL.

Link to this section Summary

Link to this section Functions

Link to this function

delete(definition, version, arg)

Link to this function

put(definition, version, arg)

Link to this function

url(definition, version, file_and_scope, options \\ [])