
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@amonks/media-uploader
Advanced tools
This is for when you want to upload some media to s3 but also tell your API some metadata about that media. You say "Hey API! Got a file for ya! Also, here's some metadata!" the api says "Cool! I'll keep the metadata. Here's a signature for sending the fi
This is for when you want to upload some media to s3 but also tell your API some metadata about that media. You say "Hey API! Got a file for ya! Also, here's some metadata!" the api says "Cool! I'll keep the metadata. Here's a signature for sending the file straight over to s3!" Then, you send the file to s3. Great!
First, install nodejs.
Then, from the command line,
npm install --global @amonks/upload-media
You can configure Media Uploader using environment variables.
These environment variables are required:
You can also pass metadata to the server by using additional environment variables that begin with UPLOAD_MEDIA_METADATA_
.
Once you've installed this module, you can use it from the command line. This works on Windows.
upload-media my-picture.jpg
One way of setting the required environment variables is like this:
UPLOAD_MEDIA_API_KEY="abc123" UPLOAD_MEDIA_ENDPOINT_URL="https://whatever.com/upload" upload-media my-picture.jpg
Another way is to make a file called .env
. That file has to be in whatever folder you call upload-media
from. It should look like this:
UPLOAD_MEDIA_API_KEY="abc123"
UPLOAD_MEDIA_ENDPOINT_URL="https://whatever.com/upload"
UPLOAD_MEDIA_METADATA_MEDIA_TYPE="Polaroid"
If you're using javascript, you can use this as a library like this:
const uploadMedia = require("@amonks/upload-media");
uploadMedia("path-to-my-file.mp4").then((success, err) => {
if (error) throw Error("Error uploading media!\n" + error.message);
console.log("Success!");
});
It makes two requests. First, it sends an HTTP request to the UPLOAD_MEDIA_ENDPOINT_URL:
POST /upload HTTP/1.1
x-api-key: abc123
accept: application/json
content-type: application/json
accept-encoding: gzip,deflate
connection: close
content-length: 114
Host: whatever.com
{"contentLength":361,"contentType":"application/json","uuid":"ffdf5a2c-f28d-4b67-b1d4-cdd5af58a6dc","metadata":{"mediaType":"Polaroid"}}
It expects to receive a response like this:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 926
Connection: close
{"version":"1.0","responseId":"49cca5e7-9283-4099-9ed3-9b323d5c3a5d","sentAt":"2018-06-05T07:07:32.584Z","status":"ok","data":{"signedRequest":"https://xxxxxxxxxxxxxxxxxxxx-media-uploads.s3.us-west-2.amazonaws.com/ffdf5a2c-f28d-4b67-b1d4-xxxxxxxxxxxx/hhhhhhhhh?AWSxccessKeyId=ASIAIFNO2XZXXXXXXXXA&Content-Type=image%2Fjpeg&Expires=1528183351&Signature=NN2XXXXXXXXXXXXXR4QAGD71u3g%3D&x-amz-security-token=FQoDYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXkYeP5N10WNrd9otA4HvCtSVSgyFJLws3FW9GqU4CpU5DM7qO678YSpWdNJp3u%2BPjUnzQsC6apSN2jKKAD9tJBYOhNjPlpdBEt1KjlZbcCOmWjU4IU4cFw%2FnhTVVy7Zoe9%2FVLt3BT9Tls44iElxNzngHl7tMFXVOCORaG6A%2Fvx0mwzJGLkLOPpzb5YD97de%2BvbnGAE4SiAx9jYBQ%3D%3D","key":"ffdf5a2c-f28dxxxxxxxxxxxxxxxxx58a6dc/undefined","bucket":"whatever-media-uploads"}}
It then PUT
s the file to the url from the signedRequest field of the response.
FAQs
This is for when you want to upload some media to s3 but also tell your API some metadata about that media. You say "Hey API! Got a file for ya! Also, here's some metadata!" the api says "Cool! I'll keep the metadata. Here's a signature for sending the fi
The npm package @amonks/media-uploader receives a total of 2 weekly downloads. As such, @amonks/media-uploader popularity was classified as not popular.
We found that @amonks/media-uploader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.