Skip to content

feat: add media command (mediaStorage), deprecate upload#78

Open
felixsanz wants to merge 1 commit into
mainfrom
feat/media-storage
Open

feat: add media command (mediaStorage), deprecate upload#78
felixsanz wants to merge 1 commit into
mainfrom
feat/media-storage

Conversation

@felixsanz

Copy link
Copy Markdown
Contributor

Adds a media command group backed by the mediaStorage task:

  • runware media upload <file|url> — store media, returns mediaUUID + mediaURL
  • runware media delete <mediaUUID> — permanently delete stored media

Deprecates the upload command (kept, still works) in favor of media upload, matching the SDK deprecation of imageUploadmediaStorage. Extracts the shared image-input builder into cmdutil.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include coderabbit-review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f4586406-d2bd-495f-8241-05a0b9231619

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/media-storage

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 upload and runware media delete commands wired to Client.MediaStorage.
  • Extract the shared image input builder into internal/cmdutil.BuildImageInput with unit tests.
  • Deprecate (but keep) runware upload, and update end-user docs to highlight media.

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.

Comment on lines +1 to +3
// 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.
Comment thread internal/api/client.go
Comment on lines +89 to +91
//
// Superseded by MediaStorage, which handles any media type and supports deletion;
// retained for the deprecated "upload" command.
Comment on lines +64 to +73
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
}
}
Comment thread docs/runware.md
* [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 danmrichards left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: check the arg is a valid UUID before sending to the API, save the round-trip time for a typo'd uuid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants