Code Monkey home page Code Monkey logo

react-filepond's Introduction

React FilePond

React FilePond is a handy wrapper component for FilePond, a JavaScript library that can upload anything you throw at it, optimizes images for faster uploads, and offers a great, accessible, silky smooth user experience.

License: MIT npm version npm


FilePond

Buy me a Coffee / Use FilePond with Pintura / Dev updates on Twitter


Core Features

  • Accepts directories, files, blobs, local URLs, remote URLs and Data URIs.
  • Drop files, select on filesystem, copy and paste files, or add files using the API.
  • Async uploading with AJAX, or encode files as base64 data and send along form post.
  • Accessible, tested with AT software like VoiceOver and JAWS, navigable by Keyboard.
  • Image optimization, automatic image resizing, cropping, and fixes EXIF orientation.
  • Responsive, automatically scales to available space, is functional on both mobile and desktop devices.

Learn more about FilePond


Also need Image Editing?

Pintura the modern JavaScript Image Editor is what you're looking for. Pintura supports setting crop aspect ratios, resizing, rotating, cropping, and flipping images. Above all, it integrates beautifully with FilePond.

Learn more about Pintura


Installation

npm install react-filepond filepond --save

Hooks:

import React, { useState } from 'react'
import ReactDOM from 'react-dom'

// Import React FilePond
import { FilePond, registerPlugin } from 'react-filepond'

// Import FilePond styles
import 'filepond/dist/filepond.min.css'

// Import the Image EXIF Orientation and Image Preview plugins
// Note: These need to be installed separately
// `npm i filepond-plugin-image-preview filepond-plugin-image-exif-orientation --save`
import FilePondPluginImageExifOrientation from 'filepond-plugin-image-exif-orientation'
import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css'

// Register the plugins
registerPlugin(FilePondPluginImageExifOrientation, FilePondPluginImagePreview)

// Our app
function App() {
  const [files, setFiles] = useState([])
  return (
    <div className="App">
      <FilePond
        files={files}
        onupdatefiles={setFiles}
        allowMultiple={true}
        maxFiles={3}
        server="/api"
        name="files" /* sets the file input name, it's filepond by default */
        labelIdle='Drag & Drop your files or <span class="filepond--label-action">Browse</span>'
      />
    </div>
  )
}

Component:

import React, { useState } from 'react'
import ReactDOM from 'react-dom'

// Import React FilePond
import { FilePond, registerPlugin } from "react-filepond";

// Import FilePond styles
import "filepond/dist/filepond.min.css";

// Import the Image EXIF Orientation and Image Preview plugins
// Note: These need to be installed separately
import FilePondPluginImageExifOrientation from "filepond-plugin-image-exif-orientation";
import FilePondPluginImagePreview from "filepond-plugin-image-preview";
import "filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css";

// Register the plugins
registerPlugin(FilePondPluginImageExifOrientation, FilePondPluginImagePreview);

// Our app
class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      // Set initial files, type 'local' means this is a file
      // that has already been uploaded to the server (see docs)
      files: [
        {
          source: "index.html",
          options: {
            type: "local"
          }
        }
      ]
    };
  }

  handleInit() {
    console.log("FilePond instance has initialised", this.pond);
  }

  render() {
    return (
      <div className="App">
        <FilePond
          ref={ref => (this.pond = ref)}
          files={this.state.files}
          allowMultiple={true}
          allowReorder={true}
          maxFiles={3}
          server="/api"
          name="files" /* sets the file input name, it's filepond by default */
          oninit={() => this.handleInit()}
          onupdatefiles={fileItems => {
            // Set currently active file objects to this.state
            this.setState({
              files: fileItems.map(fileItem => fileItem.file)
            });
          }}
        />
      </div>
    );
  }
}

Read the docs for more information

Live Demo on Code Sandbox

react-filepond's People

Contributors

dhilst avatar jokinen avatar kimgenius avatar lukestuts avatar rikschennink avatar sbusch avatar songhn233 avatar z1k0v avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-filepond's Issues

