Skip to content

Create blob backed up by filesystem #55

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 9 commits into from
Jul 28, 2020
Merged

Create blob backed up by filesystem #55

merged 9 commits into from
Jul 28, 2020

Conversation

jimmywarting
Copy link
Contributor

@jimmywarting jimmywarting commented Jul 24, 2020

haven't been any discussion about how to go about solving this so i have made a first attempt/design at creating a blob backed up by filesystem.

Think this could be useful for ppl who need to to work with FormData for example

const blobFrom = require('fetch-blob/from.js')
const fd = new FormData()
const blob = blobFrom('./wallpaper.png')
fd.append('portrait', blob, 'wallpaper.png')

This don't add to the bundle size unless you implicit import/require "fetch-blob/from.js"


i first thought about doing something like blob = Blob.from(path) but that would make it different from the spec and adds to the bundle cost

@codecov
Copy link

codecov bot commented Jul 24, 2020

Codecov Report

Merging #55 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #55   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         2    +1     
  Lines          176       231   +55     
  Branches        32        36    +4     
=========================================
+ Hits           176       231   +55     
Impacted Files Coverage Δ
from.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae6b565...cffb0be. Read the comment docs.

@Richienb Richienb changed the title create blob backed up by filesystem Create blob backed up by filesystem Jul 25, 2020
@jimmywarting jimmywarting requested a review from Richienb July 25, 2020 15:24
@jimmywarting jimmywarting added the enhancement New feature or request label Jul 25, 2020
Copy link
Member

@Richienb Richienb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't from.js be included in the files array in package.json?

@jimmywarting
Copy link
Contributor Author

have added from.js to files array now

@jimmywarting jimmywarting dismissed Richienb’s stale review July 28, 2020 15:40

can't find anything else that needs to be done

@jimmywarting jimmywarting merged commit 3217da9 into node-fetch:master Jul 28, 2020
@jimmywarting jimmywarting deleted the from branch July 28, 2020 15:42
@jimmywarting
Copy link
Contributor Author

just tried it out as a real developer

tried to install it: works ok
tried using it: works ok

like it better then native fs 🙂

import blobFrom from 'fetch-blob/from.js' 

const text = await blobFrom('package.json').text()
const arrayBuffer = await blobFrom('package.json').text()
const stream = blobFrom('package.json').stream()
const chunk = await blobFrom('package.json').slice(5, 10).text()

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants