Home > database >  Logic question related to file size check during implementation of aws file upload
Logic question related to file size check during implementation of aws file upload

Time:03-29

I am implementing aws file upload, does aws provide a method to check the size of a file when it is uploaded? I am developing using springboot in java. Thank you

I did a search related to aws, but it was difficult to find it by myself, so I had to post a question.

CodePudding user response:

If you are using aws sdk, you can get the size of the file in bytes by using the getSize() method in the S3ObjectSummary class after uploading the file.

See the List Objects doc or the Class S3ObjectSummary doc.

Or if you want to get the size of a file before uploading, access the file directly and get the size of the file.

File file = new File(path);
long length = file.length();
  • Related