Skip to main content

Store attachments into S3 complient filesystem

Project description

Odoo Community Association

Fs Attachment S3

Beta License: AGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

This module extends the functionality of fs_attachment to better support Amazon S3 storage. It includes features such as:

  • Special handling of X-Accel-Redirect headers for S3 storages.

  • Options for using signed URLs in X-Accel-Redirect. (This is required to be able to serve files from a private S3 bucket using X-Accel-Redirect without exposing the files publicly.)

  • Enforcing the mimetype of files stored in S3.

Table of contents

Configuration

On the Odoo instance, go to Settings > Technical > Storage > File Storage.

When you create a new storage for s3 or modify an existing one, when you activate the option “Use X-Sendfile To Serve Internal Url”, 2 additional fields will appear:

  • S3 Uses Signed URL For X-Accel-Redirect: If checked, the X-Accel-Redirect path will be a signed URL, which is useful for S3 storages that require signed URLs for access.

  • S3 Signed URL Expiration: The expiration time for the signed URL in seconds. This field is only relevant if the previous option is checked. By default, it is set to 30 seconds but it could be less since the url generated into the X-Accel-Redirect process is directly used by the web server to serve the file.

The value of these fields can also be set in the server environment variables using the keys:

  • s3_uses_signed_url_for_x_sendfile

  • s3_signed_url_expiration

When the option “Use X-Sendfile To Serve Internal Url” is enabled, the system will generate an X-Accel-Redirect header in the response to a request to get a file. In the case of S3 storages, it will follow the format:

X-Accel-Redirect: /fs_x_sendfile/{scheme}/{host}/{path with query if any}

Where:

  • {scheme}: The URL scheme (http or https).

  • {host}: The host of the S3 storage.

  • {path with query if any}: The path to the file in the S3 storage, including any query parameters. (Query parameters are set when the s3_uses_signed_url_for_x_sendfile option is enabled.)

In order to serve files using X-Accel-Redirect, you must ensure that your web server is configured to handle these headers correctly. This typically involves setting up a location block in your web server configuration that matches the X-Accel-Redirect path and proxies the request to the S3 storage.

For example, if you are using Nginx, you would add a location block like this:

location ~ ^/fs_x_sendfile/(.*?)/(.*?)/(.*) {
    internal;
    set $url_scheme $1;
    set $url_host $2;
    set $url_path $3;
    set $url $url_scheme://$url_host/$url_path;

    proxy_pass $url$is_args$args;
    proxy_set_header Host $url_host;
    proxy_ssl_server_name on;

}

Unlike the standard implementation of X-Accel-Redirect on non S3 storages, the S3 implementation does not require a base URL to be set in the storage configuration. The X-Accel-Redirect path is constructed directly from the S3 storage’s URL defined for the connection, the directory name as bucket name, and the file path.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • ACSONE SA/NV

Contributors

Other credits

The development of this module has been financially supported by:

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainer:

lmignon

This module is part of the OCA/storage project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file odoo_addon_fs_attachment_s3-19.0.1.1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_addon_fs_attachment_s3-19.0.1.1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1bc10944e144f162a6e6da4e2b81aa3b24d1f5b6d3372867e7e254d4e94d2b88
MD5 f6714818bb699b9f668eccc17d3e29d0
BLAKE2b-256 657281463495883bc99ba3f9d2a49c86831e95548d54991e53090db0767ca546

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page