Comments (2)
That's not really how the class was meant to work. You will have to download the file first.
from amazon-s3-php-class.
yes i figured after more playing around with it. I used inputResource instead. Here's a function for anyone who's looking (i am a poor programmer but it works)
function copy_remote_img($fileURL,$fileNewName)
{
$bucketName = "your-bucket";
ini_set('max_execution_time', 600);
$picRemote = $fileURL;
$picLocal = "images_users/".$fileNewName."_foto_fb.jpg";
$data = file_get_contents($picRemote)
or die("We cannot write in the local file");
file_put_contents($picLocal, $data)
or die("We cannot write in the local file");
$theSize = filesize($picLocal); // Get size (bytes)
$temp = getimagesize($picLocal);
$theMime = $temp['mime'];
//include the S3 class
if (!class_exists('S3'))require_once('S3.php');
//AWS access info
if (!defined('awsAccessKey')) define('awsAccessKey', 'yourKey);
if (!defined('awsSecretKey')) define('awsSecretKey', 'yourSkey');
$s3 = new S3(awsAccessKey, awsSecretKey); //instantiate the class
$input = $s3->inputResource(fopen($picLocal, "rb"), $theSize);
$input['type'] = $theMime;
$fileS3Name = $fileNewName."_foto_fb.jpg";
if (S3::putObject($input, $bucketName, $fileS3Name, S3::ACL_PUBLIC_READ)) {
$imgURL = "http://".$bucketName.".s3.amazonaws.com/".$fileS3Name;
return $imgURL;
} else {echo "Failed to upload file.";}
}
from amazon-s3-php-class.
Related Issues (20)
- S3.php uses AWS API that will be deprecated on June 6th 2019
- SignatureDoesNotMatch error HOT 2
- Easy fix for getObjectInfo bug
- Missing setSignatureVersion function HOT 1
- Issue on uploading in Asia Mumbai region bucket.
- S3.php is huge and is becoming unmanageable :(
- putObject problem
- AuthorizationHeaderMalformed: the region 'us-east-1' is wrong; expecting 'ap-northeast-1' HOT 3
- Access denied on deleteObject
- error messages
- Could I prevent invalidation?
- ListBuckets does not work on non-amazon services HOT 12
- Install region eu-west-1 default
- Does it support tagging? HOT 1
- Haveing 2 buckets in the same region
- Deprecated: Array and string offset access syntax with curly braces
- openssl_free_key() is deprecated in PHP8
- De-static-ified version of S3 with tagging
- PHP 8 Issues HOT 2
- How To Get Public URL Of Object After Uploading A File Object?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-s3-php-class.