아래와 같은 방법으로 PHP에서 S3CMD를 통해 S3에 파일을 옮기려고 할 때, 오류 없이 동작하는 것 같은데 파일이 옮겨지지 않더군요.
(I failed to move file to s3 with code below.)
<?php // test.php $ret = exec("s3cmd put ./test.dat s3://testbucket.mine/test/"); echo $ret; ?>
쉘에서 php test.php 를 실행하면 잘 동작합니다.
하지만, 웹브라우저나 REST API 호출 도구를 통해 실행하면 파일이 옮겨지지 않았습니다.
"s3cmd --configure"를 처음 실행해서 설정하면 설정파일이 만들어집니다만, 그 파일을 찾지 못하는 것 같았습니다.
이에, 아래와 같이 실행을 해 보았습니다.
(I tried to move the file to s3 with the code below, but I failed again.)
<?php $ret = exec("/usr/bin/s3cmd --config=/somewhere/.s3cfg put test.dat s3://testbucket/test/"); echo $ret; ?>
즉, .s3cfg파일의 위치를 명시적으로 지정해 주었습니다. 하지만, 동작하지 않더군요ㅠㅠ (-c 옵션도 마찬가지 였습니다)
그래서, 파라메터 정보를 좀 더 훑어 보다가 그럴싸한 두놈을 골라 다시 아래와 같이 실행을 했더니- 잘 동작했습니다! LoL
(Finally, I succeeded using the code below.)
<?php $ret = exec("s3cmd --access_key=MY_ACCESS_KEY --secret_key=MY_SECRET_KEY put test.data s3://testbucket.mine/test/"); echo $ret; ?>
건투를 빕니다~^^
Good Luck !