How to use the apollo-upload-client.ReactNativeFile function in apollo-upload-client

To help you get started, we’ve selected a few apollo-upload-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sysgears / apollo-universal-starter-kit / modules / chat / client-react / containers / withImage.jsx View on Github external
pickImage = async ({ onSend }) => {
      const { t } = this.props;
      if (await this.checkPermission(Permissions.CAMERA_ROLL, 'android')) {
        const { cancelled, uri } = await ImagePicker.launchImageLibraryAsync(settings.chat.image.imagePicker);
        if (!cancelled) {
          const { size } = await FileSystem.getInfoAsync(uri);
          const reg = /[^\\/]*\.\w+$/;
          if (size <= settings.chat.image.maxSize && reg.test(uri)) {
            const type = mime.lookup(uri);
            const name = uri.match(reg)[0];
            const imageData = new ReactNativeFile({ uri, type, name });
            onSend({ attachment: imageData });
          } else {
            this.setState({ notify: t('attachment.errorMsg') });
          }
        }
      } else {
        this.setState({ notify: t('permission.errorMsg') });
      }
    };
github srtucker22 / chatty / client / src / screens / settings.screen.js View on Github external
}).then((file) => {
      const avatar = new ReactNativeFile({
        name: 'avatar',
        type: file.mime,
        size: file.size,
        path: file.path,
        uri: file.path,
      });
      self.setState({ avatar });
    });
  }
github benawad / fullstack-graphql-airbnb-clone / packages / app / src / modules / shared / PictureField.tsx View on Github external
onPress = async () => {
    const { status } = await Permissions.getAsync(Permissions.CAMERA_ROLL);
    if (status !== "granted") {
      await Permissions.askAsync(Permissions.CAMERA_ROLL);
    }
    const imageResult = await ImagePicker.launchImageLibraryAsync({});
    if (!imageResult.cancelled) {
      const file = new ReactNativeFile({
        uri: imageResult.uri,
        type: imageResult.type,
        name: "picture"
      });
      const {
        field: { name },
        form: { setFieldValue }
      } = this.props;
      setFieldValue(name, file);
    }
  };
github srtucker22 / chatty / client / src / screens / group-details.screen.js View on Github external
}).then((file) => {
      const icon = new ReactNativeFile({
        name: 'avatar',
        type: file.mime,
        size: file.size,
        path: file.path,
        uri: file.path,
      });
      self.setState({ icon });
    });
  }

apollo-upload-client

A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, or Blob instances), or else fetches a regular GraphQL POST or GET request (depending on the config and

MIT
Latest version published 6 months ago

Package Health Score

69 / 100
Full package analysis