Skip to content

Commit

Permalink
Merge pull request #376 from shiosyakeyakini-info/feature/fix_375
Browse files Browse the repository at this point in the history
#375 対応
  • Loading branch information
shiosyakeyakini-info authored Oct 8, 2023
2 parents ecfc461 + 186974b commit 3c78f90
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:dio/dio.dart';
import 'package:file/file.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mfm_parser/mfm_parser.dart';
Expand Down Expand Up @@ -283,14 +284,28 @@ class NoteCreateNotifier extends StateNotifier<NoteCreate> {
for (final file in state.files) {
switch (file) {
case ImageFile():
final fileName = file.fileName.toLowerCase();
var imageData = file.data;
try {
if (fileName.endsWith("jpg") ||
fileName.endsWith("jpeg") ||
fileName.endsWith("tiff") ||
fileName.endsWith("tif")) {
imageData =
await FlutterImageCompress.compressWithList(file.data);
}
} catch (e) {
print("failed to compress file");
}

final response = await misskey.drive.files.createAsBinary(
DriveFilesCreateRequest(
force: true,
name: file.fileName,
isSensitive: file.isNsfw,
comment: file.caption,
),
file.data,
imageData,
);
fileIds.add(response.id);

Expand Down
32 changes: 32 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.0-alpha.6"
flutter_image_compress:
dependency: "direct main"
description:
name: flutter_image_compress
sha256: "2725cce5c58fdeaf1db8f4203688228bb67e3523a66305ccaa6f99071beb6dc2"
url: "https://pub.dev"
source: hosted
version: "2.0.4"
flutter_image_compress_common:
dependency: transitive
description:
name: flutter_image_compress_common
sha256: "8e7299afe109dc4b97fda34bf0f4967cc1fc10bc8050c374d449cab262d095b3"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
flutter_image_compress_platform_interface:
dependency: transitive
description:
name: flutter_image_compress_platform_interface
sha256: "3c7e86da7540b1adfa919b461885a41a018d4a26544d0fcbeaa769f6542e603d"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
flutter_image_compress_web:
dependency: transitive
description:
name: flutter_image_compress_web
sha256: e879189dc7f246dcf8f06c07ee849231341508bf51e8ed7d5dcbe778ddde0e81
url: "https://pub.dev"
source: hosted
version: "0.1.3+1"
flutter_launcher_icons:
dependency: "direct dev"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ dependencies:
colorfilter_generator: ^0.0.8
matrix2d: ^1.0.4
twemoji_v2: ^0.5.3
flutter_image_compress: ^2.0.4

dependency_overrides:
image_editor:
Expand Down

0 comments on commit 3c78f90

Please sign in to comment.