Skip to content

Cannot create URL for blob! #440

@slytter

Description

@slytter

Describe the bug

Cannot upload images via method UploadClient.uploadFile on android using Expo Go.
I get the following error:

"Cannot create URL for blob!"

When I try to upload an image to Uploadcare via the JS api client, it fails on android only

Expected behavior

The image 'test.jpg' is expected to be uploaded to ImageCare upon following code being executed:

Code / screenshots

import { UploadClient } from '@uploadcare/upload-client'

const client = new UploadClient({ publicKey: 'XXXXXXXXX',  })

// Uploads an image to UploadCare
export const uploadToUploadCare = async (blob: Blob, fileName: string) => {
	try {
		const fileRef = await client.uploadFile(blob, {
			fileName,
		})

		return fileRef.cdnUrl

	} catch (e) {
		console.warn(e)
		throw e
	}
}

// Grabs first image from gallery and calls uploadToUploadCare
const testUploader = async () => {
	try {
		const images = await MediaLibrary.getAssetsAsync({
			sortBy: 'creationTime',
			first: 1,
			mediaType: [MediaType.photo, ],
		})

		const img = await fetch(images.assets[0].uri)
		const blob = await img.blob()

		await uploadToUploadCare(blob, 'test.jpg')

	} catch (e) {
		alert(e)
	}
}

testUploader()

Environment

  • Library version:
    5.1.1

  • Language/framework version:
    expo: 46.0.0 (managed workflow)
    react-native: 0.69.6

  • OS version:
    Android 11 (OnePlus 6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions