Skip to content

Conversation

@mgajda
Copy link

@mgajda mgajda commented Dec 15, 2025

Summary

This PR enhances the Storage Import functionality to support additional IANA-registered content types as documented in the UpCloud Storage Import API.

Changes

  1. Extended Content Type Support

    • Added support for: application/x-tar, application/x-bzip2, application/x-7z-compressed, application/zip
    • Auto-detection from file extensions
    • Default to application/octet-stream for unknown types
  2. New --content-type Flag

    • Allows explicit specification of content type
    • Example: upctl storage import --source-location file.tar --content-type application/x-tar --title my_storage --zone es-mad1
  3. Improved Help Text

    • Both --source-location and --content-type flags now dynamically display supported formats
    • Extracted content type mapping to package level for reusability

Testing

  • All existing tests pass
  • Added comprehensive unit tests for content type detection
  • Build verification successful

Supported File Types

Extension Content Type
.gz application/gzip
.xz application/x-xz
.tar application/x-tar
.bz2 application/x-bzip2
.7z application/x-7z-compressed
.zip application/zip
.iso, .img, .raw, .qcow2 application/octet-stream

How to Test

# Auto-detect content type
upctl storage import --source-location archive.tar.gz --title test --zone es-mad1

# Explicit content type
upctl storage import --source-location file.tar --content-type application/x-tar --title test --zone es-mad1

# View supported types in help
upctl storage import --help

Fixes #581

…content-type flag

- Support IANA-registered content types: application/gzip, application/x-xz,
  application/x-tar, application/x-bzip2, application/x-7z-compressed,
  application/zip, and application/octet-stream
- Add --content-type flag to allow explicit content type specification
- Auto-detect content type from file extension with fallback to octet-stream
- Add getContentType() function for extensible content type mapping
- Add comprehensive unit tests for content type detection

Fixes UpCloudLtd#581
@mgajda mgajda requested a review from a team as a code owner December 15, 2025 07:59
- Move supportedContentTypes map to package level for reusability
- Add getSupportedExtensionsText() to list all supported file extensions
- Add getSupportedContentTypesText() to list all supported content types
- Update --source-location help to show supported extensions dynamically
- Update --content-type help to show supported types dynamically
- Simplify getContentType() to use the package-level map
- Help text now automatically reflects all supported formats
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.

upctl storage import should allow content-type header to be specified manually for URLs

1 participant