mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Implement s3 storage.
Use uuid as file id.
This commit is contained in:
@@ -74,7 +74,7 @@ export interface Storage {
|
||||
}
|
||||
|
||||
export interface RFile {
|
||||
id: number;
|
||||
id: string;
|
||||
filename: string;
|
||||
description: string;
|
||||
}
|
||||
|
@@ -488,7 +488,7 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
async getFile(fileId: number): Promise<Response<RFile>> {
|
||||
async getFile(fileId: string): Promise<Response<RFile>> {
|
||||
try {
|
||||
const response = await axios.get(`${this.apiBaseUrl}/files/${fileId}`);
|
||||
return response.data;
|
||||
@@ -501,7 +501,7 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
async updateFile(fileId: number, filename: string, description: string): Promise<Response<RFile>> {
|
||||
async updateFile(fileId: string, filename: string, description: string): Promise<Response<RFile>> {
|
||||
try {
|
||||
const response = await axios.put(`${this.apiBaseUrl}/files/${fileId}`, {
|
||||
filename,
|
||||
@@ -530,7 +530,7 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
getFileDownloadLink(fileId: number): string {
|
||||
getFileDownloadLink(fileId: string): string {
|
||||
return `${this.apiBaseUrl}/files/download/${fileId}`;
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ export class UploadingTask extends Listenable {
|
||||
this.onFinished = onFinished;
|
||||
}
|
||||
|
||||
async upload(id: number) {
|
||||
async upload() {
|
||||
let index = 0;
|
||||
while (index < this.blocks.length) {
|
||||
if (this.blocks[index] || this.uploadingBlocks.includes(index)) {
|
||||
@@ -67,7 +67,6 @@ export class UploadingTask extends Listenable {
|
||||
if (this.status !== UploadingStatus.UPLOADING) {
|
||||
return;
|
||||
}
|
||||
console.log(`${id}: uploading block ${index}`);
|
||||
this.uploadingBlocks.push(index);
|
||||
const start = index * this.blockSize;
|
||||
const end = Math.min(start + this.blockSize, this.file.size);
|
||||
@@ -88,7 +87,6 @@ export class UploadingTask extends Listenable {
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log(`${id}: uploaded block ${index}`);
|
||||
this.blocks[index] = true;
|
||||
this.finishedBlocksCount++;
|
||||
this.uploadingBlocks = this.uploadingBlocks.filter(i => i !== index);
|
||||
@@ -101,10 +99,10 @@ export class UploadingTask extends Listenable {
|
||||
this.status = UploadingStatus.UPLOADING;
|
||||
this.notifyListeners();
|
||||
await Promise.all([
|
||||
this.upload(0),
|
||||
this.upload(1),
|
||||
this.upload(2),
|
||||
this.upload(3),
|
||||
this.upload(),
|
||||
this.upload(),
|
||||
this.upload(),
|
||||
this.upload(),
|
||||
])
|
||||
if (this.status !== UploadingStatus.UPLOADING) {
|
||||
return;
|
||||
|
@@ -71,7 +71,7 @@ function UserTable({ page, searchKeyword, totalPagesCallback }: { page: number,
|
||||
|
||||
useEffect(() => {
|
||||
fetchUsers();
|
||||
}, [page, searchKeyword]);
|
||||
}, [fetchUsers]);
|
||||
|
||||
const handleChanged = useCallback(async () => {
|
||||
setUsers(null);
|
||||
|
Reference in New Issue
Block a user