-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* HEXA-261 Users should be able to upload files from the catalog (s3) WIP * HEXA-261 Users should be able to upload files from the catalog (s3) Working POC * HEXA-261 Users should be able to upload files from the catalog (s3) Working POC * HEXA-261 Users should be able to upload files from the catalog (s3) Simpler UI * HEXA-261 Users should be able to upload files from the catalog (s3) Upload in folders too * Lint * Cleanup * HEXA-261 Users should be able to upload files from the catalog (s3) Basic api tests * HEXA-261 Users should be able to upload files from the catalog (s3) Basic api tests
- Loading branch information
1 parent
0061210
commit 7a7c25f
Showing
19 changed files
with
306 additions
and
49 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
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
17 changes: 17 additions & 0 deletions
17
hexa/plugins/connector_s3/templates/connector_s3/components/upload.html
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,17 @@ | ||
{% load i18n %} | ||
|
||
<div | ||
class="flex justify-end items-center" | ||
> | ||
<form action="#" method="POST" x-ref="form"> | ||
<label | ||
for="file-upload" | ||
class="inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 cursor-pointer" | ||
> | ||
{% trans "Upload a file" %} | ||
<span x-show="!uploading">{% include "ui/icons/upload.html" with ml=2 %}</span> | ||
<span x-show="uploading">{% include "ui/icons/refresh.html" with ml=2 spin="true" %}</span> | ||
<input x-ref="input" id="file-upload" name="file-upload" type="file" class="sr-only" @change="onChange"> | ||
</label> | ||
</form> | ||
</div> |
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,52 @@ | ||
import boto3 | ||
from django import test | ||
from moto import mock_s3, mock_sts | ||
|
||
from hexa.plugins.connector_s3.api import generate_download_url, generate_upload_url | ||
from hexa.plugins.connector_s3.models import Bucket, Credentials, Object | ||
|
||
|
||
class ApiTest(test.TestCase): | ||
bucket_name = "test-bucket" | ||
|
||
def setUp(self): | ||
self.credentials = Credentials.objects.create( | ||
username="test-username", | ||
role_arn="test-arn-arn-arn-arn", | ||
default_region="eu-central-1", | ||
) | ||
self.bucket = Bucket.objects.create(name=self.bucket_name) | ||
|
||
@mock_s3 | ||
@mock_sts | ||
def test_generate_download_url(self): | ||
s3_client = boto3.client("s3") | ||
s3_client.create_bucket(Bucket="test-bucket") | ||
s3_client.put_object(Bucket="test-bucket", Key="test.csv", Body="test") | ||
|
||
target_object = Object.objects.create( | ||
bucket=self.bucket, key="test.csv", size=100 | ||
) | ||
|
||
self.assertIsInstance( | ||
generate_download_url( | ||
principal_credentials=self.credentials, | ||
bucket=self.bucket, | ||
target_object=target_object, | ||
), | ||
str, | ||
) | ||
|
||
@mock_s3 | ||
@mock_sts | ||
def test_generate_upload_url(self): | ||
s3_client = boto3.client("s3") | ||
s3_client.create_bucket(Bucket="test-bucket") | ||
self.assertIsInstance( | ||
generate_upload_url( | ||
principal_credentials=self.credentials, | ||
bucket=self.bucket, | ||
target_key="test.csv", | ||
), | ||
str, | ||
) |
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
Oops, something went wrong.