1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-24 04:46:50 +02:00

chore(server) refactor serveFile and downloadFile endpoint (#978)

This commit is contained in:
Alex
2022-11-16 00:11:16 -06:00
committed by GitHub
parent 1db255fd3e
commit e799f35dd2
19 changed files with 116 additions and 175 deletions

View File

@ -178,19 +178,18 @@ class AssetApi {
return null;
}
/// Performs an HTTP 'GET /asset/download' operation and returns the [Response].
/// Performs an HTTP 'GET /asset/download/{assetId}' operation and returns the [Response].
/// Parameters:
///
/// * [String] aid (required):
///
/// * [String] did (required):
/// * [String] assetId (required):
///
/// * [bool] isThumb:
///
/// * [bool] isWeb:
Future<Response> downloadFileWithHttpInfo(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
Future<Response> downloadFileWithHttpInfo(String assetId, { bool? isThumb, bool? isWeb, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/download';
final path = r'/asset/download/{assetId}'
.replaceAll('{assetId}', assetId);
// ignore: prefer_final_locals
Object? postBody;
@ -199,8 +198,6 @@ class AssetApi {
final headerParams = <String, String>{};
final formParams = <String, String>{};
queryParams.addAll(_queryParams('', 'aid', aid));
queryParams.addAll(_queryParams('', 'did', did));
if (isThumb != null) {
queryParams.addAll(_queryParams('', 'isThumb', isThumb));
}
@ -224,15 +221,13 @@ class AssetApi {
/// Parameters:
///
/// * [String] aid (required):
///
/// * [String] did (required):
/// * [String] assetId (required):
///
/// * [bool] isThumb:
///
/// * [bool] isWeb:
Future<Object?> downloadFile(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
final response = await downloadFileWithHttpInfo(aid, did, isThumb: isThumb, isWeb: isWeb, );
Future<Object?> downloadFile(String assetId, { bool? isThumb, bool? isWeb, }) async {
final response = await downloadFileWithHttpInfo(assetId, isThumb: isThumb, isWeb: isWeb, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
@ -841,19 +836,18 @@ class AssetApi {
return null;
}
/// Performs an HTTP 'GET /asset/file' operation and returns the [Response].
/// Performs an HTTP 'GET /asset/file/{assetId}' operation and returns the [Response].
/// Parameters:
///
/// * [String] aid (required):
///
/// * [String] did (required):
/// * [String] assetId (required):
///
/// * [bool] isThumb:
///
/// * [bool] isWeb:
Future<Response> serveFileWithHttpInfo(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
Future<Response> serveFileWithHttpInfo(String assetId, { bool? isThumb, bool? isWeb, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/file';
final path = r'/asset/file/{assetId}'
.replaceAll('{assetId}', assetId);
// ignore: prefer_final_locals
Object? postBody;
@ -862,8 +856,6 @@ class AssetApi {
final headerParams = <String, String>{};
final formParams = <String, String>{};
queryParams.addAll(_queryParams('', 'aid', aid));
queryParams.addAll(_queryParams('', 'did', did));
if (isThumb != null) {
queryParams.addAll(_queryParams('', 'isThumb', isThumb));
}
@ -887,15 +879,13 @@ class AssetApi {
/// Parameters:
///
/// * [String] aid (required):
///
/// * [String] did (required):
/// * [String] assetId (required):
///
/// * [bool] isThumb:
///
/// * [bool] isWeb:
Future<Object?> serveFile(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
final response = await serveFileWithHttpInfo(aid, did, isThumb: isThumb, isWeb: isWeb, );
Future<Object?> serveFile(String assetId, { bool? isThumb, bool? isWeb, }) async {
final response = await serveFileWithHttpInfo(assetId, isThumb: isThumb, isWeb: isWeb, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}