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:

  1. client tells lamp server wants upload file
  2. 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)
  3. lamp sends key , digital signature 2. client.
  4. client uploads file s3
  5. after finishing, tells lamp that file completed. sends in key , digital signature.
  6. lamp makes sure both key , signature match. if do, lamp knows client honest key being given him(and has not randomly generated it)
  7. 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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -