Uploading files to Amazon S3 from Meteor

Hi
Recently I started working on an app based on Meteor platform.i want to upload files to amazon s3 from my meteor app .
i have the s3.config details.
where should i place the config details

what should be wriiten on client side to talk with s3 server .??
setup??

any help?

thanks a lot in advance.

Do a little search, this has been discussed numerous times on this forum.

Either way, most people will likely suggest slingshot: https://atmospherejs.com/edgee/slingshot

1 Like

hi thanks for your reply @nlammertyn .Iam using lepozepo-s3 .

i was struck with this error
XMLHttpRequest cannot load https://s3-us-west-2.amazonaws.com/fictest. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:3000’ is therefore not allowed access.

do you have any idea??

thanks

Did you see https://themeteorchef.com/tutorials/uploading-files-to-amazon-s3? It was very helpful and detailed.

hey thanks for the reply @townmulti .
i will look into it. do you have any idea about the error which iam facing ?

XMLHttpRequest cannot load https://s3-us-west-2.amazonaws.com/fictest. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:3000’ is therefore not allowed access.

I’m guessing you didn’t properly set up your bucket policies?

thanks for your reply @vigorwebsolutions.Iam using lepozepo meteor package .i follwed the steps as mentioned here


my bucket policy :

{
“Version”: “2008-10-17”,
“Statement”: [
{
“Sid”: “AllowPublicRead”,
“Effect”: “Allow”,
“Principal”: {
“AWS”: “"
},
“Action”: [
“s3:GetObject”,
“s3:PutObject”
],
“Resource”: "arn:aws:s3:::test/
”
}
]
}

What does your CORS config look like for your bucket?

Also, you may need to set the region in your S3.config definition.

here is my CORS config

i set the location in s3.config too.

i have placed my s3.config in server side lib folder .

Can you try <AllowedOrigin>*</AllowedOrigin> – this will at least help you determine where the problem is coming from.

Getting this in console

XMLHttpRequest cannot load https://s3-us-west-2.amazonaws.com/test. Response for preflight has invalid HTTP status code 301

Now I’m stumped. A quick google search shows it may be a browser issue? Maybe give FF a shot, as I’m guessing you’re on chrome?

yes iam on chrome @vigorwebsolutions .

In FF iam not getting the error which i got in chrome …but file not uploaded
In EDGE iam getting :

XMLHttpRequest: Network Error 0x800c0008, The download of the specified resource has failed.

Did you try the allow all cors policy?

my cors config

Try this and see if you can at least connect with that permission setting.

thanks for your reply @vigorwebsolutions.
i have tried the way you suggested but got the same error :frowning: .

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. iam getting this message in network

And in your server startup, you have the region set as us-west-2?

S3.config = {
    key: 'yourKey',
    secret: 'yourSecret',
    bucket: 'yourBucketName',
    region: 'us-west-2', // This is the line you need.
};
1 Like