You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

11 months ago
// api/api_client.dart
// ignore_for_file: constant_identifier_names
import 'package:dio/dio.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import 'dart:io';
import 'package:path/path.dart';
const String _ReleaseURL = 'http://8.210.250.29:10010/musics';
11 months ago
///上传
class ReleaseApi {
final Dio dio = Dio();
Future<UniversalBean> release({
required File coverFile,
required File musicFile,
required String Authorization,
required String singerName,
required String name,
required String introduce,
}) async {
String coverFileName = basename(coverFile.path);
String musicFileName = basename(musicFile.path);
FormData formData = FormData.fromMap({
'Authorization': Authorization,
'coverFile': await MultipartFile.fromFile(coverFile.path, filename: coverFileName),
'musicFile': await MultipartFile.fromFile(musicFile.path, filename: musicFileName),
'singerName': singerName,
'name': name,
'introduce': introduce,
});
Response response = await dio.post(
_ReleaseURL,
queryParameters: {'singerName':singerName,'name':name,'introduce':introduce},
data: formData,
options: Options(headers:{'Authorization':Authorization,
})
11 months ago
);
print(response.data);
return UniversalBean.formMap(response.data);
}
}