This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Upload = () => { | |
const [uploadUrl, setUploadUrl] = useState(false); | |
const uploadyContext = useContext(UploadyContext); | |
useItemFinishListener((item) => { | |
const response = JSON.parse(item.uploadResponse.data); | |
console.log(`item ${item.id} finished uploading, response was: `, response); | |
setUploadUrl(response.url); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactCrop from "react-image-crop"; | |
import { withRequestPreSendUpdate, useItemFinalizeListener } from "@rpldy/uploady"; | |
import { PREVIEW_TYPES } from "@rpldy/upload-preview"; | |
import cropImage from "./image-crop-helper"; | |
const ItemPreviewWithCrop = withRequestPreSendUpdate(props => { | |
const { id, url, isFallback, type, updateRequest, requestData, previewMethods } = props; | |
const [finished, setFinished] = useState(false); | |
const [crop, setCrop] = useState(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Uploady from "@rpldy/uploady"; | |
import UploadButton from "@rpldy/upload-button"; | |
import UploadPreview from "@rpldy/upload-preview"; | |
export default function UploadWithCrop() { | |
const previewMethodsRef = useRef(); | |
return ( | |
<Uploady | |
destination={{ url: "[upload-url]" }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { isFunction } from "lodash"; | |
import { mount } from "enzyme"; | |
export default (hook, props) => { | |
let wrapper, hookResult, hookParams, error; | |
if (isFunction(props)) { | |
hookParams = props; | |
props = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from "styled-components" | |
import { useItemProgressListener } from "@rpldy/uploady"; | |
const PreviewImage = styled.img` | |
margin: 5px; | |
max-width: 200px; | |
height: auto; | |
transition: opacity 0.4s; | |
${({ completed }) => `opacity: ${completed / 100};`} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UploadButton from "@rpldy/upload-button"; | |
import UploadPreview from "@rpldy/upload-preview"; | |
import CustomImagePreview from "./CustomImagePreview"; | |
const UploadWithProgressPreview = () => { | |
const getPreviewProps = useCallback(item => ({ id: item.id }), []); | |
return ( | |
<> | |
<UploadButton>Upload Files</UploadButton> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Uploady from "@rpldy/uploady"; | |
import UploadWithProgressPreview from "./UploadWithProgressPreview"; | |
const App = > () { | |
return ( | |
<Uploady | |
destination={{ url: "[upload-url]" }} | |
> | |
<div className="App"> | |
<h1>Hello React Uploady</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Uploady from "@rpldy/uploady"; | |
const App = > () { | |
return ( | |
<Uploady | |
destination={{ url: "[upload-url]" }} | |
> | |
<div className="App"> | |
<h1>Hello React Uploady</h1> | |
<UploadWithProgressPreview /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var path = require("path"), | |
fs = require("fs"); | |
module.exports = (function(){ | |
/** | |
* recursively remove the fs structure starting from (and including) the path given in dirToRemove | |
* @param dirToRemove | |
* the path to remove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Uploady from "@rpldy/uploady"; | |
import UploadButton from "@rpldy/upload-button"; | |
const MyApp = () => ( | |
<Uploady destination={{url: "https://my-server.com/upload"}}> | |
<UploadButton/> | |
</Uploady> | |
); |