quivr/backend/repository/files/generate_file_signed_url.py
Stan Girard 4a305a854e
feat: Add file URL to DocumentAnswer objects (#1874)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2023-12-12 23:16:32 +01:00

27 lines
677 B
Python

from multiprocessing import get_logger
from models import get_supabase_client
from supabase.client import Client
logger = get_logger()
SIGNED_URL_EXPIRATION_PERIOD_IN_SECONDS = 3600
def generate_file_signed_url(path):
supabase_client: Client = get_supabase_client()
try:
response = supabase_client.storage.from_("quivr").create_signed_url(
path,
SIGNED_URL_EXPIRATION_PERIOD_IN_SECONDS,
options={
"download": True,
"transform": None,
},
)
logger.info("RESPONSE SIGNED URL", response)
return response
except Exception as e:
logger.error(e)