Skip to content

Commit bda59a6

Browse files
committed
docs(uploads): update deleteFile and deleteImage methods
This commit updates the `deleteFile` and `deleteImage` methods in `FeedsClient` and `FeedsClientImpl` to accept the `url` parameter as a named, required argument. Additionally, it adds a new code snippet to the documentation demonstrating how to use these methods to delete files and images from the CDN.
1 parent 4cdeeb4 commit bda59a6

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

docs_code_snippets/03_03_file_uploads.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import 'package:stream_feeds/stream_feeds.dart';
44

5+
late StreamFeedsClient client;
56
late Feed feed;
67
late Activity activity;
78
late StreamAttachmentUploader attachmentUploader;
@@ -79,6 +80,14 @@ Future<void> howToUploadAFileOrImageStep4() async {
7980
);
8081
}
8182

83+
Future<void> howToDeleteAFileOrImage() async {
84+
// Delete an image from the CDN
85+
await client.deleteImage(url: 'https://mycdn.com/image.png');
86+
87+
// Delete a file from the CDN
88+
await client.deleteFile(url: 'https://mycdn.com/file.pdf');
89+
}
90+
8291
// Your custom implementation of CdnClient
8392
class CustomCDN implements CdnClient {
8493
@override

packages/stream_feeds/lib/src/client/feeds_client_impl.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class StreamFeedsClientImpl implements StreamFeedsClient {
294294
@override
295295
Activity activity({
296296
required String activityId,
297-
required FeedId fid,
297+
required FeedId fid,
298298
ActivityData? initialData,
299299
}) {
300300
return Activity(
@@ -442,8 +442,12 @@ class StreamFeedsClientImpl implements StreamFeedsClient {
442442
}
443443

444444
@override
445-
Future<Result<void>> deleteFile(String url) => _cdnClient.deleteFile(url);
445+
Future<Result<void>> deleteFile({required String url}) {
446+
return _cdnClient.deleteFile(url);
447+
}
446448

447449
@override
448-
Future<Result<void>> deleteImage(String url) => _cdnClient.deleteImage(url);
450+
Future<Result<void>> deleteImage({required String url}) {
451+
return _cdnClient.deleteImage(url);
452+
}
449453
}

packages/stream_feeds/lib/src/feeds_client.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ abstract interface class StreamFeedsClient {
667667
/// ```
668668
///
669669
/// Returns a [Result] indicating success or failure of the deletion operation.
670-
Future<Result<void>> deleteFile(String url);
670+
Future<Result<void>> deleteFile({required String url});
671671

672672
/// Deletes a previously uploaded image from the CDN.
673673
///
@@ -689,7 +689,7 @@ abstract interface class StreamFeedsClient {
689689
/// ```
690690
///
691691
/// Returns a [Result] indicating success or failure of the deletion operation.
692-
Future<Result<void>> deleteImage(String url);
692+
Future<Result<void>> deleteImage({required String url});
693693

694694
/// The moderation client for managing moderation-related operations.
695695
///

0 commit comments

Comments
 (0)