You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-10 23:22:22 +02:00
fix(server): more asset upload validation and docs (#1720)
* fix(server): more asset upload validation and docs
* remove unused DTO
* changed Object.keys() to Object.values()
* apply patch to openapi generator for web
* revert CreateAssetDto assetType enum
* resolve merge conflict
* Revert "resolve merge conflict"
This reverts commit 0e00805187
.
This commit is contained in:
24
mobile/openapi/doc/AssetApi.md
generated
24
mobile/openapi/doc/AssetApi.md
generated
@@ -1059,7 +1059,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)
|
||||
|
||||
# **uploadFile**
|
||||
> AssetFileUploadResponseDto uploadFile(assetData)
|
||||
> AssetFileUploadResponseDto uploadFile(assetType, assetData, deviceAssetId, deviceId, createdAt, modifiedAt, isFavorite, fileExtension, livePhotoData, isVisible, duration)
|
||||
|
||||
|
||||
|
||||
@@ -1076,10 +1076,20 @@ import 'package:openapi/api.dart';
|
||||
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);
|
||||
|
||||
final api_instance = AssetApi();
|
||||
final assetType = ; // AssetTypeEnum |
|
||||
final assetData = BINARY_DATA_HERE; // MultipartFile |
|
||||
final deviceAssetId = deviceAssetId_example; // String |
|
||||
final deviceId = deviceId_example; // String |
|
||||
final createdAt = createdAt_example; // String |
|
||||
final modifiedAt = modifiedAt_example; // String |
|
||||
final isFavorite = true; // bool |
|
||||
final fileExtension = fileExtension_example; // String |
|
||||
final livePhotoData = BINARY_DATA_HERE; // MultipartFile |
|
||||
final isVisible = true; // bool |
|
||||
final duration = duration_example; // String |
|
||||
|
||||
try {
|
||||
final result = api_instance.uploadFile(assetData);
|
||||
final result = api_instance.uploadFile(assetType, assetData, deviceAssetId, deviceId, createdAt, modifiedAt, isFavorite, fileExtension, livePhotoData, isVisible, duration);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling AssetApi->uploadFile: $e\n');
|
||||
@@ -1090,7 +1100,17 @@ try {
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**assetType** | [**AssetTypeEnum**](AssetTypeEnum.md)| |
|
||||
**assetData** | **MultipartFile**| |
|
||||
**deviceAssetId** | **String**| |
|
||||
**deviceId** | **String**| |
|
||||
**createdAt** | **String**| |
|
||||
**modifiedAt** | **String**| |
|
||||
**isFavorite** | **bool**| |
|
||||
**fileExtension** | **String**| |
|
||||
**livePhotoData** | **MultipartFile**| | [optional]
|
||||
**isVisible** | **bool**| | [optional]
|
||||
**duration** | **String**| | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
|
87
mobile/openapi/lib/api/asset_api.dart
generated
87
mobile/openapi/lib/api/asset_api.dart
generated
@@ -1164,8 +1164,28 @@ class AssetApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [AssetTypeEnum] assetType (required):
|
||||
///
|
||||
/// * [MultipartFile] assetData (required):
|
||||
Future<Response> uploadFileWithHttpInfo(MultipartFile assetData,) async {
|
||||
///
|
||||
/// * [String] deviceAssetId (required):
|
||||
///
|
||||
/// * [String] deviceId (required):
|
||||
///
|
||||
/// * [String] createdAt (required):
|
||||
///
|
||||
/// * [String] modifiedAt (required):
|
||||
///
|
||||
/// * [bool] isFavorite (required):
|
||||
///
|
||||
/// * [String] fileExtension (required):
|
||||
///
|
||||
/// * [MultipartFile] livePhotoData:
|
||||
///
|
||||
/// * [bool] isVisible:
|
||||
///
|
||||
/// * [String] duration:
|
||||
Future<Response> uploadFileWithHttpInfo(AssetTypeEnum assetType, MultipartFile assetData, String deviceAssetId, String deviceId, String createdAt, String modifiedAt, bool isFavorite, String fileExtension, { MultipartFile? livePhotoData, bool? isVisible, String? duration, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/asset/upload';
|
||||
|
||||
@@ -1180,11 +1200,52 @@ class AssetApi {
|
||||
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest('POST', Uri.parse(path));
|
||||
if (assetType != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'assetType'] = parameterToString(assetType);
|
||||
}
|
||||
if (assetData != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'assetData'] = assetData.field;
|
||||
mp.files.add(assetData);
|
||||
}
|
||||
if (livePhotoData != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'livePhotoData'] = livePhotoData.field;
|
||||
mp.files.add(livePhotoData);
|
||||
}
|
||||
if (deviceAssetId != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'deviceAssetId'] = parameterToString(deviceAssetId);
|
||||
}
|
||||
if (deviceId != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'deviceId'] = parameterToString(deviceId);
|
||||
}
|
||||
if (createdAt != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'createdAt'] = parameterToString(createdAt);
|
||||
}
|
||||
if (modifiedAt != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'modifiedAt'] = parameterToString(modifiedAt);
|
||||
}
|
||||
if (isFavorite != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'isFavorite'] = parameterToString(isFavorite);
|
||||
}
|
||||
if (isVisible != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'isVisible'] = parameterToString(isVisible);
|
||||
}
|
||||
if (fileExtension != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'fileExtension'] = parameterToString(fileExtension);
|
||||
}
|
||||
if (duration != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'duration'] = parameterToString(duration);
|
||||
}
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
@@ -1204,9 +1265,29 @@ class AssetApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [AssetTypeEnum] assetType (required):
|
||||
///
|
||||
/// * [MultipartFile] assetData (required):
|
||||
Future<AssetFileUploadResponseDto?> uploadFile(MultipartFile assetData,) async {
|
||||
final response = await uploadFileWithHttpInfo(assetData,);
|
||||
///
|
||||
/// * [String] deviceAssetId (required):
|
||||
///
|
||||
/// * [String] deviceId (required):
|
||||
///
|
||||
/// * [String] createdAt (required):
|
||||
///
|
||||
/// * [String] modifiedAt (required):
|
||||
///
|
||||
/// * [bool] isFavorite (required):
|
||||
///
|
||||
/// * [String] fileExtension (required):
|
||||
///
|
||||
/// * [MultipartFile] livePhotoData:
|
||||
///
|
||||
/// * [bool] isVisible:
|
||||
///
|
||||
/// * [String] duration:
|
||||
Future<AssetFileUploadResponseDto?> uploadFile(AssetTypeEnum assetType, MultipartFile assetData, String deviceAssetId, String deviceId, String createdAt, String modifiedAt, bool isFavorite, String fileExtension, { MultipartFile? livePhotoData, bool? isVisible, String? duration, }) async {
|
||||
final response = await uploadFileWithHttpInfo(assetType, assetData, deviceAssetId, deviceId, createdAt, modifiedAt, isFavorite, fileExtension, livePhotoData: livePhotoData, isVisible: isVisible, duration: duration, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
|
2
mobile/openapi/test/asset_api_test.dart
generated
2
mobile/openapi/test/asset_api_test.dart
generated
@@ -166,7 +166,7 @@ void main() {
|
||||
|
||||
//
|
||||
//
|
||||
//Future<AssetFileUploadResponseDto> uploadFile(MultipartFile assetData) async
|
||||
//Future<AssetFileUploadResponseDto> uploadFile(AssetTypeEnum assetType, MultipartFile assetData, String deviceAssetId, String deviceId, String createdAt, String modifiedAt, bool isFavorite, String fileExtension, { MultipartFile livePhotoData, bool isVisible, String duration }) async
|
||||
test('test uploadFile', () async {
|
||||
// TODO
|
||||
});
|
||||
|
Reference in New Issue
Block a user