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

@@ -79,7 +79,7 @@ Class | Method | HTTP request | Description
*AssetApi* | [**checkDuplicateAsset**](doc//AssetApi.md#checkduplicateasset) | **POST** /asset/check |
*AssetApi* | [**checkExistingAssets**](doc//AssetApi.md#checkexistingassets) | **POST** /asset/exist |
*AssetApi* | [**deleteAsset**](doc//AssetApi.md#deleteasset) | **DELETE** /asset |
*AssetApi* | [**downloadFile**](doc//AssetApi.md#downloadfile) | **GET** /asset/download |
*AssetApi* | [**downloadFile**](doc//AssetApi.md#downloadfile) | **GET** /asset/download/{assetId} |
*AssetApi* | [**downloadLibrary**](doc//AssetApi.md#downloadlibrary) | **GET** /asset/download-library |
*AssetApi* | [**getAllAssets**](doc//AssetApi.md#getallassets) | **GET** /asset |
*AssetApi* | [**getAssetById**](doc//AssetApi.md#getassetbyid) | **GET** /asset/assetById/{assetId} |
@@ -92,7 +92,7 @@ Class | Method | HTTP request | Description
*AssetApi* | [**getCuratedObjects**](doc//AssetApi.md#getcuratedobjects) | **GET** /asset/curated-objects |
*AssetApi* | [**getUserAssetsByDeviceId**](doc//AssetApi.md#getuserassetsbydeviceid) | **GET** /asset/{deviceId} |
*AssetApi* | [**searchAsset**](doc//AssetApi.md#searchasset) | **POST** /asset/search |
*AssetApi* | [**serveFile**](doc//AssetApi.md#servefile) | **GET** /asset/file |
*AssetApi* | [**serveFile**](doc//AssetApi.md#servefile) | **GET** /asset/file/{assetId} |
*AssetApi* | [**updateAssetById**](doc//AssetApi.md#updateassetbyid) | **PUT** /asset/assetById/{assetId} |
*AssetApi* | [**uploadFile**](doc//AssetApi.md#uploadfile) | **POST** /asset/upload |
*AuthenticationApi* | [**adminSignUp**](doc//AuthenticationApi.md#adminsignup) | **POST** /auth/admin-sign-up |

View File

@@ -12,7 +12,7 @@ Method | HTTP request | Description
[**checkDuplicateAsset**](AssetApi.md#checkduplicateasset) | **POST** /asset/check |
[**checkExistingAssets**](AssetApi.md#checkexistingassets) | **POST** /asset/exist |
[**deleteAsset**](AssetApi.md#deleteasset) | **DELETE** /asset |
[**downloadFile**](AssetApi.md#downloadfile) | **GET** /asset/download |
[**downloadFile**](AssetApi.md#downloadfile) | **GET** /asset/download/{assetId} |
[**downloadLibrary**](AssetApi.md#downloadlibrary) | **GET** /asset/download-library |
[**getAllAssets**](AssetApi.md#getallassets) | **GET** /asset |
[**getAssetById**](AssetApi.md#getassetbyid) | **GET** /asset/assetById/{assetId} |
@@ -25,7 +25,7 @@ Method | HTTP request | Description
[**getCuratedObjects**](AssetApi.md#getcuratedobjects) | **GET** /asset/curated-objects |
[**getUserAssetsByDeviceId**](AssetApi.md#getuserassetsbydeviceid) | **GET** /asset/{deviceId} |
[**searchAsset**](AssetApi.md#searchasset) | **POST** /asset/search |
[**serveFile**](AssetApi.md#servefile) | **GET** /asset/file |
[**serveFile**](AssetApi.md#servefile) | **GET** /asset/file/{assetId} |
[**updateAssetById**](AssetApi.md#updateassetbyid) | **PUT** /asset/assetById/{assetId} |
[**uploadFile**](AssetApi.md#uploadfile) | **POST** /asset/upload |
@@ -176,7 +176,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **downloadFile**
> Object downloadFile(aid, did, isThumb, isWeb)
> Object downloadFile(assetId, isThumb, isWeb)
@@ -191,13 +191,12 @@ import 'package:openapi/api.dart';
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);
final api_instance = AssetApi();
final aid = aid_example; // String |
final did = did_example; // String |
final assetId = assetId_example; // String |
final isThumb = true; // bool |
final isWeb = true; // bool |
try {
final result = api_instance.downloadFile(aid, did, isThumb, isWeb);
final result = api_instance.downloadFile(assetId, isThumb, isWeb);
print(result);
} catch (e) {
print('Exception when calling AssetApi->downloadFile: $e\n');
@@ -208,8 +207,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**aid** | **String**| |
**did** | **String**| |
**assetId** | **String**| |
**isThumb** | **bool**| | [optional]
**isWeb** | **bool**| | [optional]
@@ -781,7 +779,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **serveFile**
> Object serveFile(aid, did, isThumb, isWeb)
> Object serveFile(assetId, isThumb, isWeb)
@@ -796,13 +794,12 @@ import 'package:openapi/api.dart';
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);
final api_instance = AssetApi();
final aid = aid_example; // String |
final did = did_example; // String |
final assetId = assetId_example; // String |
final isThumb = true; // bool |
final isWeb = true; // bool |
try {
final result = api_instance.serveFile(aid, did, isThumb, isWeb);
final result = api_instance.serveFile(assetId, isThumb, isWeb);
print(result);
} catch (e) {
print('Exception when calling AssetApi->serveFile: $e\n');
@@ -813,8 +810,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**aid** | **String**| |
**did** | **String**| |
**assetId** | **String**| |
**isThumb** | **bool**| | [optional]
**isWeb** | **bool**| | [optional]

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));
}