Skip to content

Commit a630297

Browse files
committed
Adds blob to url functions
These are from the Fileapi at https://www.w3.org/TR/FileAPI/#creating-revoking These functions allow a url to be created from a blob, and for that url to be revoked. This allows parts of the dom to 'use' the blob as if it were an asset loaded by the browser
1 parent b98b742 commit a630297

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/Web/File/URL.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
3+
exports.createObjectURL = function (blob) {
4+
return function () {
5+
return URL.createObjectURL(blob);
6+
};
7+
};
8+
9+
exports.revokeObjectURL = function (url) {
10+
return function () {
11+
URL.revokeObjectURL(url);
12+
};
13+
};

src/Web/File/URL.purs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Web.File.Url
2+
(createObjectURL
3+
, revokeObjectURL
4+
) where
5+
6+
import Prelude
7+
import Effect (Effect)
8+
import Web.File.Blob (Blob)
9+
10+
11+
-- | Adds this blob to the url store
12+
-- | The string is a url that can be used to
13+
-- | 'download' the blob
14+
foreign import createObjectURL :: Blob -> Effect String
15+
16+
-- | Revoke a blob url from the url store
17+
-- | Doesn't throw errors on failure
18+
foreign import revokeObjectURL :: String -> Effect Unit

0 commit comments

Comments
 (0)