-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add support for additional Storage Import content types #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add support for additional Storage Import content types #634
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
| ".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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.