Solved

subdirectories in Amazon s3

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Download a website to hdd 2 48
converting numbers with php 3 26
Checking if varaible is empty 6 25
PHP: Insert Data into MySQL 5 7
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
The viewer will learn how to count occurrences of each item in an array.
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…

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now