question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any way to get blob of image

See original GitHub issue

Hi, i have a question, is any way to get blob of image, i need to handle source image with canvas after fetch

Is possible implement on CacheManager.prefetch or some way? For example:

CacheManager.prefetch(url).then((blob) => {})

Thank you.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
efstathiosntonascommented, Aug 9, 2022
1reaction
youniaogucommented, Aug 9, 2022

@youniaogu are you using typescript or javascript in your project?

If you’re using typescript, can you add this at line ~166 on CacheManager.ts and let me know if it’s what you need:

  static async prefetchBlob(
    source: string,
    options?: DownloadOptions
  ): Promise<string> {
    if (typeof source === "string") {
      const path = await CacheManager.get(source, options).getPath();
      const blob = await FileSystem.readFile(path, "base64");
      return blob;
    }
  }

Call it with

CacheManager.prefetchBlob(YOUR IMAGE URL).then((response) =>
      console.log(response)
    );

thank you for quick reply, i am using typescript

it look work, i am trying

Read more comments on GitHub >

github_iconTop Results From Across the Web

convert image into blob using javascript - Stack Overflow
You can do this in two ways: Load the image source using XMLHttpRequest() or fetch() instead of an image element; Convert image element...
Read more >
Blob - The Modern JavaScript Tutorial
// take any image let img = document.querySelector('img'); // make <canvas> of the same size ...
Read more >
How to convert an Image to blob using JavaScript?
How to convert an Image to blob using JavaScript? - Following is the code to convert an image to blob using JavaScript −Example...
Read more >
An Introduction to Blob API & Its Use Cases
Use Cases: 1. Upload in chunks, 2. Download data from the Internet, 3. Image Compression, 4. Create Blob URL, 5. Blob to Data...
Read more >
Convert A Blob To A File Using JavaScript - PQINA
In this quick tutorial we'll explore how to turn a Blob into a File. Fetch. The script below converts a fetch response into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found