Using react-aws-s3 and it gives error: undefined is not an object(evaluating 'e.type.split')

Viewed 46

I currently have a react native app that is pulling images from my AmazonS3 account but I am intending to give the user the ability to upload to my bucket and use/view the images on my app. but it is giving me following error while clicking on upload to s3 button:

undefined is not an object (evaluating 'e.type.split')

Code:

     const handleSubmit = async (listing, { resetForm }) => {
    uploadImage(listing)
    setProgress(0)
    setUploadVisible(true)
    const result = await listingsApi.addListing({ ...listing, location },
      progress => setProgress(progress))

    if (!result.ok) {
      setUploadVisible(false)
      alert('Could not save the listing.')
      return
    }
    resetForm()
  }

  const config = {
    bucketName: 'bucketName',
    dirName: '/assets',
    region: 'region',
    accessKeyId: 'AccessKey',
    secretAccessKey: 'SecretAccessKey',
  }
  const uploadImage = (listing) => {
    const ReactS3Client = new S3(config)
    const file = listing.images[0]
    ReactS3Client
      .uploadFile(file)
      .then(data => console.log(data))
      .catch(err => console.error(err))
  }
0 Answers
Related