setting headers

I have set the headers as the below, but it doesnt work when uploading to server, is this done right?

 handleInit() {
    this.pond.customHeader = customHeader();
    console.log(this.pond.customHeader)
  }
render() {
    return (
      <div className="App">
        {/* // Pass FilePond properties as attributes */}
        <FilePond
          ref={ref => (this.pond = ref)}
          allowMultiple={true}
          customHeader={}
          maxFiles={3}
          server="address here"
          // oninit={() => this.handleInit()}
        >
          {/* // Set current files using the <File/> component */}
          {this.state.files.map(file => <File key={file} source={file} />)}
        </FilePond>
      </div>
    );
  }
}

the customHeader function above returns my headers

"window is not defined" error on Next.js 7

Summary

Importing react-filepond into my Next.js 7 application gives the following error:

ReferenceError: window is not defined
    at isOperaMini (/Users/richardlam/S2-Projects/React/simple-events/node_modules/filepond/dist/filepond.js:8874:38)
    at /Users/richardlam/S2-Projects/React/simple-events/node_modules/filepond/dist/filepond.js:8901:7
    at /Users/richardlam/S2-Projects/React/simple-events/node_modules/filepond/dist/filepond.js:8914:5
    at isNode (/Users/richardlam/S2-Projects/React/simple-events/node_modules/filepond/dist/filepond.js:10:7)
    at Object.<anonymous> (/Users/richardlam/S2-Projects/React/simple-events/node_modules/filepond/dist/filepond.js:14:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/richardlam/S2-Projects/React/simple-events/node_modules/react-filepond/dist/react-filepond.js:24:17)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)

How to reproduce

To reproduce, import the following statement into any page on Next and it'll throw the error.

import { FilePond, File, registerPlugin } from 'react-filepond';

Additional information

Environment Version
Filepond 3.2.3
React-Filepond 5.0.0
React 16.6.0
Nextjs 7.0.2
OS MacOS
Device 2017 Macbook Pro
Browser Chrome 70.0.3538.67

adding user supplied values to payload

How can I add some user supplied values along with the file payload sent to my server?
for example, my users will need to add a file and then input some values such as

{
  client: "Acme Inc.", 
  clientId: 123, 
}

i can easily add some input fields and clickHandlers to get those values into state, but not sure how to get FilePond to access them and send to backend.

thanks

How To Set Plugin Properties

Summary

I have the image preview plugin working but I can't figure out how to set imagePreviewMaxHeight.

Expected behaviour

I would expect one of these to work

  • <FilePond imagePreviewMaxHeight={1024} />
  • <FilePond options={{ imagePreviewMaxHeight: 1024 }} />
  • <FilePond setOptions={{ imagePreviewMaxHeight: 1024 }} />
  • <FilePond ref={ref=>this.fp = ref} oninit={() => {this.fp.setOptions({ imagePreviewMaxHeight: 1024 })}} />

What am I doing wrong?

FilePond.SetOptions not worked

i just use this code in my component to set custom server request with headers

FilePond.setOptions({
    server: {
        url: '/uploader',
        process: {
            url: './process',
            method: 'POST',
            withCredentials: false,
            headers: {},
            timeout: 7000,
            onload: null,
            onerror: null
        }
    }
});

but it's not worked for me.

this is the error

Uncaught TypeError: react_filepond__WEBPACK_IMPORTED_MODULE_10__.FilePond.setOptions is not a function

Files not rerendering inside conditional component

Summary

I am setting the files to show in the filepond bar using setState. Generally filepond bar is displaying the given files when they are updated but if the filepond component is shown conditionally (condition failed on init) it is not showing any files until any other setState() is called.
I require to call a dummy setState({}) to make it display files.

How to reproduce

