Download response for S3 asset? - laravel

I'm trying to generate a download response by:
return response()->download('full URL to my asset on S3 via cloudfront');
But I'm getting an error stating that the file does not exist.
I've checked the path, and it loads fine in a browser window.
How can I generate a download response for my asset on S3 via cloudfront?

Related

How to upload file to Amazon S3 pre-signed URL in Laravel?

I have a pre-signed URL generated for Amazon S3 file upload. How to upload a file to that URL in Laravel using it's HTTP Client (Preferably using the PUT method)?
After trying out several ways, I found using Curl to be the best solution.
I used the "ixudra/curl" composer package to make the HTTP PUT request.
My solution:
$response = Curl::to(url)
->withFile( 'data', path_to_file, '*' )
->withContentType('multipart/form-data')
->put();

image uploader in post free ad page is not working in osclass

I am new to Osclass. I have purchased shopclass theme. we are using jquery fine uploader plugin for image upload. when we are uploading image it shows error.
"[FineUploader 3.8.0] Error when attempting to parse xhr response text (Unexpected token < in JSON at position 61)"-this is the error shown in console.
The image is uploaded into temp folder but it does not shown in post and also shows uploading error in user end.Please help me to solve this problem.

Upload file to Amazon S3 failing only first time

I am trying to upload files to amazon s3 bucket and its failing only first time. After first time, files upload successfully. Tried many ways can’t fix it. Please help.
The error I am getting is as follows:
Exception 'ErrorException' with message 'S3::inputFile(): Unable to open input file: C:\inetpub\temp\PHPTemp\php6C81.tmp' in C:\inetpub\websites\bizitask.com\app\libraries\S3.php:355
I am using an ajax form to upload the file and code in controller to upload the file is as follows:
if ($s3->putObjectFile(Input::file('file')->getRealPath(), 'bizitask', 'files/businesses/'.$business_id.'/'.$file_name, S3::ACL_PUBLIC_READ)) { return Redirect::to('customers/businesses/' . $business_id)->with('success', 'success'); }
I am using laravel 4.2

AFNetworking 2.0: NSURLSessionDownloadTask is cancelled when received 302 to AWS S3

I'm using a simple example from the README file (from AFNetworking 2.0 page) to download an image. All works fine for the images served directly from my web-sever.
But for those located on the S3 the web-server returns 302 Redirect the following error:
Error Domain=NSURLErrorDomain Code=-999 "cancelled"
When I try to download the image (using the same code) directly from the S3 (omitting the redirection) I receive the same error.
I've checked the availability of the actual image with wget. The image is publicly available (https://youguide.s3.amazonaws.com/icons/user_96x96.png).
Anyone experience the similar problem?
I was having the same problem with S3 and seem to have resolved it. AFNetworking was returning a value in the authentication challenge handling logic that was canceling the request.
By telling the AFURLSessionManager how to handle authentication challenges I've fixed the problem.
[manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition (NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential) {
return NSURLSessionAuthChallengePerformDefaultHandling;
}];

Upload to Amazon S3 with Codeigniter

I am developing an API using Codeigniter and I want to let users upload images to my Amazon S3 account. I am using Phils Restserver and Donovan Schönknecht S3 library (for Ci).
It works perfectly to upload a local file to Amazon but how can I get the image file
sent via normal external form?
Using the built in Ci upload library it works fine but then I have to store the files
locally on my own server and I want them on S3. Can the two be combined?
I guess what I am asking is how can I "get" the image file that is sent to the controller
and resize it and then upload it to S3?
Do I perhaps need to temporary save it on the local server, upload it to S3 and then remove it from the local server?
This is my "upload" modal:
// Load the s3 library
$this->load->library('S3');
// Make the upload
if ($this->s3->putObjectFile($args['local'], "siticdev", $args['remote'], S3::ACL_PUBLIC_READ)) {
// Handle success
return TRUE;
} else {
// Handle failure
return FALSE;
}
Thankful for all input!
If I understand you correctly, you want a user to upload an image via a form, resize that image, then transfer that to Amazon S3.
You'll have to store the file locally (at least for a few seconds) to resize it with CI. After you resize it, then you can transfer it to Amazon S3. In your success callback from the transfer, you can delete the image from your server.
You should definitely check out the CI S3 library. The "spark" is available here - http://getsparks.org/packages/amazon-s3/versions/HEAD/show

Resources