arvindr21 / blueimp-file-upload-expressjs

A simple express module for integrating jQuery File Upload.
http://expressjs-fileupload.cloudno.de/
104 stars 69 forks source link

some AWS S3 problem #31

Open GinoToo opened 9 years ago

GinoToo commented 9 years ago

Hi i am using this for my uploader, all will go the AWS S3 when i try it i have some problem

  1. when read the file form AWS the URL is not work the error is The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

then i change the code in the index.js line 250 to url: (options.useSSL ? 'https:' : 'http:') + '//' + options.storage.aws.bucketName + '.s3-' + options.storage.aws.region + '.amazonaws.com/' + o.Key

them is can display correct, is that ok ?

  1. when post to aws that is no any thumbnail.

3.for the tmpDir the file will upload to it, those file will delete ?

thx Gino

mycaule commented 9 years ago

GinoToo,

Thank you.

arvindr21 commented 9 years ago

Hello,

To answer your questions,

1 : This is same as https://github.com/arvindr21/blueimp-file-upload-expressjs/issues/16 the solution is set to the bucket name and point to region if you know. If not, leave the region out. Just in case, can you please post the config and options?

2 : As of now thumbnails are only supported in server uploads. I will need to implement this next.

3 : Looks like the delete logic is missing for AWS. Thanks for bringing it to the notice. Will fix this too.

-- Thanks.

mycaule commented 9 years ago

I think the region is mandatory. I didn't have good results on a clean installation. I tried :

In my case setting region:'eu-west-1' and changing the get URL here to this line below solved all the problems (GET and DELETE).

url: (options.useSSL ? 'https:' : 'http:') + '//s3-'+ options.storage.aws.region+'.amazonaws.com/' + options.storage.aws.bucketName + '/' + o.Key         

A simple way to know what the region is, is to go to your Amazon S3 Managment Console with your browser and to get the parameter value in the URL.

GinoToo commented 9 years ago

hi arvindr21

reference for #16

http(s)://<bucket>.s3.amazonaws.com/<object>
http(s)://s3.amazonaws.com/<bucket>/<object>

for me also only work for the first one

http(s)://<bucket>.s3.amazonaws.com/<object>

no need to use the region

the code look like

url: (options.useSSL ? 'https:' : 'http:') + '//' + options.storage.aws.bucketName + '.s3.amazonaws.com/' + o.Key

here is my option

var options = {
    tmpDir:  __dirname + '/../assets/uploaded/tmp',
    uploadUrl:  '/uploaded/files/',
    maxPostSize: 11000000000, // 11 GB
    minFileSize:  1,
    maxFileSize:  10000000000, // 10 GB
    acceptFileTypes:  /.+/i,
    // Files not matched by this regular expression force a download dialog,
    // to prevent executing any scripts in the context of the service domain:
    inlineFileTypes:  /\.(gif|jpe?g|png)$/i,
    imageTypes:  /\.(gif|jpe?g|png)$/i,
    imageVersions: {
        width:  80,
        height: 80
    },
    accessControl: {
        allowOrigin: '*',
        allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE',
        allowHeaders: 'Content-Type, Content-Range, Content-Disposition'
    },
    nodeStatic: {
        cache:  3600 // seconds to cache served files
    },
     storage : {
        type : 'aws',
         aws : {
            accessKeyId :  'XXXXXXXXXXXXXXXXXXXXXXXX',
            secretAccessKey : 'XXXXXXXXXXXXXXXXXXXXXXXX',
            bucketName : 'XXXXXXXXXXXXXXXXXXXXXXXX'
        }
    }
};