Merge branch 'mime-refactor-use-mime' into 'master'
Use mime instead of mime_type See merge request famedly/famedlysdk!368
This commit is contained in:
commit
ab812e0da2
|
@ -32,7 +32,7 @@ import 'package:famedlysdk/matrix_api/model/third_party_location.dart';
|
||||||
import 'package:famedlysdk/matrix_api/model/timeline_history_response.dart';
|
import 'package:famedlysdk/matrix_api/model/timeline_history_response.dart';
|
||||||
import 'package:famedlysdk/matrix_api/model/user_search_result.dart';
|
import 'package:famedlysdk/matrix_api/model/user_search_result.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:mime_type/mime_type.dart';
|
import 'package:mime/mime.dart';
|
||||||
import 'package:moor/moor.dart';
|
import 'package:moor/moor.dart';
|
||||||
|
|
||||||
import 'model/device.dart';
|
import 'model/device.dart';
|
||||||
|
@ -1326,7 +1326,8 @@ class MatrixApi {
|
||||||
fileName = fileName.split('/').last;
|
fileName = fileName.split('/').last;
|
||||||
var headers = <String, String>{};
|
var headers = <String, String>{};
|
||||||
headers['Authorization'] = 'Bearer $accessToken';
|
headers['Authorization'] = 'Bearer $accessToken';
|
||||||
headers['Content-Type'] = contentType ?? mime(fileName);
|
headers['Content-Type'] =
|
||||||
|
contentType ?? lookupMimeType(fileName, headerBytes: file);
|
||||||
fileName = Uri.encodeQueryComponent(fileName);
|
fileName = Uri.encodeQueryComponent(fileName);
|
||||||
final url =
|
final url =
|
||||||
'${homeserver.toString()}/_matrix/media/r0/upload?filename=$fileName';
|
'${homeserver.toString()}/_matrix/media/r0/upload?filename=$fileName';
|
||||||
|
|
|
@ -27,7 +27,7 @@ import 'package:famedlysdk/src/utils/room_update.dart';
|
||||||
import 'package:famedlysdk/src/utils/matrix_file.dart';
|
import 'package:famedlysdk/src/utils/matrix_file.dart';
|
||||||
import 'package:image/image.dart';
|
import 'package:image/image.dart';
|
||||||
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
|
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
|
||||||
import 'package:mime_type/mime_type.dart';
|
import 'package:mime/mime.dart';
|
||||||
import 'package:html_unescape/html_unescape.dart';
|
import 'package:html_unescape/html_unescape.dart';
|
||||||
|
|
||||||
import './user.dart';
|
import './user.dart';
|
||||||
|
@ -524,7 +524,7 @@ class Room {
|
||||||
String thumbnailUploadResp;
|
String thumbnailUploadResp;
|
||||||
|
|
||||||
var fileName = file.path.split('/').last;
|
var fileName = file.path.split('/').last;
|
||||||
final mimeType = mime(file.path) ?? '';
|
final mimeType = lookupMimeType(file.path, headerBytes: file.bytes) ?? '';
|
||||||
if (msgType == null) {
|
if (msgType == null) {
|
||||||
final metaType = (mimeType).split('/')[0];
|
final metaType = (mimeType).split('/')[0];
|
||||||
switch (metaType) {
|
switch (metaType) {
|
||||||
|
@ -647,7 +647,7 @@ class Room {
|
||||||
inReplyTo: inReplyTo,
|
inReplyTo: inReplyTo,
|
||||||
info: {
|
info: {
|
||||||
'size': file.size,
|
'size': file.size,
|
||||||
'mimetype': mime(file.path.split('/').last),
|
'mimetype': lookupMimeType(file.path, headerBytes: file.bytes),
|
||||||
'w': width,
|
'w': width,
|
||||||
'h': height,
|
'h': height,
|
||||||
});
|
});
|
||||||
|
@ -663,10 +663,9 @@ class Room {
|
||||||
int thumbnailWidth,
|
int thumbnailWidth,
|
||||||
int thumbnailHeight,
|
int thumbnailHeight,
|
||||||
Event inReplyTo}) async {
|
Event inReplyTo}) async {
|
||||||
var fileName = file.path.split('/').last;
|
|
||||||
var info = <String, dynamic>{
|
var info = <String, dynamic>{
|
||||||
'size': file.size,
|
'size': file.size,
|
||||||
'mimetype': mime(fileName),
|
'mimetype': lookupMimeType(file.path, headerBytes: file.bytes),
|
||||||
};
|
};
|
||||||
if (videoWidth != null) {
|
if (videoWidth != null) {
|
||||||
info['w'] = videoWidth;
|
info['w'] = videoWidth;
|
||||||
|
@ -678,7 +677,6 @@ class Room {
|
||||||
info['duration'] = duration;
|
info['duration'] = duration;
|
||||||
}
|
}
|
||||||
if (thumbnail != null && !(encrypted && client.encryptionEnabled)) {
|
if (thumbnail != null && !(encrypted && client.encryptionEnabled)) {
|
||||||
var thumbnailName = file.path.split('/').last;
|
|
||||||
final thumbnailUploadResp = await client.api.upload(
|
final thumbnailUploadResp = await client.api.upload(
|
||||||
thumbnail.bytes,
|
thumbnail.bytes,
|
||||||
thumbnail.path,
|
thumbnail.path,
|
||||||
|
@ -686,7 +684,8 @@ class Room {
|
||||||
info['thumbnail_url'] = thumbnailUploadResp;
|
info['thumbnail_url'] = thumbnailUploadResp;
|
||||||
info['thumbnail_info'] = {
|
info['thumbnail_info'] = {
|
||||||
'size': thumbnail.size,
|
'size': thumbnail.size,
|
||||||
'mimetype': mime(thumbnailName),
|
'mimetype':
|
||||||
|
lookupMimeType(thumbnail.path, headerBytes: thumbnail.bytes),
|
||||||
};
|
};
|
||||||
if (thumbnailWidth != null) {
|
if (thumbnailWidth != null) {
|
||||||
info['thumbnail_info']['w'] = thumbnailWidth;
|
info['thumbnail_info']['w'] = thumbnailWidth;
|
||||||
|
|
|
@ -353,13 +353,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.9.6+3"
|
version: "0.9.6+3"
|
||||||
mime_type:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: mime_type
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.3.0"
|
|
||||||
moor:
|
moor:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -9,7 +9,7 @@ environment:
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
http: ^0.12.1
|
http: ^0.12.1
|
||||||
mime_type: ^0.3.0
|
mime: ^0.9.6
|
||||||
canonical_json: ^1.0.0
|
canonical_json: ^1.0.0
|
||||||
image: ^2.1.4
|
image: ^2.1.4
|
||||||
markdown: ^2.1.3
|
markdown: ^2.1.3
|
||||||
|
|
Loading…
Reference in a new issue