feat(server): multi archive downloads (#956)

This commit is contained in:
Jason Rasmussen
2022-11-15 10:51:56 -05:00
committed by GitHub
parent b5d75e2016
commit f2f255e6e6
26 changed files with 538 additions and 151 deletions
@@ -41,6 +41,8 @@ import { timeUtils } from '@app/common/utils';
import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto';
import { CheckExistingAssetsResponseDto } from './response-dto/check-existing-assets-response.dto';
import { UpdateAssetDto } from './dto/update-asset.dto';
import { DownloadService } from '../../modules/download/download.service';
import { DownloadDto } from './dto/download-library.dto';
const fileInfo = promisify(stat);
@@ -52,6 +54,8 @@ export class AssetService {
@InjectRepository(AssetEntity)
private assetRepository: Repository<AssetEntity>,
private downloadService: DownloadService,
) {}
public async createUserAsset(
@@ -140,6 +144,12 @@ export class AssetService {
return mapAsset(updatedAsset);
}
public async downloadLibrary(user: AuthUserDto, dto: DownloadDto) {
const assets = await this._assetRepository.getAllByUserId(user.id, dto.skip);
return this.downloadService.downloadArchive(dto.name || `library`, assets);
}
public async downloadFile(query: ServeFileDto, res: Res) {
try {
let fileReadStream = null;