feat(frontend): アップロードするファイルの名前をランダム文字列にできるように (#13688)
* feat(frontend): アップロードするファイルの名前をランダム文字列にできるように * Update Changelog * refactor * 設定項目を移動 * fix * 「オリジナルのファイル名を保持」に変更 * 拡張子を付加するように
This commit is contained in:
parent
eb1ef1484a
commit
f5100cc81f
6 changed files with 27 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
import { reactive, ref } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { readAndCompressImage } from '@misskey-dev/browser-image-resizer';
|
||||
import { getCompressionConfig } from './upload/compress-config.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
|
@ -39,13 +40,16 @@ export function uploadFile(
|
|||
if (folder && typeof folder === 'object') folder = folder.id;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = Math.random().toString();
|
||||
const id = uuid();
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = async (): Promise<void> => {
|
||||
const filename = name ?? file.name ?? 'untitled';
|
||||
const extension = filename.split('.').length > 1 ? '.' + filename.split('.').pop() : '';
|
||||
|
||||
const ctx = reactive<Uploading>({
|
||||
id: id,
|
||||
name: name ?? file.name ?? 'untitled',
|
||||
id,
|
||||
name: defaultStore.state.keepOriginalFilename ? filename : id + extension,
|
||||
progressMax: undefined,
|
||||
progressValue: undefined,
|
||||
img: window.URL.createObjectURL(file),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue