feat: add media command (mediaStorage), deprecate upload#78
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new runware media command group backed by the mediaStorage API task (upload + delete), refactors the shared local-path/URL/data-URI input handling into internal/cmdutil, and marks the legacy runware upload command as deprecated.
Changes:
- Add
runware media uploadandrunware media deletecommands wired toClient.MediaStorage. - Extract the shared image input builder into
internal/cmdutil.BuildImageInputwith unit tests. - Deprecate (but keep)
runware upload, and update end-user docs to highlightmedia.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Replaces the “Upload” section with “Media”, documenting media upload/delete and noting upload is deprecated. |
| internal/cmdutil/mediainput.go | New shared helper to turn `<file |
| internal/cmdutil/mediainput_test.go | Updates and relocates tests to cover cmdutil.BuildImageInput. |
| internal/cmd/upload/upload.go | Deprecates upload command and switches to using cmdutil.BuildImageInput. |
| internal/cmd/root.go | Registers the new media command group on the root command. |
| internal/cmd/media/upload.go | Implements runware media upload (calls MediaStorage(upload, ...)) and prints mediaUUID/mediaURL/taskUUID. |
| internal/cmd/media/media.go | Defines the media command group and attaches upload/delete subcommands. |
| internal/cmd/media/delete.go | Implements runware media delete (calls MediaStorage(delete, <uuid>)) and prints mediaUUID/taskUUID. |
| internal/api/types.go | Adds MediaStorageRequest / MediaStorageResult types for the new task. |
| internal/api/media_storage_test.go | Adds unit tests validating request construction and response parsing for upload/delete operations. |
| internal/api/constants.go | Adds taskTypeMediaStorage and operation constants (upload, delete). |
| internal/api/client.go | Adds Client.MediaStorage and documents UploadImage as superseded. |
| docs/runware.md | Adds runware media to top-level docs list (but removes runware upload entry). |
| docs/runware_media.md | Adds docs page for the runware media command group. |
| docs/runware_media_upload.md | Adds docs page for runware media upload. |
| docs/runware_media_delete.md | Adds docs page for runware media delete. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Package upload implements the deprecated "upload" command, which uploads image | ||
| // files to the Runware platform and returns their reusable UUID. Superseded by | ||
| // the "media" command group, which handles any media type and supports deletion. |
| // | ||
| // Superseded by MediaStorage, which handles any media type and supports deletion; | ||
| // retained for the deprecated "upload" command. |
| mime := http.DetectContentType(data) | ||
| if _, ok := allowedImageMIME[mime]; ok { | ||
| return mime, nil | ||
| } | ||
|
|
||
| if extMIME, ok := imageExtMIME[strings.ToLower(filepath.Ext(path))]; ok { | ||
| if _, allowed := allowedImageMIME[extMIME]; allowed { | ||
| return extMIME, nil | ||
| } | ||
| } |
| * [runware auth](runware_auth.md) - Manage authentication | ||
| * [runware completion](runware_completion.md) - Generate shell completion scripts | ||
| * [runware config](runware_config.md) - Manage CLI configuration | ||
| * [runware media](runware_media.md) - Store and delete media in your Runware account |
danmrichards
left a comment
There was a problem hiding this comment.
Linter isn't happy with one of your tests
| // the Runware platform and returns their reusable UUID. | ||
| // Package upload implements the deprecated "upload" command, which uploads image | ||
| // files to the Runware platform and returns their reusable UUID. Superseded by | ||
| // the "media" command group, which handles any media type and supports deletion. |
There was a problem hiding this comment.
nitpick: handles any media is potentially misleading, as we're still only accepting images by the look of it. Probably a server-side limitation, and the plan is to accept more media types via that task type in future?
| defer t.Close() //nolint:errcheck | ||
|
|
||
| client := api.NewClient(t, slog.New(logger)) | ||
| result, err := client.MediaStorage(cmd.Context(), api.MediaOperationDelete, args[0]) |
There was a problem hiding this comment.
suggestion: check the arg is a valid UUID before sending to the API, save the round-trip time for a typo'd uuid
Adds a
mediacommand group backed by themediaStoragetask:runware media upload <file|url>— store media, returns mediaUUID + mediaURLrunware media delete <mediaUUID>— permanently delete stored mediaDeprecates the
uploadcommand (kept, still works) in favor ofmedia upload, matching the SDK deprecation ofimageUpload→mediaStorage. Extracts the shared image-input builder intocmdutil.