Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@rpldy/upload-preview
Advanced tools
Preview component to show image or video being uploaded.
By default, will present a preview of the file being uploaded in case its an image or video.
#Yarn:
$ yarn add @rpldy/uploady @rpldy/upload-preview
#NPM:
$ npm i @rpldy/uploady @rpldy/upload-preview
Name (* = mandatory) | Type | Default | Description |
---|---|---|---|
loadFirstOnly | boolean | false | load preview only for the first item in a batch |
maxPreviewImageSize | number | 2e+7 | maximum size of image to preview |
maxPreviewVideoSize | number | 1e+8 | maximum size of video to preview |
fallbackUrl | string | FallbackMethod | undefined | static URL or function that returns fallback in case failed to load preview or when file over max size |
imageMimeTypes | string[] | see list below | image mime types to load preview for |
videoMimeTypes | string[] | see list below | video mime types to load preview for |
previewComponentProps | PreviewComponentPropsOrMethod | undefined | object or function to generate object as additional props for the preview component |
PreviewComponent | React.ComponentType | img | video | The component that will show the preview |
rememberPreviousBatches | boolean | false | show previous batches' previews as opposed to just the last |
previewMethodsRef | React Ref | undefined | ref will be set with preview helper methods |
onPreviewsChanged | (PreviewItem[]) => void | undefined | callback will be called whenever preview items array changes |
import React from "react";
import Uploady from "@rpldy/uploady";
import UploadPreview from "@rpldy/upload-preview";
export const App = () => (
<Uploady destination={{ url: "my-server.com/upload" }}>
<UploadPreview
fallbackUrl="https://icon-library.net/images/image-placeholder-icon/image-placeholder-icon-6.jpg"/>
</Uploady>
);
_The props rememberPreviousBatches, previewMethodsRef, and onPreviewsChanged make it possible to do more with previews. Specifically, the make it possible to create a visual queue of the uploads.
This is especially useful when adding other features such as abort and retry.
The code below shows how to clear the previews with a button click:
import React from "react";
import Uploady from "@rpldy/uploady";
import UploadPreview from "@rpldy/upload-preview";
import UploadButton from "@rpldy/upload-button";
const PreviewsWithClear = () => {
const previewMethodsRef = useRef();
const [previews, setPreviews] = useState([]);
const onPreviewsChanged = useCallback((previews) => {
setPreviews(previews);
}, []);
const onClear = useCallback(() => {
if (previewMethodsRef.current?.clear) {
previewMethodsRef.current.clear();
}
}, [previewMethodsRef]);
return <>
<button onClick={onClear}>
Clear {previews.length} previews
</button>
<br/>
<UploadPreview
rememberPreviousBatches
previewMethodsRef={previewMethodsRef}
onPreviewsChanged={onPreviewsChanged}
/>
</>;
};
export const App = () => {
return <Uploady destination={{ url: "my-server.com/upload" }}>
<UploadButton />
<PreviewsWithClear />
</Uploady>;
};
For an example of using a custom preview component see this story.
0.4.0 (2020-07-22)
[mock-sender]
- mock sender for testing purposes (moved out of sender)[shared]
- getMerge with withSymbols[simple-state]
- unwrap with symbol propsFAQs
preview component to show image or video being uploaded
The npm package @rpldy/upload-preview receives a total of 3,305 weekly downloads. As such, @rpldy/upload-preview popularity was classified as popular.
We found that @rpldy/upload-preview demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.