feat(server): multi archive downloads (#956)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user