Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature mismatch error for S3Store #122

Open
ghisvail opened this issue Oct 29, 2019 · 2 comments
Open

Signature mismatch error for S3Store #122

ghisvail opened this issue Oct 29, 2019 · 2 comments

Comments

@ghisvail
Copy link

I am trying to store a docx file in S3 and its query metadata in postgres using sqlalchemy-media. My S3 provider is not AWS. I use Minio for testing and a private cloud provider, both of which are advertised as "S3 compatible".

However, my attempts so far have failed with the following signature mismatch error:

The request signature we calculated does not match the signature you provided. Check your Secret Access Key and signing method.

It works fine if I provide an alternative store backed by the filesystem instead, so I suppose the issue has to be with the S3 store rather than the model.

My model looks similar to this:

from sqlalchemy_media import File

class MyDocument(File):
    __directory__ = "my-directory"
    __prefix__ = "my-document"

class MyReport(Base):
    __tablename__ = "my_report"
    id = Column(Integer, primary_key=True, autoincrement=True)
    year = Column(Integer, nullable=False)
    document = Column(MyDocument.as_mutable(JSON), nullable=False)

And the store setup:

from sqlalchemy_media import StoreManager
from sqlalchemy_media import S3Store, FileSystemStore

def get_s3_store():
    return S3Store(
        bucket=None,  # Bucket name prefixed to endpoint
        access_key=my_access_key,
        secret_key=my_secret_key,
        region=None,  # No region support, also tried with eu-west-1
        base_url=some_base_url,
        prefix=my_bucket_name,
    )

def get_fs_store():
    return FileSystemStore(
        root_path="/tmp/sqlalchemy-media",
        base_url="static.mydomain.com",
    )

# File upload works with this setup
StoreManager.register("fs", get_fs_store, default=True)

# File upload fails with this setup
StoreManager.register("s3", get_s3_store, default=True)
@ghisvail ghisvail changed the title Signature mismatch error for S3Store with Minio Signature mismatch error for S3Store Oct 29, 2019
@ghisvail
Copy link
Author

Worth noting that a similar implementation using depot works fine.

@ghisvail
Copy link
Author

I believe a key differentiator between the S3 implementation in sqlalchemy-media and depot is the latter uses boto3 instead of requests-aws4auth, which is no longer maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant