php - Amazon pre signed url, allow only certain file types? -
i need use s3 store content users , govern access, in social network type of service.
so far have thought of doing:
- client tells lamp server wants upload file
- lamp authenticates, , generates presigned url s3 user can upload. creates encrypted version of key using private key. adds key, along user started in mysql table(along when started)
- lamp sends key , digital signature 2. client.
- client uploads file s3
- after finishing, tells lamp that file completed. sends in key , digital signature.
- lamp makes sure both key , signature match. if do, lamp knows client honest key being given him(and has not randomly generated it)
- lamp checks s3 make sure file key exists, if does,then delete row added in 2.
my question is:
- does above data flow have serious flaw, inefficiency ?
- how make sure user allowed upload valid files(like png,jpg,pdf etc).i believe checking extension not enough may changed
i wouldn't let clients upload s3 directly. upload file server, can validation on (and you're correct, a file extension check not sufficient). then, once file validated, send file on s3 yourself. way not abandon control on process.
Comments
Post a Comment