Solved

subdirectories in Amazon s3

Posted on 2006-11-29
5
733 Views
Last Modified: 2012-08-13
Has anyone written a function to create subdirectories for Amazon s3 in php?
I can make main directories no problem.
i.e. /myrootdir

What I am trying to do is make:
/myrootdir/subdir

I started with the php program at: http://www.neurofuzzy.net/2006/03/17/amazon-s3-php-class/
where you can download s3.class.php
and then I've written a small program to call the functions contained in the s3.class.php program.

Thanks in advance.

 
0
Comment
Question by:nhtahoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 5

Accepted Solution

by:
dasmaer earned 500 total points
ID: 18041926
Hi nhtahoe

PHP comes with a handy utility called mkdir(): http://uk.php.net/mkdir - you can normally use this to make a diretcory.  Sometimes though this has been disabled.

You may be able to make directories by passing commands directly to the terminal though.  Try:

shell_exec("mkdir mydir");

or

exec("mkdir mydir");

There are a few ways to pass commands to the OS in PHP, start looking here and see what you come up with: http://uk.php.net/exec - follow links to similar methods for more details. Quite often one of these will be left open, so that you can upload an archive and then extract it... and a simple command like mkdir isn't likely to be blocked.

Hope this helps
0
 

Author Comment

by:nhtahoe
ID: 18042011
I have no problems creating/deleting sub directories on our server using php, very easy.
However,  I need to make them on the Amazon s3 server.
0
 

Author Comment

by:nhtahoe
ID: 18042059
Thanks for the suggestion, but that does not help with AMAZON S3 which is what I need help with.  I am well aware of the mkdir() function, but it doesn't work in S3.
0
 

Author Comment

by:nhtahoe
ID: 18042324
We figured out the answer on our own.  To create directories in S3 you simply create a file with the directory structure in the name.
0
 
LVL 3

Expert Comment

by:dereck2008
ID: 23640241
Yes, there is no folder object in S3. You need to create it yourself in the filename. It could lead to issues depending on third party tool you're using. JS3Explorer is a tool that allow to simulate folders and view flat S3 objects. It could be useful for troubleshooting:
http://www.jfileupload.com/products/js3explorer/index.html
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question