I'm using S3 for storing generated HTML and JS files (from an EC2 instance).
I'm trying to make AJAX requests from these JS files to my PHP files on my EC2 instance.
So, I've added this line to my htaccess:
Header set Access-Control-Allow-Origin *
When I test locally, AJAX requests are made from S3 to my localhost, it works perfectly.
But when I try to make these requests to EC2 I get the "not allowed by Access-Control-Allow-Origin" message...
Does anyone know if it's possible to do such a thing ?
If not is there anyway to dynamically load content to S3 files ?
Thanks
Related
I need your help or get some Idea in doing the Integration of s3 through a third party vendor application. I have some issues that I am not able to resolve, since I am not an expert with the Amazon s3 stuff.
So I have an application that is called Medallia and I am trying to perform a feed pull to export or download a file which is uploaded into the s3 bucket. I was able to figure out how to upload the file to the s3 bucket, but I am stuck on downloading the files or (feed pulling) the file to the app
I have added the information below for you to review!
Amazon s3 (Vendor Application Settings)
pull method: Amazon s3
Feedpull: feedpull.va.dev.us-west-1.medallia
Amazon s3 access Key: AKIA****(Confidential)
End Point: s3-website-us-gov-west-1.amazonaws.com
I have added the URL from where i took the end point from. I am not sure if i have to use Web or Storage. (http://docs.aws.amazon.com/govcloud-us/latest/UserGuide/using-govcloud-endpoints.html) Please inform!
Why am I doing this?
- So that I can have the files that gets uploaded to Amazon s3 bucket be pulled on schedule every end of the week to update/maintain the third party application.
Additional Info Needed (If Possible)
I need to have the python installed and have a Command to COI and then drop files on to the s3 bucket. This will help me to test the s3 Bucket (on the web services) through Automatic feed pull.
ERRORS
Before no end-point
Error while pulling feedpull. The configuration is using the wrong endpoint for the specified bucket for s3. exception: nonfatal error.
After end-point
Error while pulling feedpull: s3 Pull (feedpull I)Unable to execute HTTP request. Connect timed out. One possible cause is a malformed endpoint. nonfatal error exception.
Thank you!
The web site hosting endpoints are for unsecured, publicly-accessible content, and don't support authentication... so that isn't likely what you are looking for.
Assuming you're working in US GovCloud, you want one of the REST endpoints:
s3-fips-us-gov-west-1.amazonaws.com
s3-us-gov-west-1.amazonaws.com
The first one is FIPS 140 Level 2 compliant, so I would suggest that this is the one you want, unless you have a reason not to.
I have setup a cloudfront system for a website.
To serve of the fly picture transformation, i added a custom origin, being the website.
So, in my distribution, i have 2 origins :
- s3 bucket
- mywebsite.com/images
Wen i call cdn.mywebsite.com/500/picture.jpg
It will call my website like : website.com/api.php/file/500/picture.jpg
I get the s3 object, create the thumb, save it on server then upload to s3.
Up to here, it all works.
Now, i would like that the next request to this file does not go to my origin custom website, but to the s3 stored file.
I cannot find a way to define order of importance (weight) for multiple origins.
It seams that once frontcloud has a "route", it keeps the same one.
Any ideas ?
You cannot do multiple origins for a Cloud Front Distributions from the AWS side you have to customize this using either
Amazon CloudFront REST API
Bucket Explorer
Check this guide has both steps http://www.bucketexplorer.com/documentation/amazon-s3--how-to-create-distributions-post-distribution-with-multiple-origin-servers.html
Please help me understand the process of uploading files to Amazon S3 server via PHP. I have a website on EC2, which will have PHP script for uploading file to S3 server from client's machine. What I need to understand, is whether the file will go directly to S3 from client's machine, or if it will first be uploaded onto EC2, and then to S3. If it's the second option, then how can I optimize the upload so that file goes directly to S3 from client's machine?
It is possible to upload a file to S3 using any of the scenarios you specified.
In the first scenario, the file gets uploaded to your PHP backend on EC2 and then you upload it from PHP to S3 via a PUT request. Basically, in this scenario, all uploads pass through your EC2 server.
The second option is to upload the file directly to S3 from the client's browser. This is done by using a POST request directly to S3 and a policy that you can generate using your PHP logic, and attach it to the POST request. This policy is basically a set of rules that allow S3 to accept the upload (without it anyone would be able to upload anything in your bucket).
In this second scenario, your PHP scripts on EC2 will only need to generate a valid policy for the upload, but the actual file that's being uploaded will go directly to S3 without passing trough your EC2 server.
You can get more info on the second scenario here:
http://aws.amazon.com/articles/1434
even if it's not PHP specific, it explains how to generate the policy and how to form the POST request.
You can also get more information by reading through the API docs for POST requests:
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html
EDIT: The official AWS SDK for PHP contains a helper class for doing this: http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.Model.PostObject.html
I know you can't run PHP on Amazon S3, but is there a way to host a static site on S3 and then have a contact form that runs using PHP from another server? In essence, I'm asking if the PHP file needs to be on S3 for it to run properly?
No, the PHP file does not have to be on S3. Just put it on the other server and refer to the absolute (full) URL.
Pages can submit forms to other domains (e.g. to the PHP server). This is actually what makes CSRF possible even when a server requires POST requests.
Pages can load images, scripts, and stylesheets from other domains. In fact, it is very common for these assets to be loaded from separate servers or even third-party content delivery networks. For example, Stack Overflow loads its copy of jQuery from //ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js.
I would like to find a simple PHP script that will send a HTTP Request to my bucket in Amazon S3 and delete a file. I have found code around the web using PHP that manages S3 files, but what I am looking for is just the delete request. I already know the name of the file and the bucket, I just want to send the request to delete it.