feat: add support for additional Storage Import content types#634
Open
mgajda wants to merge 4 commits intoUpCloudLtd:mainfrom
Open
feat: add support for additional Storage Import content types#634mgajda wants to merge 4 commits intoUpCloudLtd:mainfrom
mgajda wants to merge 4 commits intoUpCloudLtd:mainfrom
Conversation
…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
- 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
46a03e9 to
5f652e2
Compare
kangasta
reviewed
Dec 31, 2025
Comment on lines
+31
to
+40
| ".gz": "application/gzip", | ||
| ".xz": "application/x-xz", | ||
| ".iso": "application/octet-stream", | ||
| ".img": "application/octet-stream", | ||
| ".raw": "application/octet-stream", | ||
| ".qcow2": "application/octet-stream", | ||
| ".tar": "application/x-tar", | ||
| ".bz2": "application/x-bzip2", | ||
| ".7z": "application/x-7z-compressed", | ||
| ".zip": "application/zip", |
Member
There was a problem hiding this comment.
Based on our our docs we only support raw images and gz and xz compressions, so no need for all of these 🤔
The supported data type is raw (extension .raw, .img or .iso). However, the data can be compressed either with GZip or XZ (Content-Types application/gzip and application/x-xz, typical extensions .gz and .xz respectively) in which case it will be transparently decompressed.
The golangci-lint modernize linter detected inefficient string concatenation in loops. Using strings.Builder is more efficient as it avoids creating multiple intermediate string objects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the Storage Import functionality to support additional IANA-registered content types as documented in the UpCloud Storage Import API.
Changes
Extended Content Type Support
New
--content-typeFlagupctl storage import --source-location file.tar --content-type application/x-tar --title my_storage --zone es-mad1Improved Help Text
--source-locationand--content-typeflags now dynamically display supported formatsTesting
Supported File Types
How to Test
For #581 client-side uploads only. The custom content type is not yet supported for URL-based import.