How to use @react-native-community/cameraroll - 10 common examples

To help you get started, we’ve selected a few @react-native-community/cameraroll 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 Doha26 / Instagram-clone / src / components / cameraRollPicker / index.tsx View on Github external
var fetchParams = {
            first: 1000,
            groupTypes: groupTypes,
            assetType: assetType,
        };

        if (Platform.OS === "android") {
            // not supported in android
            delete fetchParams.groupTypes;
        }

        if (this.state.lastCursor) {
            fetchParams.after = this.state.lastCursor;
        }

        CameraRoll.getPhotos(fetchParams)
            .then((data) => this._appendImages(data), (e) => console.log(e));
    }
github jeanpan / react-native-camera-roll-picker / index.js View on Github external
const fetchParams = {
      first: 100,
      groupTypes,
      assetType,
    };

    if (Platform.OS === 'android') {
      // not supported in android
      delete fetchParams.groupTypes;
    }

    if (this.state.lastCursor) {
      fetchParams.after = this.state.lastCursor;
    }

    CameraRoll.getPhotos(fetchParams)
      .then(data => this.appendImages(data), e => console.log(e));
  }
github mattermost / mattermost-mobile / app / screens / image_preview / downloader.ios.js View on Github external
this.downloadTask = RNFetchBlob.config(options).fetch('GET', imageUrl);
            this.downloadTask.progress((received, total) => {
                const progress = (received / total) * 100;
                if (this.mounted) {
                    this.setState({
                        progress,
                        started: true,
                    });
                }
            });

            const res = await this.downloadTask;
            let path = res.path();

            if (saveToCameraRoll) {
                path = await CameraRoll.saveToCameraRoll(path, 'photo'); /* eslint-disable-line require-atomic-updates */
            }

            if (this.mounted) {
                this.setState({
                    progress: 100,
                }, async () => {
                    if (this.state.didCancel) {
                        try {
                            await RNFetchBlob.fs.unlink(path);
                        } finally {
                            this.downloadDidCancel();
                        }
                    } else {
                        this.props.onDownloadSuccess();
                    }
                });
github keybase / client / shared / actions / platform-specific / index.native.tsx View on Github external
export async function saveAttachmentToCameraRoll(filePath: string, mimeType: string): Promise {
  const fileURL = 'file://' + filePath
  const saveType = mimeType.startsWith('video') ? 'video' : 'photo'
  const logPrefix = '[saveAttachmentToCameraRoll] '
  try {
    await requestPermissionsToWrite()
    logger.info(logPrefix + `Attempting to save as ${saveType}`)
    await CameraRoll.saveToCameraRoll(fileURL, saveType)
    logger.info(logPrefix + 'Success')
  } catch (e) {
    // This can fail if the user backgrounds too quickly, so throw up a local notification
    // just in case to get their attention.
    PushNotifications.localNotification({
      message: `Failed to save ${saveType} to camera roll`,
    })
    logger.debug(logPrefix + 'failed to save: ' + e)
    throw e
  } finally {
    require('rn-fetch-blob').default.fs.unlink(filePath)
  }
}
github Doha26 / Instagram-clone / src / screens / Search / index.tsx View on Github external
componentDidMount() {
        const fetchParams = {
            first: 25,
        };
        CameraRoll.getPhotos(fetchParams).then((data: any) => {
            const assets = data.edges;
            const images = assets.map((asset: any) => asset.node.image);
            this.setState({
                tmpImages: images,
            });
            const imgArray: any = [];
            this.state.tmpImages.forEach(function (image: any, index: number) {
                imgArray.push({uri: image.uri, id: index, height: Math.round(Math.random() * 50 + 100)})
            });
            this.setState({images: imgArray});
        }).catch((err: any) => {
            console.log("Error retrieving photos");
        });
    }
github Doha26 / Instagram-clone / src / screens / Root / index.tsx View on Github external
componentDidMount(): void {
        const fetchParams = {
            first: 25,
        };
        CameraRoll.getPhotos(fetchParams).then((data: any) => {
            const assets = data.edges;
            const images = assets.map((asset: any) => asset.node.image);
            this.setState({
                tmpImages: images,
            });
            const imgArray: any = [];
            this.state.tmpImages.forEach(function (image: any, index: number) {
                imgArray.push({uri: image.uri, id: index, height: Math.round(Math.random() * 50 + 100)})
            });
            this.setState({images: imgArray});
            
            this.onBlurViewLoaded.bind(this)
        }).catch((err: any) => {
            console.log("Error retrieving photos");
        });
    }
github berty / berty / js / packages / components / chat / file-uploads / GallerySection.tsx View on Github external
async function getInitalGalleryContents() {
		try {
			const photos = await CameraRoll.getPhotos({
				first: GALLERY_IMAGE_PER_PAGE,
			})

			setGalleryContents(
				photos.edges.map(({ node: { image: { filename, uri }, type: mime } }) => ({
					filename: filename || '',
					uri,
					mimeType: mime,
				})),
			)

			setGalleryImageEndCursor(photos.page_info.has_next_page ? photos.page_info.end_cursor : null)
		} catch (err) {
			console.log('getPhotos err', err)
		}
	}
github berty / berty / js / packages / components / modals / ImageView.tsx View on Github external
onPress() {
				images[currentIndex] &&
					CameraRoll.save(images[currentIndex].uri, { type: 'photo' })
						.then(() => {
							setModalVisibility(false)
							handleMessage(t('chat.files.image-saved'))
						})
						.catch((err) => console.log(err))
			},
		},
github iyegoroff / react-native-image-filter-kit / examples / ImageExtraction / src / App.tsx View on Github external
const saveImage = (uri: string) => (
  CameraRoll.saveToCameraRoll(uri, 'photo')
)
github alphasp / pxview / src / components / HOC / enhanceSaveImage.js View on Github external
workId,
          workTitle,
          workType,
          saveImageSettings,
          imageIndex || index,
        );
        try {
          const res = await RNFetchBlob.config({
            path: `${imagesDir}/${fileName}`,
          }).fetch('GET', url, {
            referer: 'http://www.pixiv.net',
          });
          const filePath = res.path();
          if (Platform.OS === 'ios') {
            try {
              await CameraRoll.saveToCameraRoll(filePath);
              this.showToast(
                i18n.formatString(i18n.saveImageSuccess, fileName),
              );
            } catch (err) {
              this.showToast(i18n.formatString(i18n.saveImageError, fileName));
            }
          } else if (Platform.OS === 'android') {
            this.showToast(i18n.formatString(i18n.saveImageSuccess, fileName));
            try {
              await RNFetchBlob.fs.scanFile([{ path: filePath }]);
            } catch (err) {}
          }
        } catch (err) {
          this.showToast(i18n.formatString(i18n.saveImageError, fileName));
        }
      });

@react-native-community/cameraroll

React Native Camera Roll for iOS & Android

MIT
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis