Skip to content

Commit

Permalink
Fix to img upload http status 500 (#137)
Browse files Browse the repository at this point in the history
Env Rename and only getting the env once, Fixes this issue
  • Loading branch information
Trivinyx authored Apr 26, 2024
1 parent 12846a0 commit 4550127
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
echo "HOST_PORT=8000" > backend/.env
echo "CORS_ORIGINS='http://localhost,${{ vars.CORS_ORIGINS }}'" >> backend/.env
echo "ENVIRONMENT='production'" >> backend/.env
echo "STORAGE_TYPE='bucketeer-s3'" >> backend/.env
#TODO: add tests step
#build backend docker image
Expand Down
2 changes: 1 addition & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENVIRONMENT="development"
DATABASE_URL="postgresql://[user[:password]@][netloc][:port][/dbname]" # insert your database url here more info at https://www.postgresql.org/docs/9.2/libpq-connect.html#LIBPQ-CONNSTRING

#Storage types are: "local", "aws", "bucketeer-s3" (defaults to local if not set)
STORAGE_TYPE="local"
APP_FILE_STORAGE_TYPE="local"

# AWS S3 bucket configuration
AWS_BUCKET_NAME="bucket-name"
Expand Down
10 changes: 6 additions & 4 deletions backend/img2mapAPI/routers/georefProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,19 @@
# Default to local file storage
_Filestorage: FileStorage = LocalFileStorage()

if 'STORAGE_TYPE' in os.environ:
if 'APP_FILE_STORAGE_TYPE' in os.environ:
# Decide which file storage to use based on environment variable
if os.environ['STORAGE_TYPE'] == 'aws':
APP_FILE_STORAGE_TYPE = os.environ['APP_FILE_STORAGE_TYPE']
if APP_FILE_STORAGE_TYPE == 'aws':
_Filestorage: FileStorage = S3FileStorage(os.environ['AWS_BUCKET_NAME'], os.environ['AWS_REGION_NAME'], os.environ['AWS_ACCESS_KEY_ID'], os.environ['AWS_SECRET_ACCESS_KEY'])
print("Using AWS S3 file storage")
elif os.environ['STORAGE_TYPE'] == 'bucketeer-s3':
elif APP_FILE_STORAGE_TYPE == 'bucketeer-s3':
_Filestorage: FileStorage = S3FileStorage(os.environ['BUCKETEER_BUCKET_NAME'],os.environ['BUCKETEER_AWS_REGION'],os.environ['BUCKETEER_AWS_ACCESS_KEY_ID'],os.environ['BUCKETEER_AWS_SECRET_ACCESS_KEY'])
print("Using AWS S3 file storage through Bucketeer")
elif os.environ['STORAGE_TYPE'] == 'local':
elif APP_FILE_STORAGE_TYPE == 'local':
#This seems a bit redundant, but it is to explicitly state that local storage has been chosen
print("Using local file storage")
_Filestorage: FileStorage = LocalFileStorage()
else:
print("Defaulting to using local file storage")
else:
Expand Down

0 comments on commit 4550127

Please sign in to comment.