How can I use Java upload a folder to AWS S3? - java

I checked the document and the code examples. However, I just found the way to upload a file. If I set the file path be a folder, the program would return exception:
Exception in thread "main" com.amazonaws.SdkClientException: Unable to calculate MD5 hash: /path/to/folder (Is a directory)
I noticed that C# code example has a way to upload folder, but Java doesn't. Does it mean Java cannot upload folder to AWS S3?

The Amazon S3 API only supports uploading one object per API call. There is no API call to upload a folder.
Your code would need to loop through each file in the folder and upload them individually.

Related

AWS File Upload to S3 with Java

I am trying to upload files into my S3 bucket using AWS Lambda in Java and i'm having some issues.
I am using APIGatewayProxyRequestEvent in my AWS Lambda function to get my file upload from Postman.
request.getBody() method of this event gives me a String representation of the image file whereas the S3.putObject takes as input an InputStream of the file to be uploaded.
How can I feed in request.getBody() to the S3.putObject() method in my Lambda code to make the File Upload work?
1) You may create a File and using FileWriter you may write the request.getBody() into it.
2) You can go with PutObjectRequest object and put file created in Step1 into it.
3) s3Client.putObject(PutObjectRequest) will help you to put object to s3

Upload file From AWS s3 bucket

I need help with getting file from AWS S3 bucket.What I want is when I click file browse to browse the file,till now I was uploading file through my local disk.But now what I want is when I click browse,it should show me to upload file from s3 bucket.I want this functionality to validate my files on s3 bucket according to some validations.Through local files,It's much easier but now need solution over uploading from AWS S3.How can I accomplish this?I am stuck.
Any help would be very much appreciable.
If you are doing this from the console, and the other S3 bucket (that you want to upload from) is in your account, you can simply copy from that bucket and paste it in this bucket of yours.

Play Framework file upload to in memory to S3

I am writing a web server with Play framework 2.6 in Java. I want to upload a file to WebServer through a multipart form and do some validations, then upload the file s3. The default implementation in play saves the file to a temporary file in the file system but I do no want to do that, I want to upload the file straight to AWS S3.
I looked into this tutorial, which explains how to save file the permanently in file system instead of using temporary file. To my knowledge I have to make a custom Accumulator or a Sink that saves the incoming ByteString(s) to a byte array? but I cannot find how to do so, can someone point me in the correct direction?
thanks

Transfer byte stream to HDFS using JAVA

Is it possible to upload a file using some web-service directly to HDFS space. I tried to write file in to local system and moved it to HDFS.
WebHDFS provides REST APIs to support all the filesystem operations.
Direct uploading is not possible though.
It has to follow 2 steps
Create File in the hdfs location http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=CREATE
Write to that file - by specifying your local file path tat u want to upload in the Header http://<DATANODE>:<PORT>/webhdfs/v1/<PATH>?op=CREATE
Refer APIs here WebHDFS apis

Writing file from PHP page android

In my project a compressed file is displayed on a php in bytes.
I am trying to find a way to read the php page, decompress the file using GZIP, and write it out to the assets folder.
The file that I am reading in has to be placed in the data/data/package/database file.
I have a class that reads a file from the assets folder and places the file into data/data/package/database.
Is it possible to write to the assets folder during runtime? If not is there a better way to do this?
if the PHP script is running on a server, your Android app will need to make an HTTP request to retrieve the content. of course then it has to store it somewhere. the SQLite database is a good option, but you could also store content in files on the SD card.
there are a couple ways to do the HTTP connection part of it, and they're written up on the Android Dev Blog. Myself, I prefer the HttpURLConnection.

Categories