blob stopped working in expo sdk 39

I noticed this as well. I got a work around working for the time being: Apparently you can still access the values via the FileSystem then you can get the file as base64 and then create a buffer from the base64 encoded value and send that as a blob. Here’s the code I used.

import { Buffer } from "buffer"; // get this via: npm install buffer
import * as FileSystem from "expo-file-system";

const path = "some/path/to/the/selected/image.png";

const result = await ImageManipulator.manipulateAsync(
  path,
  [{ resize: { width: 300 } }],
   {
    compress: 0.5,
    format: ImageManipulator.SaveFormat.JPEG,
  },
);
const options = { encoding: FileSystem.EncodingType.Base64 };
const base64Response = await FileSystem.readAsStringAsync(
    results.uri,
    options,
);

const blob = Buffer.from(base64Response, "base64");
// upload blob

I know this isn’t a “fix” for the actual problem but this is a work around until the bug is fixed.

3 Likes