java - Generating a pre-signed PUT url for Amazon S3 with a maximum content-length -


i'm trying generate pre-signed url client can use upload image specific s3 bucket. i've succesfully generated requests files, so:

generatepresignedurlrequest urlrequest = new generatepresignedurlrequest(bucket, filename); urlrequest.setmethod(method); urlrequest.setexpiration(expiration); 

where expiration , method date , httpmethod objects respectively.

now i'm trying create url allow users put file, can't figure out how set maximum content-length. did find information on post policies, i'd prefer use put here - i'd avoid constructing json, though doesn't seem possible.

lastly, alternative answer way pass image upload api gateway lambda can upload lambda s3 after validating file type , size (which isn't ideal).

while haven't managed limit file size on upload, ended creating lambda function activated on upload temporary bucket. function has signature below

public static void checkupload(s3eventnotification event) { 

(this notable because guides found online refer s3event class doesn't seem exist anymore)

the function pulls file's metadata (not file itself, potentially counts large download) , checks file size. if it's acceptable, downloads file uploads destination bucket. if not, deletes file.

this far ideal, uploads failing meet criteria seem work never show (as s3 issue 200 status code on upload without caring lambda's response is).

this workaround rather solution, won't accepting answer.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -