Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

subdirectories in Amazon s3

Posted on 2006-11-29
5
Medium Priority
?
736 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 1000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

610 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