generated at
複数の画像ファイルを一括してGyazoにuploadしてURLを保存するscript
2022-02-04 12:02:35 uploadToGyazoEasyAuthがscrapbox.ioで動かなくなったので使えなくなりました
hr
用途
Gyazoに紐付けた画像を作っておきたいときに使う

platform
どっちで作るか悩んでる
web browser
Deno
CLIを作るのがめんどい

使い方
js
const { convert } = await import("./script.js"); const { downloadObject } = await import("../web_browserから任意のデータをdownloadするscript/script.js"); const URLs = await convert(); await downloadObject(URLs);
compareFunction 比較用関数
これで画像ファイルの順番を決める
verbose true でログを出力する

とりあえずweb browserで作るか。

2021-05-25 02:39:23 .gif もuploadできるようにした

dependencies
script.js
import {uploadToGyazoEasyAuth} from '../uploadToGyazoEasyAuth/script.js'; import {throttle} from '../promise-parallel-throttle/script.js'; import {getLocalFiles} from '../簡単にfileをbrowserに取り込むscript/script.js'; import {BlobToURI} from '../BlobをData_URIに変換する/script.js'; export async function convert({compareFunction, convertName, verbose} = {}) { compareFunction ??= new Intl.Collator().compare; convertName ??= (title) => title; const files = await getLocalFiles({accept: '.png, .jpeg, .jpg, .gif', multiple: true}); const data = await Promise.all([...files] .sort((a, b) => compareFunction(a.name, b.name)) .map(async (file, index) => { return { uri: await BlobToURI(file), name: convertName(file.name), updated: file.lastModified, index, }; }) ); const URLs = []; let queue = data; let rest = []; while(queue.length > 0) { await throttle(queue.map(({uri, name, updated, index}) => async () => { try { const url = await uploadToGyazoEasyAuth({dataURI: uri, title: name, clientId: 'fd84cef882b9b51d8de3365cd28c86bc2cc8a1646ef05dbc641ca49278f9d0d6'}); URLs[index] = url; } catch(e) { rest.push({uri, name, updated, index}); } }), {maxInProgress: 10}); queue = [...rest]; rest = []; } if (verbose) console.log(URLs); return URLs; }

#2022-02-04 12:03:14
#2022-01-08 15:56:30 refactoring
#2021-05-25 02:39:39
#2021-04-02 22:43:19