Reproduced the behaviour in (https://stackblitz.com/edit/react-fileupload?file=index.js)
In this there are two filepond components both are given with same values, the one displaying naturally has a file showing but the one displaying conditionally (condition will fail at init) is showing blank files in it.
When clicked on the button which calls a blank setState({}) the files will be shown in that one too.

Expected behaviour

Files should be visible in the first component without calling any dummy setState({})

Additional information

Dependency Version
filepond 3.7.0
react 16.5.0
react-filepond 5.0.0
Environment Version
OS Windows
Device Desktop
Browser Google Chrome Version 71.0.3578.98

Pass filename to delete a file in server on multiple file upload

Summary

I am uploading multiple files to a server using Filepond but when I want to delete a file which is uploaded, I need a reference to that file (which can be as simple as filename) so that I can delete that file before user choose to upload different one.

So, how can I pass this file reference to my service when user clicks on remove icon in Filepond?

How to reproduce

Client-side

<FilePond ref={ref => this.pond = ref}
    server={serverUrl}
    name={this.props.id}
    required={true}
    allowMultiple={true}
    maxFiles={2}
    allowFileSizeValidation={true}
    maxTotalFileSize={10485760}
    labelMaxTotalFileSize={'Total file size should be lesser than 10MB.'}
    allowFileTypeValidation={true}
    acceptedFileTypes={['application/pdf', 'image/jpeg']}
    fileValidateTypeLabelExpectedTypesMap={{
      'application/pdf': '.pdf', 'image/jpeg': '.jpg'
    }}
    labelFileTypeNotAllowed={'Upload only PDF or JPEG file.'}
    oninit={() => this.handleInit() }
    onremovefile={(file) => {
      console.log(file)
    }}
    onupdatefiles={(fileItems) => {
      this.setState({
        files: fileItems.map(fileItem => fileItem.file.name)
      });
    }}
/>

Server-side

app.delete('/upload', function (req, res) {
    const dest = `${process.cwd()}/src/uploads/${req.query.id.toUpperCase()}`;

    if(util.deleteFolder(dest)) {
       res.status(200).send('Delete success');
    } else {
       res.status(500).send('Delete failed');
    }
});

Expected behaviour

Need reference to file (like filename) which needs to be deleted when multiple files are uploaded.

Additional information

I am new to UI development and React, so this might be a simple query or I am reading it differently. Either way please help me out in finding solution for this problem :)

Environment Version
OS MacOS / Linux
Device Web
Browser Chrome

How to display the fileName instead of serverId

Hi

How can I restore the filename ?

<FilePond
    server={{
       url: 'https://localhost:8443/api',
       load: {
          url: '/fileLoad/',
	  method: 'GET',
	  withCredentials: true,
      }
     }}
 >
    <File source="724" type="local" />
</FilePond>

image

image

Thx

Use processFile with a function that handles the upload rather than a direct Post?

Hey there,

I'm currently using filepond on a react page and it's awesome! I've run into a bit of difficulty recently however.

The current process I'm trying to achieve is:

User drops file onto filepond => file contents are converted to a json string => a function takes this json string and posts it to a remote server (this function handles the authentication as well).

Currently I've got something that works by doing the following:

