Cannot move local file to mounted s3 drive? PHP

I am using s3fs to mount an amazon s3 drive to my filesystem. When I use PHP's rename() function to move a local file to the mounted drive nothing happens. Is rename() okay to use for this?

$tempfile = $_SERVER['DOCUMENT_ROOT'].'/temp.png';
rename($tempfile,'/mnt/test.png');

Above code is not working for me. The drive appears to be mounted as I can see its files.

It turns out it was a permission problem - I fixed it with the "allow_other" option for s3fs, but now I am getting this php error while using rename():

failed to open stream: Input/output error 

Answers


You can't rename files across filesystems in general. You'll have to copy the file, then delete the original. (The issue doesn't arise with mv because it automatically detects the situation and does the whole copy/delete thing.)


I have had a similar problem, but I was using Java. Since it s3fs emulates a filesystem it's impossible to copy the file from one fs to the other.

I had to write two copies of the file; one directly to local fs and then one to the emulated drive.


Found this gem here - and that solved my "Input/output error" when trying to upload files to my mounted S3 bucket:

Recently, I ran into the infamous "Input/output error" on a new install of r188. The S3 bucket was fine, and everything else correct, but still was not working.

It took quite a while to discover that my problem had to do with the "+" character that was part of the secretAccessKey.

I created a new access key, and substituted that info into the /etc/passwd-s3fs file and all started working.


Need Your Help

Not able to launch Android Hybrid app using Salesforce Mobile SDK

android mobile salesforce hybrid-mobile-app

When I run a project created using forcedroid, I am getting following error in logcat of my ADT.