Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Add Blob URL actions (create|revoke)ObjectURL#78

Merged
garyb merged 1 commit into
purescript-deprecated:masterfrom
justinwoo:add-blob-actions
Mar 4, 2017
Merged

Add Blob URL actions (create|revoke)ObjectURL#78
garyb merged 1 commit into
purescript-deprecated:masterfrom
justinwoo:add-blob-actions

Conversation

@justinwoo

@justinwoo justinwoo commented Feb 23, 2017

Copy link
Copy Markdown
Contributor

Blob URL methods are commonly supported and used for crap like getting a URL for use in audio tags when sourced from file inputs and whatnot. I thought it'd be nice to have this in the library since it'll probably be useful for others' and

(Maybe some things could be renamed to make this less messy, idk)

My own use:

              url <- H.liftEff $ url =<< window
              blob <- H.liftEff $ createObjectURL file url
              prevBlob <- H.gets _.file
              case prevBlob of
                Just x ->
                  H.liftEff $ revokeObjectURL (unwrap x) url

@justinwoo justinwoo force-pushed the add-blob-actions branch 3 times, most recently from 9e6ae44 to 5b948ca Compare February 23, 2017 21:48
@chexxor

chexxor commented Feb 23, 2017

Copy link
Copy Markdown
Contributor

👍 I need it for putting image preview in an img tag.

Comment thread src/DOM/HTML/URL.purs Outdated
import DOM.HTML.Types (URL)
import Data.Unit (Unit)

foreign import createObjectURL :: forall eff. URL -> File -> Eff (dom :: DOM | eff) String

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make URL the last argument, perhaps, to make it easier to use like this:

fileObjectUrl <- createObjectURL someFile =<< url =<< window

Discussed here also: #75

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sounds good, made the change

@garyb

garyb commented Mar 4, 2017

Copy link
Copy Markdown
Member

Thanks! Sorry for the hold up. It's kinda a shame we need a new URL type for this, but it makes sense given there is a real class backing it up.

@garyb garyb merged commit 676fd06 into purescript-deprecated:master Mar 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants