Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#768386 [Fix] - Fix filename when channel is instagram #283

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ class DSImageMessageBubbleController extends GetxController {
}

final uri = Uri.parse(url);
final identifier = uri.queryParameters['asset_id'] ?? uri.path;

final cachePath = await DSDirectoryFormatter.getCachePath(
type: mediaType!,
filename: md5.convert(utf8.encode(uri.path)).toString(),
filename: md5.convert(utf8.encode(identifier)).toString(),
);

if (File(cachePath).existsSync()) {
Expand Down
13 changes: 10 additions & 3 deletions lib/src/controllers/chat/ds_video_message_bubble.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DSVideoMessageBubbleController {
Future<void> getStoredVideo() async {
try {
isLoadingThumbnail.value = true;
final fileName = md5.convert(utf8.encode(Uri.parse(url).path)).toString();
final fileName = _getFileName(url);

final fullPath = await DSDirectoryFormatter.getCachePath(
type: type,
Expand All @@ -72,7 +72,7 @@ class DSVideoMessageBubbleController {
}

Future<String> getFullThumbnailPath() async {
final fileName = md5.convert(utf8.encode(Uri.parse(url).path)).toString();
final fileName = _getFileName(url);

return DSDirectoryFormatter.getCachePath(
type: 'image/png',
Expand All @@ -86,7 +86,7 @@ class DSVideoMessageBubbleController {
try {
final cachePath = await DSDirectoryFormatter.getCachePath(
type: 'video/mp4',
filename: md5.convert(utf8.encode(Uri.parse(url).path)).toString(),
filename: _getFileName(url),
);

final outputFile = File(cachePath);
Expand Down Expand Up @@ -143,4 +143,11 @@ class DSVideoMessageBubbleController {

return '${getSize(downloadProgress.value)} / ${getSize(maximumProgress.value)}';
}

String _getFileName(String url) {
final uri = Uri.parse(url);
final identifier = uri.queryParameters['asset_id'] ?? uri.path;

return md5.convert(utf8.encode(identifier)).toString();
}
}