Solved

subdirectories in Amazon s3

Posted on 2006-11-29
5
732 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
  • 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decrypt string by php 7 48
What does != "" mean in programming 8 82
What does this formatting equate to? 7 18
Wordpress Security 29 49
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

830 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