ZF-6648: Amazon S3 StreamWrapper - is_dir Funktion

Description

Hi,

ive tested the Amazon_S3 StreamWrapper and this works fine. But now, i would like to realize a direct Upload to the Amazon Storage, but to Upload a file, Zend_File checks the Destination Directory and this won´t work with the StreamWrapper.

$s3 = new Zend_Service_Amazon_S3(*****) $s3->registerStreamWrapper("s3"); [...] $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination('s3://test-test-f/'); ( The bucket exist, checked with S3Fox. I also grant all rights in the ACL to everyone. )

This throws an exception, that the destination is not a directory.

Did i make a mistake or it is not implemented yet ?

Comments

I´ve found the Issue.

There is a Problem with the backslash in the "_getNamePart" function.

I cant use this: "is_dir('s3://test-test-f)" cause the index "path" is undefined.

But when i use this: "is_dir('s3://test-test-f/')" the function return 2 slashes. string(12) "test-test-f//" and url_stat wont work.

The main problem, that i cant use is_dir() is, thats the mode is not set. ($stat['mode'] = 0;)

Quote from cellog at php dot net 13-Apr-2005 04:45 :

"url_stat() must define mode, or is_file()/is_dir()/is_executable(), and any of those functions affected by clearstatcache() simply won't work. It's not documented, but directories must be a mode like 040777 (octal), and files a mode like 0100666. If you wish the file to be executable, use 7s instead of 6s. The last 3 digits are exactly the same thing as what you pass to chmod. 040000 defines a directory, and 0100000 defines a file. "

Assigning to Stas.

the slash issue should be already fixed and I've checked in the fix for is_dir issue.

This is still an issue. It look like we are not able to directly upload to S3. * The url_stat() code to detect folder/bucket vs. file often mix up: ** Example : 's3://bucketName/subfolder/' result in a file mode 's3://bucketName/file' is converted to 'bucketName\file' which result in a folder mode because '/' is not the Windows DIRECTORY_SEPARATOR

So query return error 404 most of the time.

file_put_contents('s3://BucketName/SubFolder/item.html', $data); work correctly so i will manualy update the file until it is fixed.