Comments (4)
Could you provide a more detailed example resembling your internal tests? I'm not too familiar with how s3.createPresignedPost
interacts with the S3 API. My guess is that the POST endpoint just needs to be made case-insensitive when reading request body parameters.
from s3rver.
Of course!
The idea of s3.createPresignedPost
is to upload directly to S3 on the frontend. And also for uploading files larger than API Gateway (10mb) and EC2 can support or have a higher price for this function.
Then you can create a link (server) with parameters for submission and add it to a form (client).
So let's say you add the filename that will be inside s3, control the expiry time and set the upload condition, something like:
{
Bucket: "example",
Key: "path/of/file.pdf",
Conditions: [["content-length-range", 0, 10240000]], // optional
Expires: 3600,
}
To use in form:
// URL_VALUE url to upload
// VALUE params to use on upload
<form action="URL_VALUE" method="post" enctype="multipart/form-data">
<input type="hidden" name="key" value="VALUE" />
<input type="hidden" name="AWSAccessKeyId" value="VALUE" />
<input type="hidden" name="policy" value="VALUE" />
<input type="hidden" name="signature" value="VALUE" />
File:
<input type="file" name="file" /> <br />
<input type="submit" name="submit" value="Upload to Amazon S3" />
</form>
For some reason, in the documentation it displays as key and in the code as Key:
Docs: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_s3_presigned_post.html
Code: https://github.com/aws/aws-sdk-js-v3/blob/72611ca19b/packages/s3-presigned-post/src/createPresignedPost.ts#L19
In order for the code to work on AWS, I needed to change from <input type="hidden" name="key" value="VALUE" />
to <input type="hidden" name="Key" value="VALUE" />
, but the process fails in place.
In order for it to work with S3rver, I changed all references from key to Key. The rest of the S3 sending and receiving processes, such as profile photo, were not affected and work in both cases in s3rver and aws.
I think the process used refers to the uploadPart
function:
s3rver/lib/controllers/object.js
Line 693 in 005feae
I think the simplest solution would be to check if the Key exists when key does not exist, because has 2 references when use uploadPart
:
s3rver/lib/controllers/object.js
Lines 221 to 228 in 005feae
and
s3rver/lib/controllers/object.js
Lines 571 to 579 in 005feae
Maybe can use like:
const key = ctx.params.key || ctx.params.Key;
But for now it's all guesswork, I don't have the opportunity and time to analyze each process in depth.
from s3rver.
I submitted a pull request that allows this change without braking changes. #750
from s3rver.
It still looks like the parameter name sent over the wire is lowercase. From the same file you linked in the JS SDK it takes the capitalized parameter name and sends it as lowercase:
https://github.com/aws/aws-sdk-js-v3/blob/72611ca19bfe43ae6cee0e65dbb0a83689f76c5d/packages/s3-presigned-post/src/createPresignedPost.ts#L92
This aligns with the POST Object docs
https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html#RESTObjectPOST-requests-form-fields
from s3rver.
Related Issues (20)
- Project inactive? HOT 10
- replace moment.js with maintaned date library HOT 2
- vhostBuckets Documentation Confusing HOT 2
- Close Stale Issues/PRs HOT 5
- Error = A parameter you provided functionality that in not implemented HOT 6
- Error: fopen(httpseek://): failed to open stream ... HOT 4
- Storage Class not being respected HOT 5
- Question: Is s3rver a s3 "private" / "public" or both? HOT 1
- Content Range header not returned when requested range is 'bytes=0-' HOT 1
- Dependency Dashboard
- Failed to upload large file (53Mb)
- Apparent race condition deleting objects results in ENOENT HOT 1
- Custom Store
- attention on files contains url ecoding putcopy function need decodeURIComponent
- Security Issue in Dependency - CVE-2022-24434 HOT 4
- Feature request - storing/retrieving checksum metadata (x-amz-checksum) inside object attributes
- Simulate slow fetch
- fast-xml-parser vulnerable to prototype pollution SNYK-JS-FASTXMLPARSER-3325616 sonatype-2023-0998
- if i use aws java v2 sdk putobject fail HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s3rver.