mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 20:26:10 +02:00
Add namespace with helpers for work with html5 blobs.
This commit is contained in:
parent
64d2b1e4dc
commit
a6ec2cb38b
1 changed files with 29 additions and 0 deletions
29
src/uxbox/util/blob.cljs
Normal file
29
src/uxbox/util/blob.cljs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
|
(ns uxbox.util.blob
|
||||||
|
"Helpers for work with HTML5 Blob objects.")
|
||||||
|
|
||||||
|
(defn ^boolean blob?
|
||||||
|
[v]
|
||||||
|
(instance? js/Blob v))
|
||||||
|
|
||||||
|
(defn create
|
||||||
|
"Create a blob from content."
|
||||||
|
([content]
|
||||||
|
(create content "application/octet-stream"))
|
||||||
|
([content mimetype]
|
||||||
|
(js/Blob. #js [content] #js {:type mimetype})))
|
||||||
|
|
||||||
|
(defn revoke-uri
|
||||||
|
[url]
|
||||||
|
(js/URL.revokeObjectURL url))
|
||||||
|
|
||||||
|
(defn create-uri
|
||||||
|
"Create a url from blob."
|
||||||
|
[b]
|
||||||
|
{:pre [(blob? b)]}
|
||||||
|
(js/URL.createObjectURL b))
|
Loading…
Add table
Add a link
Reference in a new issue