PHP Classes

Putting Files...

Recommend this page to a friend!

      Amazon S3 Stream Wrapper  >  All threads  >  Putting Files...  >  (Un) Subscribe thread alerts  
Subject:Putting Files...
Summary:Putting Files on S3 server....
Messages:9
Author:Scott Phillips
Date:2007-12-23 21:38:48
Update:2008-10-27 03:01:38
 

  1. Putting Files...   Reply   Report abuse  
Picture of Scott Phillips Scott Phillips - 2007-12-23 21:38:48
I didn't see in the example if there is a simple way to put a file on the server. Is there some sort of put command, if I wanted to copy a local file to the s3 server?

Thanks!

  2. Re: Putting Files...   Reply   Report abuse  
Picture of Cesar D. Rodas Cesar D. Rodas - 2007-12-23 22:53:24 - In reply to message 1 from Scott Phillips
Hello,

The easiest way is:

<?
set_time_limit(0);
include("gs3.php");
/* fake keys!, please put yours */
define('S3_KEY', 'DA5S4D5A6S4D');
define('S3_PRIVATE','adsadasd');
buckets

/* creating a bucket or folder */
$e=mkdir('s3://YOUR_BUCKET',_PUBLIC_READ);

file_put_contents("s3://YOUR_BUCKET/your_file.jpg", file_get_contents("local/file.jph") );

?>

  3. Re: Putting Files...   Reply   Report abuse  
Picture of Scott Phillips Scott Phillips - 2007-12-30 22:08:51 - In reply to message 2 from Cesar D. Rodas
Awesome, thanks.

For backup purposes, is there anyway to send it a directory, and have it recursively create the subdirectories and files onto s3?

So for example I could pass it the root folder for my website, and it would then mirror the whole thing up on Amazon's server?

Or would I need to write something to loop through all the items and stream/create them up there...

thanks.

  4. Re: Putting Files...   Reply   Report abuse  
Picture of bivek bivek - 2008-03-28 03:20:19 - In reply to message 2 from Cesar D. Rodas
While i tried to create the directory it give error as follows:
========================================================
ERROR

The requested URL could not be retrieved


While trying to process the request:

PUT /UBAtest HTTP/1.1
Host: s3.amazonaws.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
x-amz-acl: public-read
Date: Fri, 28 Mar 2008 3:06:01 GMT
Authorization: AWS 0ZQZPQ52AJABAXWAYTG2:3v+Q2wQQvn2eOX+f/QqEc5Vn/KA=



The following error was encountered:

* Invalid Request



Some aspect of the HTTP Request is invalid. Possible problems:

* Missing or unknown request method
* Missing URL
* Missing HTTP Identifier (HTTP/1.0)
* Request is too large
* Content-Length missing for POST or PUT requests
* Illegal character in hostname; underscores are not allowed

========================================================
Can you please help me reply me.
My email: bivek.uba@gmail.com



  5. Re: Putting Files...   Reply   Report abuse  
Picture of Cesar D. Rodas Cesar D. Rodas - 2008-03-28 20:37:22 - In reply to message 4 from bivek
Hello,

What is the error text that you have?

Regards.

  6. Re: Putting Files...   Reply   Report abuse  
Picture of bivek bivek - 2008-03-30 03:34:17 - In reply to message 5 from Cesar D. Rodas
The error text is as follows:

Amazon Said:
ERROR

The requested URL could not be retrieved


While trying to process the request:

PUT /UBAtest HTTP/1.1
Host: s3.amazonaws.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
x-amz-acl: public-read
Date: Fri, 28 Mar 2008 3:06:01 GMT
Authorization: AWS 0ZQZPQ52AJABAXWAYTG2:3v+Q2wQQvn2eOX+f/QqEc5Vn/KA=



The following error was encountered:

* Invalid Request



Some aspect of the HTTP Request is invalid. Possible problems:

* Missing or unknown request method
* Missing URL
* Missing HTTP Identifier (HTTP/1.0)
* Request is too large
* Content-Length missing for POST or PUT requests
* Illegal character in hostname; underscores are not allowed

  7. Re: Putting Files...   Reply   Report abuse  
Picture of bivek bivek - 2008-03-30 03:43:13 - In reply to message 5 from Cesar D. Rodas
I have copied and pasted all the errors above.

I think that the error is "Invalid Request".

  8. Re: Putting Files...   Reply   Report abuse  
Picture of Cesar D. Rodas Cesar D. Rodas - 2008-03-30 06:46:42 - In reply to message 7 from bivek
Can you put your PHP Script?

It is missing the Content-Lenght, but I want to figure out when that occure.

Thank you.

  9. put directory??   Reply   Report abuse  
Picture of yanyan yanyan - 2008-10-27 03:01:38 - In reply to message 8 from Cesar D. Rodas
For backup purposes, is there anyway to send it a directory, and have it recursively create the subdirectories and files onto s3?

So for example I could pass it the root folder for my website, and it would then mirror the whole thing up on Amazon's server?

Or would I need to write something to loop through all the items and stream/create them up there...

thanks.