-
Notifications
You must be signed in to change notification settings - Fork 323
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
S3 Read Access, Input Stream based reading #7776
Conversation
069f6c8
to
164c36c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only skimmed through lib changes, engine part is 👍
std-bits/base/src/main/java/org/enso/base/file_system/FileSystemSPI.java
Outdated
Show resolved
Hide resolved
057cb4b
to
c72ddc4
Compare
distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Redshift_Details.enso
Outdated
Show resolved
Hide resolved
## Gets an object from an S3 bucket. | ||
|
||
Arguments: | ||
- bucket: the name of the bucket. | ||
- key: the key of the object. | ||
- credentials: AWS credentials. If not provided, the default credentials will | ||
be used. | ||
get_object : Text -> Text -> AWS_Credential | Nothing -> Any ! S3_Error | ||
get_object bucket key credentials:(AWS_Credential | Nothing)=Nothing = handle_s3_errors <| | ||
client = make_client credentials | ||
request = GetObjectRequest.builder.bucket bucket . key key . build | ||
Panic.catch NoSuchBucketException handler=(_->Error.throw (S3_Bucket_Not_Found.Error bucket)) <| | ||
Panic.catch NoSuchKeyException handler=(_->Error.throw (No_Such_Key.Error bucket key)) <| | ||
response = client.getObject request | ||
inner_response = response.response | ||
mime_type = inner_response.contentType | ||
s3_uri = URI.parse ("s3://" + bucket + "/" + key) | ||
input_stream = Input_Stream.new response (handle_io_errors s3_uri) | ||
Response_Body.Raw_Stream input_stream mime_type s3_uri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this returns a Raw_Stream
, I assume it is an internal method, right?
In such case it should be marked as PRIVATE
. Maybe helper methods should be moved to a file separate from public API? I think we could move in that direction, it makes all a bit clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistent with the low-level HTTP request method. I will mark it ADVANCED as it should be.
Once I merge with Greg's will make the two consistently hidden.
if uri.starts_with "s3://" . not then Nothing else | ||
no_prefix = uri.drop 5 | ||
index_of = no_prefix.index_of "/" | ||
if index_of == 0 then Nothing else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't not being able to find the bucket name be an error?
distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Base_Generator.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Pgpass.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Format.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Table/0.0.0-dev/src/Excel/Excel_Workbook.enso
Outdated
Show resolved
Hide resolved
b60ef1f
to
4f23379
Compare
…detached from File.
Add support for Excel Mime Types. All reading bytes via format.
S3 get_object working.
…emSPI.java Co-authored-by: Hubert Plociniczak <hubert.plociniczak@gmail.com>
PR comments.
d2654a4
to
b24b2e7
Compare
Pull Request Description
FileSystemSPI
allowing protocol resolution to a target type.Input_Stream
andOutput_Stream
fromFile
to allow use in other spaces.File_Format
typesread_web
changed to beread_stream
working withInputStream
.Auto_Detect
allowing forData.read
to list a folder.InputStream
not abyte[]
:Response_Body
adjusted to wrap anInputStream
.Data.fetch
will materialize if not a recognized mime-type.HTTP_Error
to handle IO exceptions from the stream.Excel_Format
now supports mime-type and reading a stream.Excel_Workbook
can now get aExcel_Section
usingread_section
.parse_uri
: splits an S3 URI into bucket and key.list_objects
: list the items in a S3 bucket with specified prefix.read_bucket
: list prefixes and keys with a delimiter in a S3 bucket with specified prefix.head
: either head_bucket (tests existance) or head_object API (reads object meta data).get_object
: gets an object from S3 returning as aResponse_Body
.S3_File
type acting like aFile
:create
methods forPostgres_Connection
andSQLite_Connection
into type instead of module.Column_Fetcher.Builder
toColumn_Fetcher_Builder
.select_into
in Dry Run mode creating permanent tables.ToDo: Unit tests.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.