Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera options in @uppy/react Dashboard #1519

Closed
rafcontreras opened this issue May 3, 2019 · 2 comments
Closed

Camera options in @uppy/react Dashboard #1519

rafcontreras opened this issue May 3, 2019 · 2 comments
Labels

Comments

@rafcontreras
Copy link

Hi there, I can't seem to be able to set camera options.

I'm trying to enable only photos and no video or audio. And I can't seem to be able to pass this props.

Here is my code

import React, { Component, Fragment } from "react";
import Uppy from "@uppy/core";
import Webcam from "@uppy/webcam";
import { Dashboard } from "@uppy/react";
import Helmet from "react-helmet";

class AvatarPicker extends Component {
 constructor(props) {
   super(props);

   this.uppy = Uppy({
     id: "uploader",
     autoProceed: false,
     allowMultipleUploads: true,
     debug: false,
     restrictions: {
       maxFileSize: null,
       maxNumberOfFiles: 1,
       minNumberOfFiles: 1,
       allowedFileTypes: ["image/*", ".jpg", ".jpeg", ".png", ".gif"]
     }
   })
     .use(Webcam)
     .use(Webcam, {
       countdown: true,
       modes: ["picture"],
       id: "webcam"        
     });
 }

 componentWillUnmount() {
   this.uppy.close();
 }

 render() {
   return (
     <Fragment>
       <Helmet>
         <link href="/css/uppy/main.css" rel="stylesheet" type="text/css" />
       </Helmet>
       <Dashboard
         plugins={["Webcam"]}
         uppy={this.uppy}
       />
     </Fragment>
   );
 }
}

export default AvatarPicker;
@kvz
Copy link
Member

kvz commented May 3, 2019

Hi, it looks like you have two of .use(Webcam), could that be it?

@goto-bus-stop
Copy link
Contributor

Yes:

// adds Webcam plugin with default configuration and ID "Webcam"
.use(Webcam)
// adds Webcam plugin with custom configuration and ID "webcam"
.use(Webcam, {
  countdown: true,
  modes: ["picture"],
  id: "webcam"
});

// Mounts plugin with ID "Webcam" (i.e. the first .use(Webcam) with default configuration)
<Dashboard
  plugins={["Webcam"]}
  uppy={this.uppy}
/>

You can fix it by removing the .use(Webcam) line, and removing the id: "webcam" option from the remaining one, so that the custom config will have the default ID "Webcam".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants