Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:08:43+00:00 2026-06-07T18:08:43+00:00

I am familiar with AWS Java SDK , I also tried to browse the

  • 0

I am familiar with AWS Java SDK, I also tried to browse the corresponding Javadoc, but I could not realize how do I create a sub directory, i.e., a directory object within a bucket, and how do I upload files to it.

Assume bucketName and dirName correspond to already existing bucket (with public permission) and a new (object) directory which needs to be created within the bucket (i.e. bucketName/dirName/)

I have tried the following:

AmazonS3Client s3 = new AmazonS3Client(
    new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY));
s3.createBucket(bucketName + "/" + dirName); //throws exception

which throws an exception on the second line.

A short snippet which creates a sub-directory and uploads files to it will be deeply appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:08:44+00:00Added an answer on June 7, 2026 at 6:08 pm

    There are no “sub-directories” in S3. There are buckets and there are keys within buckets.

    You can emulate traditional directories by using prefix searches. For example, you can store the following keys in a bucket:

    foo/bar1
    foo/bar2
    foo/bar3
    blah/baz1
    blah/baz2
    

    and then do a prefix search for foo/ and you will get back:

    foo/bar1
    foo/bar2
    foo/bar3
    

    See AmazonS3.listObjects for more details.


    Update: Assuming you already have an existing bucket, the key under that bucket would contain the /:

    s3.putObject("someBucket", "foo/bar1", file1);
    s3.putObject("someBucket", "foo/bar2", file2);
    ...
    

    Then you can list all keys starting with foo/:

    ObjectListing listing = s3.listObjects("someBucket", "foo/");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not very familiar with the OAuth flow and/or encoding, but I've managed
I'm not familiar at all with the process behind this, but what I would
That sounds familiar I'm sure, but it's not a CSS hack issue. I'm literally
I'm familiar with packages from e.g. Java and Lisp, but what I'm seeing in
i'm quite familiar with Java, not so in C. In Java, if i have
We're generally familiar with code smells here, but just as damaging if not more
I'm not familiar with wpf or C# language, but I want to generate xaml
I'm not too familiar with Perl, but I am using it for a simple
This question may sound familiar but not quite the same as asked before. I
I am not terribly familiar with either tech, so bear with me. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.