-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
163 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: Not found pages redirected to index | ||
As a user | ||
I want to be redirected to the index page when I navigate to a non existent page url | ||
So that I use the app | ||
|
||
Scenario: Upload File | ||
When I visit the path "/404" | ||
Then I expect the page "div" with "banner-content" to contain the text "Welcome to File Upload Hub" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from dependency_factory import dependencies | ||
|
||
celery = dependencies.celery(__name__) | ||
celery = dependencies.celery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
17 changes: 13 additions & 4 deletions
17
s3fileuploader/src/services/aws.py → s3fileuploader/src/tasks/upload.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
from io import BytesIO | ||
import logging | ||
import os | ||
from typing import Callable | ||
|
||
from boto.s3.connection import S3Connection | ||
from botocore.exceptions import ClientError | ||
from celery import Task | ||
|
||
from utils.lock import Lock | ||
|
||
LOG = logging.getLogger("app") | ||
|
||
class AwsS3Service: | ||
|
||
class UploadTask(Task): | ||
def __init__(self, s3: S3Connection, lock_provider: Callable[[str], Lock]): | ||
self.name = "AwsS3Service" | ||
self.s3: S3Connection = s3 | ||
self.lock_provider = lock_provider | ||
|
||
def upload_file(self, content: BytesIO, filename: str, bucket: str): | ||
def run(self, *args, **kwargs): | ||
path, filename, bucket = args | ||
with self.lock_provider(filename): | ||
try: | ||
self.s3.head_bucket(Bucket=bucket) | ||
except ClientError: | ||
self.s3.create_bucket(Bucket=bucket) | ||
self.s3.upload_fileobj(content, bucket, filename) | ||
LOG.info("Uploading file %s", filename) | ||
self.s3.upload_file(path, bucket, filename) | ||
os.remove(path) | ||
LOG.info("Uploaded file %s successfully", filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.