Added file details display

- Added password generator logic to backend
- Added UI for file details
This commit is contained in:
2024-02-16 17:27:06 +01:00
parent 58e3dd0af5
commit 43e0eb1766
6 changed files with 95 additions and 37 deletions

View File

@ -27,7 +27,6 @@ export class UploadComponent {
singleDownload: boolean = false;
fileDescription: string = '';
passwordProtected: boolean = false;
password: string = ''; // Generated by the server for only this file
uploadStarted: boolean = false;
uploadProgress = 0; // Real progress
@ -35,6 +34,8 @@ export class UploadComponent {
uploadFinished = false;
uploadSpeedBps: number = 0;
uploadData: FileDetails | null = null;
fileUrls: { downloadUrl: string, statusUrl: string, deleteUrl: string } | null = null;
constructor(private developmentStore: DevelopmentStore) {
@ -98,6 +99,8 @@ export class UploadComponent {
.then(response => {
console.log('Upload completed successfully!');
console.log(response.data);
this.fileUrls = this.buildFileUrls(response.data);
this.uploadData = response.data;
this.uploadFinished = true;
})
.catch(error => {
@ -106,13 +109,26 @@ export class UploadComponent {
}
}
buildFileUrls(fileDetails: FileDetails) {
const baseUrl = this.developmentStore.getBaseUrl();
const fileId = fileDetails.fileId;
const downloadUrl = `${baseUrl}download?fileId=${fileId}`;
const deleteUrl = `${baseUrl}api/v1/deletefile?fileId=${fileId}`;
const statusUrl = `${baseUrl}status?fileId=${fileId}`;
return {
downloadUrl,
statusUrl,
deleteUrl,
}; }
buildFormDataObject(): FormData {
const formData = new FormData();
formData.append('file', this.fileToUpload as Blob);
formData.append('password', this.passwordProtected ? this.password : '');
formData.append('passwordProtected', this.passwordProtected ? 'true' : 'false');
formData.append('singleDownload', this.singleDownload.toString());
formData.append('shortStorage', this.shortStorage.toString());
formData.append('fileDescription', this.fileDescription);
console.log(formData.get("passwordProtected"));
return formData;
}
@ -169,3 +185,12 @@ export class UploadComponent {
}
}
}
interface FileDetails {
fileId: string;
fileName: string;
message: string;
passwordProtected: boolean;
singleDownload: boolean;
uploadDate: string;
password: string;
}