
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
@navjobs/upload
Advanced tools
I'm working on a v4 soon that simplfies the api and removes the children-as-a-function paradigm to something more extendable. Also revamping the test suit. It'll be a complete rewrite.
A set of React components for handling file uploads. If you simply want to turn any component into a file upload dialog, wrap it in our <UploadField/>
component that exposes the files after selection. Need to process a file upload and receive the upload progress? Wrap <UploadField/>
with <Uploader/>
. You can see examples inside our storybook.
<UploadField/>
. This means you have ultimate styling control.yarn add @navjobs/upload
import { UploadField } from '@navjobs/upload'
<UploadField
onFiles={files => //files object here}
containerProps={{
className: 'resume_import'
}}
uploadProps={{
accept: '.pdf,.doc,.docx,.txt,.rtf',
}}
>
<div>
Click here to upload! This can be an image,
or any component you can dream of.
</div>
</UploadField>
Use <UploadField />
inside of this component; pass the files to it and handle the upload!
import { Uploader } from '@navjobs/upload'
<Uploader
request={{
fileName: 'file',
url: 'https://upload.com',
method: 'POST',
fields: {
//extra fields to pass with the request
full_name: 'Testing extra fields',
},
headers: {
//custom headers to send along
Authorization: 'Bearer: Test',
},
// use credentials for cross-site requests
withCredentials: false,
}}
onComplete={({ response, status }) => /*do something*/}
//upload on file selection, otherwise use `startUpload`
uploadOnSelection={true}
>
{({ onFiles, progress, complete }) => (
<div>
<UploadField onFiles={onFiles}>
<div>
Click here to select a file!
</div>
</UploadField>
{progress ? `Progress: ${progress}` : null}
{complete ? 'Complete!' : null}
</div>
)}
</Uploader>
This is a useful component for generating signed urls on your backend for a service like AWS or Google Cloud. The workflow generally involes hitting your own api, then uploading to the url that your api returns. After the fact, you hit your api again to say that the upload is finished.
import { SignedUploader } from '@navjobs/upload'
<SignedUploader
//grab this url from your api
beforeRequest={() => new Promise(resolve => resolve({ url: 'http://storage.googlecloud.com' }))}
request={({ before, files }) => ({
url: before.url,
method: 'PUT',
headers: {
'Content-Type': files[0].type
}
})}
afterRequest={({ before, status }) => new Promise(resolve => {
resolve('finished the upload!');
})}
>
If you need to upload files and recieve progress, but can't wrap an Uploader
around where you receive the files, feel free to use this:
import { UploadRequest } from '@navjobs/upload'
async uploadFiles() {
let { response, error, aborted } = await UploadRequest(
{
request: {
url: 'blah' //same as above request object
},
files, //files array
progress: value => console.log('progress!', value)
}
)
//do something with response
}
Q: Part of the component I'm wrapping isn't cursor pointer?
A: You may need to set
::-webkit-file-upload-button { cursor:pointer; }
In your css. For some reason file uploads aren't always pointer.
This project is licensed under the terms of the MIT license.
FAQs
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
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.