Skip to content

Commit

Permalink
fix: Support for FileID.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Feb 2, 2024
1 parent ced0d88 commit b37e096
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions packages/katana_storage/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,14 @@ packages:
path: "../../katana"
relative: true
source: path
version: "2.10.2"
version: "2.11.0"
katana_storage:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.0.35"
version: "2.1.0"
lints:
dependency: transitive
description:
Expand Down
20 changes: 10 additions & 10 deletions packages/katana_storage/lib/src/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ class Storage extends ChangeNotifier implements ValueListenable<StorageValue?> {
///
/// 公開可能なURLを取得します。画像等を`Image.network`などで取得したい場合このURIを利用します。
Future<Uri> fetchPublicURI() => storageQuery.adapter.fetchPublicURI(
storageQuery.relativeRemotePath.trimQuery().trimStringRight("/"),
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
);

/// Get the URI to download the file.
///
/// ファイルをダウンロードするためのURIを取得します。
Future<Uri> fetchDownloadURI() async {
final path = await storageQuery.adapter.fetchDownloadURI(
storageQuery.relativeRemotePath.trimQuery().trimStringRight("/"),
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
);
notifyListeners();
return path;
Expand All @@ -121,7 +121,7 @@ class Storage extends ChangeNotifier implements ValueListenable<StorageValue?> {
_downloadCompleter = Completer();
try {
final localFile = await storageQuery.adapter.download(
storageQuery.relativeRemotePath.trimQuery().trimStringRight("/"),
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
localRelativePath?.trimQuery().trimStringRight("/"),
);
_value = _value?._copyWith(
Expand All @@ -146,13 +146,13 @@ class Storage extends ChangeNotifier implements ValueListenable<StorageValue?> {

/// Uploads a file located at [localFullPath] on the local to the remote location specified by [storageQuery].
///
/// You can wait in [uploading] while downloading.
/// While uploading, you can wait at [uploading].
///
/// The full path to the upload destination can be obtained as a return value.
///
/// ローカル上の[localFullPath]にあるファイルを[storageQuery]で指定されたリモート側の位置にアップロードします。
///
/// ダウンロード中は[uploading]で待つことができます。
/// アップロード中は[uploading]で待つことができます。
///
/// 戻り値としてアップロード先のフルパスを取得することが出来ます。
Future<StorageValue?> upload(String localFullPath) async {
Expand All @@ -164,7 +164,7 @@ class Storage extends ChangeNotifier implements ValueListenable<StorageValue?> {
try {
final remoteFile = await storageQuery.adapter.upload(
localFullPath.trimQuery().trimStringRight("/"),
storageQuery.relativeRemotePath.trimQuery().trimStringRight("/"),
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
);
_value = _value?._copyWith(
remote: remoteFile,
Expand All @@ -188,13 +188,13 @@ class Storage extends ChangeNotifier implements ValueListenable<StorageValue?> {

/// Uploads a file with the actual data in [uploadFileByte] to the location on the remote side specified by [storageQuery].
///
/// You can wait in [uploading] while downloading.
/// While uploading, you can wait at [uploading].
///
/// It takes a [StorageValue] as a return value and can retrieve both local and remote data.
///
/// [uploadFileByte]の実データを持つファイルを[storageQuery]で指定されたリモート側の位置にアップロードします。
///
/// ダウンロード中は[uploading]で待つことができます。
/// アップロード中は[uploading]で待つことができます。
///
/// 戻り値として[StorageValue]を受け取り、ローカルとリモートの両方のデータを取得することができます。
Future<StorageValue?> uploadWithBytes(Uint8List uploadFileByte) async {
Expand All @@ -206,7 +206,7 @@ class Storage extends ChangeNotifier implements ValueListenable<StorageValue?> {
try {
final remoteFile = await storageQuery.adapter.uploadWithBytes(
uploadFileByte,
storageQuery.relativeRemotePath.trimQuery().trimStringRight("/"),
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
);
_value = _value?._copyWith(
remote: remoteFile,
Expand Down Expand Up @@ -243,7 +243,7 @@ class Storage extends ChangeNotifier implements ValueListenable<StorageValue?> {
_deleteCompleter = Completer();
try {
await storageQuery.adapter.delete(
storageQuery.relativeRemotePath.trimQuery().trimStringRight("/"),
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
);
_value = null;
notifyListeners();
Expand Down
36 changes: 18 additions & 18 deletions packages/katana_storage/lib/src/storage_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,73 +66,73 @@ abstract class StorageAdapter {
/// Please make sure that you can get a publicly available URL. Use this URI when you want to retrieve images, etc. using `Image.network`, etc.
///
/// 公開可能なURLを取得できるようにしてください。画像等を`Image.network`などで取得したい場合このURIを利用します。
Future<Uri> fetchPublicURI(String remoteRelativePath);
Future<Uri> fetchPublicURI(String remoteRelativePathOrId);

/// Please make sure you can get the URI to download the file.
///
/// ファイルをダウンロードするためのURIを取得できるようにしてください。
Future<Uri> fetchDownloadURI(String remoteRelativePath);
Future<Uri> fetchDownloadURI(String remoteRelativePathOrId);

/// Download the file on the remote side specified in [remoteRelativePath] to [localRelativePath] on the local.
/// Download the file on the remote side specified in [remoteRelativePathOrId] to [localRelativePath] on the local.
///
/// Both are passed relative to the root folder on each platform.
///
/// Return [LocalFile] containing the full path of the cache to download and the actual data as the return value.
///
/// If [localRelativePath] is not specified, ensure that only byte data is retrieved.
///
/// [remoteRelativePath]で指定されたリモート側のファイルをローカル上の[localRelativePath]にダウンロードします。
/// [remoteRelativePathOrId]で指定されたリモート側のファイルをローカル上の[localRelativePath]にダウンロードします。
///
/// どちらも各プラットフォーム上のルートフォルダに対する相対パスが渡されます。
///
/// 戻り値としてダウンロード先のキャッシュのフルパスと実データを格納した[LocalFile]を返してください。
///
/// [localRelativePath]が指定されない場合はバイトデータのみが取得されるようにしてください。
Future<LocalFile> download(
String remoteRelativePath, [
String remoteRelativePathOrId, [
String? localRelativePath,
]);

/// Uploads the local file specified in [localFullPath] to [remoteRelativePath], which is the location on the remote side.
/// Uploads the local file specified in [localFullPath] to [remoteRelativePathOrId], which is the location on the remote side.
///
/// The full path in the platform is passed to [localFullPath] and the relative path is passed to [remoteRelativePath].
/// The full path in the platform is passed to [localFullPath] and the relative path is passed to [remoteRelativePathOrId].
///
/// Return [RemoteFile] containing the full path of the upload destination and the actual data as the return value.
///
/// [localFullPath]で指定されたローカル上のファイルをリモート側の位置であるの[remoteRelativePath]にアップロードします。
/// [localFullPath]で指定されたローカル上のファイルをリモート側の位置であるの[remoteRelativePathOrId]にアップロードします。
///
/// [localFullPath]にプラットフォーム内のフルパスが渡され[remoteRelativePath]に相対パスが渡されます。
/// [localFullPath]にプラットフォーム内のフルパスが渡され[remoteRelativePathOrId]に相対パスが渡されます。
///
/// 戻り値としてアップロード先のフルパスと実データを格納した[RemoteFile]を返してください。
Future<RemoteFile> upload(
String localFullPath,
String remoteRelativePath,
String remoteRelativePathOrId,
);

/// Uploads the data specified in [uploadFileByte] to [remoteRelativePath], which is the location on the remote side.
/// Uploads the data specified in [uploadFileByte] to [remoteRelativePathOrId], which is the location on the remote side.
///
/// The byte data of the file is passed to [uploadFileByte] and the relative path is passed to [remoteRelativePath].
/// The byte data of the file is passed to [uploadFileByte] and the relative path is passed to [remoteRelativePathOrId].
///
/// Return [RemoteFile] containing the full path of the upload destination and the actual data as the return value.
///
/// [uploadFileByte]で指定されたデータをリモート側の位置であるの[remoteRelativePath]にアップロードします。
/// [uploadFileByte]で指定されたデータをリモート側の位置であるの[remoteRelativePathOrId]にアップロードします。
///
/// [uploadFileByte]にファイルのバイトデータが渡され[remoteRelativePath]に相対パスが渡されます。
/// [uploadFileByte]にファイルのバイトデータが渡され[remoteRelativePathOrId]に相対パスが渡されます。
///
/// 戻り値としてアップロード先のフルパスと実データを格納した[RemoteFile]を返してください。
Future<RemoteFile> uploadWithBytes(
Uint8List uploadFileByte,
String remoteRelativePath,
String remoteRelativePathOrId,
);

/// Delete files on the remote side in [relativePath].
/// Delete files on the remote side in [remoteRelativePathOrId].
///
/// A path relative to the root folder on each platform is passed.
///
/// [relativePath]にあるリモート側のファイルを削除します。
/// [remoteRelativePathOrId]にあるリモート側のファイルを削除します。
///
/// 各プラットフォーム上のルートフォルダに対する相対パスが渡されます。
Future<void> delete(String relativePath);
Future<void> delete(String remoteRelativePathOrId);
}

/// [StorageAdapter] for the entire app by placing it on top of [MaterialApp], etc.
Expand Down
12 changes: 6 additions & 6 deletions packages/katana_storage/lib/src/storage_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ part of '/katana_storage.dart';

/// Query to specify the path of storage on the remote side.
///
/// Specify the relative path on the remote storage side in [relativeRemotePath].
/// Specify the relative path on the remote storage side in [relativeRemotePathOrId].
///
/// If you want to specify [StorageAdapter] directly, pass it to [adapter].
///
/// リモート側のストレージのパスを指定するためのクエリ。
///
/// [relativeRemotePath]でリモートストレージ側の相対パスを指定します。
/// [relativeRemotePathOrId]でリモートストレージ側の相対パスを指定します。
///
/// [StorageAdapter]を直接指定したい場合、[adapter]に渡してください。
@immutable
class StorageQuery {
/// Query to specify the path of storage on the remote side.
///
/// Specify the relative path on the remote storage side in [relativeRemotePath].
/// Specify the relative path on the remote storage side in [relativeRemotePathOrId].
///
/// If you want to specify [StorageAdapter] directly, pass it to [adapter].
///
/// リモート側のストレージのパスを指定するためのクエリ。
///
/// [relativeRemotePath]でリモートストレージ側の相対パスを指定します。
/// [relativeRemotePathOrId]でリモートストレージ側の相対パスを指定します。
///
/// [StorageAdapter]を直接指定したい場合、[adapter]に渡してください。
const StorageQuery(
this.relativeRemotePath, {
this.relativeRemotePathOrId, {
StorageAdapter? adapter,
}) : _adapter = adapter;

Expand All @@ -36,7 +36,7 @@ class StorageQuery {
/// ストレージ側のローカルパス。
///
/// ストレージ側の保存可能なフォルダをルートにした相対パスを指定します。
final String relativeRemotePath;
final String relativeRemotePathOrId;

/// [StorageAdapter] to be used.
///
Expand Down
4 changes: 2 additions & 2 deletions packages/katana_storage/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ packages:
path: "../katana"
relative: true
source: path
version: "2.10.2"
version: "2.11.0"
katana_test:
dependency: "direct dev"
description:
path: "../katana_test"
relative: true
source: path
version: "2.0.0"
version: "2.1.0"
lints:
dependency: transitive
description:
Expand Down
8 changes: 4 additions & 4 deletions packages/katana_storage_firebase/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,28 +310,28 @@ packages:
path: "../katana"
relative: true
source: path
version: "2.10.2"
version: "2.11.0"
katana_firebase:
dependency: "direct main"
description:
path: "../katana_firebase"
relative: true
source: path
version: "2.0.32"
version: "2.1.1"
katana_storage:
dependency: "direct main"
description:
path: "../katana_storage"
relative: true
source: path
version: "2.0.35"
version: "2.1.0"
katana_test:
dependency: "direct dev"
description:
path: "../katana_test"
relative: true
source: path
version: "2.0.0"
version: "2.1.0"
lints:
dependency: transitive
description:
Expand Down

0 comments on commit b37e096

Please sign in to comment.