onaddfilestart={(file) => {          
   if (file.status === 2) {
   //my custom upload method takes the file and processes it;
}

This isn't very good however as the filepond UI doesn't update at all (I'm currently just showing a success message div if my upload method completes).

I've looked at the docs around using server and custom processing, but this all seems to only be useable if you want to directly upload the file itself to a remote location using XMLHttpRequest.

I'd like to be able to do the process I described above and still have the same UI effect that processFile triggers (turns green shows the uploading wheel and updates to complete when the process has finished).

Is there any mechanism in FilePond for me to be able to do this easily? Apologies if I seem to have misunderstood anything here or I'm not being clear. I come from a dev background but I'm extremely new to javascript (only a few days so far).

No changelog or release notes

Hi, I noticed this package went up 2 major versions last month, but there is no CHANGELOG.md or release notes under Releases. How are we supposed to know about what changed/breaking changes/fixes? Thanks

Help With Z-Index

Hello,

I cannot find any functionality to edit or change the styling of the filepond. Has anyone attempted this before?
I just need to lower the z-index of both .filepond--drop-label to 0 and .filepond--root>.filepond--panel to -1, as the current z-index are causing conflicts with multiple components in my app.

Kind Regards,
Liam

error 400

hi
I want to preview my image from server in fileppond if the file was uploaded
but I get 400 error
this my code

<FilePond type={'remote'} allowMultiple={true} ref={ref => {  this.getRefFileComponent(ref) }}>
  {this.state.files.map(file => {
      return <File key={file}
        src={`${window.location.protocol}` + "//" + process.env.REACT_APP_BACKEND + file.address}/>
  })}
</FilePond>

Expandable gray background not showing and not responding to new files being added

Summary

Expandable gray background not showing and not responding to new files being added

How to reproduce

Just install filepond without any plugins, replicate code provided on main React FilePond page.

Expected behaviour

Background box will expand to fit newly added files

Additional information

Environment Version
OS MacOS / Windows / iOS / Linux / ...
Device iPhone SE / Galaxy Note 9 / ...
Browser Safari 11.1.1 / Edge 15 / ...

File name label after upload

How can I change the file name label after uploading the file. I don't use the file name to download the file from the server, I use an ID.

screen shot 2018-06-01 at 09 58 39

For example:

<File key={result[0]} source={result[0]} type={'local'} />

where result[0] is the id and result[1] is the filename.

Thanks in advance

loading previous files

can you please provide an example of loading previously uploaded or initial files with urls using react-filepond

Warning after file upload

HI, i found a problem

TypeError: Cannot read property 'filename' of null
at Object.itemProcessed [as DID_COMPLETE_ITEM_PROCESSING] (filepond.js:6829)

This happens after file is uploaded, and all works fine, except for this warning
I upload files using proccessHandler and it just take arguments from the filepond and uses it for my logic

 <FilePond
                        allowMultiple={ allowMultiply }
                        allowReplace={ !allowMultiply }
                        allowDrop={ allowDrop }
                        allowBrowse={ allowBrowse }
                        maxFiles={ maxFiles }
                        server={ this.serverOptions }
                        maxFileSize={ maxFileSize }
                        maxTotalFileSize={ maxTotalFileSize }
                        acceptedFileTypes={ acceptedFileTypes }
                        instantUpload={ instantUpload }
                        allowRevert={ allowRevert }
                        allowFileSizeValidation={ allowFileSizeValidation }
                        allowFileTypeValidation={ allowFileTypeValidation }
                        { ...this.translatedText() }
                        files={ !this.hasFileUploaded() ? [] : [
                            {
                                options: {
                                    type: 'limbo',
                                    file: {
                                        name: this.getFileName(),
                                        size: this.getFileSize(),
                                    },
                                },
                            },
                        ] }
                    >
                    </FilePond>
   serverOptions = {
        process: this.processHandler,
        revert: this.revertHandler,
    };
    processHandler = ( fieldName, file, metadata, load, error ) => {
        const { formType } = this.props;
        const sendingBody = `
            {
                "requestId": "${uuidv4()}",
                "operation": "PROCESS",
                "file": {
                    "name": "${file.name}",
                    "content": "${metadata.base64}"
                }
            }
            `;

        fileSocketSend( formType, load, error, sendingBody,
            this.handlerForProcessHandlerSocket);
    };
Environment Version
OS Windows
Browser Latest Chrome

filepond.min.css file NOT being applied

Summary

Hi there,

import { FilePond } from 'react-filepond';
import 'filepond/dist/filepond.css';
...
<FilePond/>

I used above code, but got this ugly style.
image

Any suggestion?

How to reproduce

Expected behaviour

Additional information

Environment Version
OS MacOS / Windows
Browser Chrome latest

How to listen to event

Hello, firstly thanks for this package.

I have no Idea how to listen to events and attach an handler to it with React / Next.js. The documentation on React is brief.

Are there callbacks? If yes, how do we use it?

I tried using a ref and attaching the handler in componentDidMount but I got an error

this.pond.on is not a function

component.js summary

constructor(props)
{
        this.pond = React.createRef()
}

componentDidMount(){

        require('filepond-polyfill')

        this.pond.on('addfile', () => {

            console.log("File added")
        })
}

render(){
<FilePond 
        allowMultiple={false} 
        maxFiles={1} 
        server={config.media_upload_node} 
        name="file" 
        acceptedFileTypes={['image/*']} 
        ref={this.pond}
>
        {files.map(file => (
                <File key={file} src={file} />
        ))}
                                                                        
</FilePond>
}

Default image

Hello. I am using react-filepond for uploads avatar users. If the user has already uploaded avatar on server, i send from the server the link on image. How to display this avatar on FilePond component? Thank you!

Some questions

Hi Rik,

FilePond looks really sweet!

I've a couple of questions:

  • Is it possible to make the request but a PUT and not do a multipart/form-data but put the file contents straight into the request body? (Just like curl http://server/api -T path/to/file would do.)
  • In your blog post you're talking about sales. Is this a paid module? If so, where can I find pricing info?
  • I was looking for the sources (from which dist/** is derived) but couldn't find them. Are they available somewhere or is it "closed source"? I'd like to be able to review and also tweak the code if needed.
  • Last but not least; are you open for consulting work?

Thanks.

file size validation

Hello , I'm using the the file size plugin, and it seems not working. I also think it would be nice if if also had a minFileSize validation

Click to view uploaded item ?

Summary

I'm using react-filepond on an Edit form which takes information from a secured rest api (with Bearer accesstoken)
Due to the nature of the call i am actually just mocking the files in <File> with name from the rest-api.

What i'd like is for a way to click the file name and have it open the url on which it resides (since its on a different site and users need to be logged in there). Is there any way to do that? Is there any event for on-click ?

Adding anything around <File> or even onClick does nothing (<a> around <File> actually changes the src of <File>).

How to reproduce

Create FilePond file with mock data.

{this.state.selectedFiles.map(file => (
<File key={file} src={file} name={file.FileName} size={700100} type="AttachedFile" origin="local" />
))}

Expected behaviour

A handler so the user can be redirected to the files in the list by clicking on file name or on a View button.

Additional information

Environment Version
OS Windows
Device Desktop
Browser Chrome

How to add Plugin when using with React

How to register the plugins when using with react. I can see registerPlugin is imported but it is never used to register in this react wrapper. am I missing something?

FilePond - Issue when component is unmounted

Hello,

I'm testing the React Component and something caught my attention, while I was unmounting a component where the File Pond component has been mounted before it throws an error:

Uncaught TypeError: Cannot read property 'restoreElement' of undefined
    at destroy (filepond.js:7904)
    at filepond.js:1957
    at Array.forEach (<anonymous>)
    at filepond.js:1956
// destroys apps and removes them from the app array
  var destroy = function destroy(hook) {
    // returns true if the app was destroyed successfully
    var indexToRemove = state.apps.findIndex(function(app) {
      return app.isAttachedTo(hook);
    });
    if (
      function(indexToRemove) {
        return 0;
      }
    ) {
      // remove from apps
      var app = state.apps.splice(indexToRemove, 1)[0];

      // restore original dom element
Line: 7904      app.restoreElement();

      return true;
    }

    return false;
  };

Tested on:

Google Chrome
Version 65.0.3325.162 (Official Build) (64-bit)

Your component is great!!

Pass name prop to <input/>

first of all, congratulations on this amazing component ๐Ÿ˜„

besides accessibility, there are some services that use the name property on form elements โ€” e.g. netlify

so if we could just pass this string down, it'll be a huge plus โœŒ๏ธ

onremovefile missing file data

Summary

Hi, I encountered the following problem using react-filepond. When a file is added, I update the state of the component which holds the serverIds of the files to submit using "onprocessFile". When a file is removed, I try to remove it from the state using "onremovefile", however, the received file instance does not have a serverid, which makes it hard for me to know which file to remove.

How to reproduce

On a FilePond component's "onremovefile", bind a function that receive a file instance

<FilePond {...translateComponent()} allowMultiple={allowMultiple} maxFiles={maxFiles} server={serverConfig} onprocessfile={handleAttachmentAdded} onremovefile={handleAttachmentRemoved} {...otherProps}/>
handleAttachmentAdded(error, file) {
        if (error == null) {
            const currentAttachments = this.state.attachments || [];
            const allAttachments = currentAttachments.concat(file.serverId);
            this.setState({
                attachments: allAttachments
            });
        }
}
handleAttachmentRemoved(file) {
        const remainingAttachments = this.state.attachments.filter((f => f != file.serverId));
        this.setState({
            attachments: remainingAttachments
        });
}

Expected behaviour

The received file instance should have a serverId while currently, it is undefined.
EDIT: It is null when printed in the console.

Additional information

Environment Version
OS Linux
Browser Chome

react-filepond with next.js

Hi,

I have some troubles to use react-filepond with the framework https://github.com/zeit/next.js/

I add in package.json
"react-filepond": "1.2.0",

I also add the webpack conf to be able to import .css directly

but I'm still have a problem

import React, { createElement } from 'react';
^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.react-filepond (/Users/parweb/Sites/ww/web/.next/dist/bundles/pages/place/webpack:/external "react-filepond"?b8ed:1:1)
    at __webpack_require__ (/Users/parweb/Sites/ww/web/.next/dist/bundles/pages/place/webpack:/webpack/bootstrap 3e856f59bcd105a28e6b?7d67:21:1)
    at Object../pages/place/test.js (/Users/parweb/Sites/ww/web/.next/dist/bundles/pages/place/test.js:89:73)
    at __webpack_require__ (/Users/parweb/Sites/ww/web/.next/dist/bundles/pages/place/webpack:/webpack/bootstrap 3e856f59bcd105a28e6b?7d67:21:1)
    at Object.3 (/Users/parweb/Sites/ww/web/.next/dist/bundles/pages/place/test.js:165:18)
    at __webpack_require__ (/Users/parweb/Sites/ww/web/.next/dist/bundles/pages/place/webpack:/webpack/bootstrap 3e856f59bcd105a28e6b?7d67:21:1)
    at module.exports../node_modules/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css (/Users/parweb/Sites/ww/web/.next/dist/bundles/pages/place/webpack:/webpack/bootstrap 3e856f59bcd105a28e6b?7d67:68:1)```

Preview Dimensions {width, height}

Couldn't find documentation on passing dimension props to filepond-plugin-image-preview while using react, would you mind giving me a hint on this?

thank you

How to turn off instantUpload?

Hi, I have a hard time trying to turn instanUpload off. Here is what I do:

<FilePond instantUpload={false} ref={this.pond} onaddfile={this.handleAdd} server={server} />

Is there anything else I should do?

allowRevert not working

Hello,

I want to disable the revert function. Therefore I have passed allowRevert={false}. However, this is not working and the 'X' icon is still there. Also when I click on it, Filepond is trying to call the DELETE method.

Example code:
screenshot 2018-12-29 at 13 24 30

And the result:
screenshot 2018-12-29 at 13 23 09

Any help is appreciated!
Bram

How to add formdata key?

image
This is how I upload files manually, can I configure the special key "news" for form-data?
Using React.

A couple Questions.

Hi

I am looking into use this plugin (from the examples it looks pretty sweet).

I am wondering though

  1. Is there a property to change the label? Right now "Drag & Drop your picture or Browse" I would like to change it to like ".... or Click Here to Add Files"

  2. I have a form and I would like to submit the images on form submit, can this easily be done. You can think of something like craiglists where someone creates a new post, they add some information and their pictures and then hit the "submit" button.

  3. Possible to add custom borders around image preview? Like how craiglist adds to first picture that it is featured. If you drag a different image to first position it changes that new images to the "featured" border.

  4. Get count of how many images where added to filepond? If they drag 3 images in. I want to update a counter outside of filepond with that count.

FilePondPluginImageTransform using transform variants problem

i dont know how to implement variants for plugin

i am useing this code :

import { FilePond, File, registerPlugin } from 'react-filepond';
import FilePondPluginImageResize from 'filepond-plugin-image-resize';
import FilePondPluginImageValidateSize from 'filepond-plugin-image-validate-size';
import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size';
import 'filepond/dist/filepond.min.css';
import FilePondPluginImagePreview from 'filepond-plugin-image-preview';
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css';
import FilePondPluginImageTransform from 'filepond-plugin-image-transform';
registerPlugin(FilePondPluginImageResize,
FilePondPluginImagePreview,
FilePondPluginImageValidateSize,
FilePondPluginFileValidateSize,
FilePondPluginImageTransform
);

const variants=({
'thumb_smddall_': transforms => {
transforms.resize.size.width = 200;
return transforms;
}
});

<FilePond
                    allowMultiple={true}
                    maxFiles={10}
                    server={Server}
                    maxParallelUploads={1}
                    allowImagePreview={true}
                    imageValidateSizeMinWidth={200}
                    imageValidateSizeMinHeight={200}
                    imageValidateSizeMaxWidth={8000}
                    imageValidateSizeMaxHeight={8000}
                    imageResizeTargetWidth={1800}
                    imageResizeTargetHeight={1200}
                    imageResizeUpscale={false}
                    maxFileSize={'8MB'}
                    maxTotalFileSize={'30MB'}
                    allowImageTransform={true}
                    imageTransformOutputQuality={65}
                    imageTransformVariants= {variants}

                />

every plugin just works fine but when i add variant it stop working and show just loading on image upload

cant get base64 string Filepond Encode not working

#Summary:
I want to send a base64 string to an API.

##How to reproduce:
Filepond Code:
image

result:
image

in the result I use the function getFiles(); to get the object in the browser like that.
https://pqina.nl/filepond/docs/patterns/plugins/file-encode/

###Expected behaviour:
I thought I was supposed to get a base64 object like its saying in the filepond-encode link above.

####Additional information:

Environment Version
OS Windows 10
Browser Chrome 70.0.3538.67

Error if I have uploaded files and try to upload new files

Hello @pqina,
I am using react-filepond and found this issue

filepond.js:6527 Uncaught TypeError: Cannot read property 'filename' of null
    at Object.itemProcessed [as DID_COMPLETE_ITEM_PROCESSING]

This happens when I already have some files to display and try to upload new files with my custom process function
eg:

<FilePond
          allowMultiple={true}
          server={{
            process: this.handleProcessing.bind(this),
          }}
        >
          <File key={0} source={'index.html'} type="local" />
        </FilePond>

Now If i try to upload new files, the files even though gets processed, will show this error in console and blob gets hidden.

Can't modify request header manually in react

After uploading an image it send request automatically and that's okay.

`<FilePond ref={ref => this.pond = ref}
allowMultiple={false}
maxFiles={1}
allowImageCrop={true}
server="http://domen/api"
oninit={() => this.handleInit()}

`

But my server doesn't accept requests without token and etc.
I need customize request headers, so how could I do that

Server Example with Redux

Hi, congratulations on creating this great project,

I was wondering if there is an example of Filepond where redux is responsible for managing data and process/revert requests,

I have this server where I need to upload my file with additional request body parameters (which I haven't tried yet) and Authorization Header info(which is not a problem based on docs and what I experienced)

thank you for your time

onupdatefiles is empty object

used as demo show. but the onupdatefiles fileItems is {}

                          onupdatefiles={(fileItems) => {
                              // Set current file objects to this.state
                              this.setState({
                                  files: fileItems.map(fileItem => {console.log(JSON.stringify(fileItem.file)); return fileItem.file})
                              });
                          }

Receiver Response from Server

Hi Team,

I'm using this library to use upload file.
Now, my server's developing to return json response. I use onload, ondata to receive this response. But it not appear any thing,

Please help me to fix this bug

Progress indicator SVG is not centered vertically

Summary

The progress indicator SVG is not vertically centered.

The div parent of the progress indicator seems to be positioned correctly in the center, but the SVG child is not.

The SVG has the following styles:

.filepond--progress-indicator svg {
    width: 100%;
    height: 100%;
    transform-box: fill-box;
}

And when I remove the height, it fixes the issue.

Any ideas why this could be a problem, is it just for me?

How to reproduce

Upload any file.

Expected behaviour

The SVG should be vertically centered.

Additional information

Environment Version
OS Windows 10
Browser Chrome 69

File upload configuration

Hello,

Thanks for the very cool uploading tool! Can you please explain the best way (if possible) to upload only a file without using a unique Id and temporary folder. (Can I simply overwrite the headers?)

Thanks!!!

To add further detail, I will be using custom Content-Type (Content-Type: application/octet-stream) and Content-Disposition headers in the upload request that differ from what I find in the documentation.

allowMultiple file preview bug

Summary

When using react-filepond, using the attribute allowMultiple={true} leads to none of the file previews being displayed.

How to reproduce

<FilePond
    allowMultiple={true}
    instantUpload={false}
    ref={ref => this.pond = ref}
    onupdatefiles={(fileItems) => {
        // Set current file objects to this.state
        this.setState({
            files: fileItems.map(fileItem => fileItem.file)
        });
    }}>
    {/*Update current files*/}
    {this.state.files.map(file => (
        <File key={file} src={file} origin="local" />
    ))}
</FilePond>

Above is the instance I have in my working directory. However, adding allowMultiple to any instance of filepond with a react adapter causes this issue. I'm guessing it's a CSS issue. The file preview will work very rarely and sporadically.

Expected behaviour

When adding multiple files, all files should be displayed within the filepond preview queue (not sure how else to phrase this).

Additional information

Environment Version
OS Windows
Browser Chrome 70.0 / Edge 15 / ...

Component doesn't render iniitial state on error

I was debugging and I realized the components doesn't go back to it's initial state if the URL to the server returns 404.

Here are the 3 states

Initial

image

On upload error, the file is removed automatically

image

Finally, it just renders a blank component. It should revert back to the initial

image

I am using the React.JS library with Next.js

Change labels through props

Hello,

I'd like to suggest exposing the labels for FilePond through the react component.
Currently FilePond is single language english and very generic. but at least you have the option to change the labels.
However in the React Component you need to change the labels AFTER rendering the component and then trigger a rerender.

If you'd expose the label properties of the filepond instance and set them accordingly in the React component, everyone could set their own labels and/or provide translated strings without having to trigger a surplus rerender.

How to customize request headers

I just wanna customize headers after uploading image like so

const headers = { 'X-Authorization' : 'Bearer token', 'body' : 'form-data' }
const img = this.pond;

    Axios.post('http://domen/uploadFile', img, {headers: headers})
    .then((res)=>{
        console.log(res);
    })

`

but if I page my url into server attribute sends request automatic without headers and token.

<FilePond ref={ref => this.pond = ref} allowMultiple={false} maxFiles={1} allowImageCrop={true} server="http://url/uploadFile" oninit={() => this.handleInit()} > </FilePond>

So how can I handle it.

React-filepond with Fuse-box throws `filepond does not provide a module`

Summary

Hello, I am using Fuse-box to build my project and I would like to use React-filepond, however, following the tutorial, I am getting filepond does not provide a module Do you have any idea how to fix this issue? Your library is awesome and I would like to use it.

Thank you,

How to reproduce

Build the tutorial with fuse-box.

Expected behaviour

The component should work.

Environment Version
OS MacOS
Browser All

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.