This repository has been archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Allow more mime types to be uploaded #95
Comments
I agree, though it's actually a lot more complicated than it should be. I wrote this hack so I could upload my ❯ git diff
diff --git a/bin/index.ts b/bin/index.ts
index ac58de4..c84412b 100644
--- a/bin/index.ts
+++ b/bin/index.ts
@@ -38,6 +38,7 @@ const SUPPORTED_MIME = [
'image/tiff',
'image/nef',
'image/x-nikon-nef',
+ 'image/x-sony-arw',
// VIDEO
'video/mp4',
@@ -179,12 +180,13 @@ async function upload(
const uniqueFiles = new Set(files);
for (const filePath of uniqueFiles) {
- const mimeType = mime.lookup(filePath) as string;
+ const mimeType = filePath.toLowerCase().endsWith('arw') ? 'image/x-sony-arw' : mime.lookup(filePath) as string;
if (SUPPORTED_MIME.includes(mimeType)) {
try {
const fileStat = fs.statSync(filePath);
localAssets.push({
id: `${path.basename(filePath)}-${fileStat.size}`.replace(/\s+/g, ''),
+ mimeType,
filePath,
});
} catch (e) {
@@ -385,7 +387,7 @@ async function startUpload(endpoint: string, key: string, asset: any, deviceId:
data.append('fileExtension', path.extname(asset.filePath));
data.append('duration', '0:00:00.000000');
- data.append('assetData', fs.createReadStream(asset.filePath));
+ data.append('assetData', fs.createReadStream(asset.filePath), { contentType: asset.mimeType });
try {
await fs.promises.access(`${asset.filePath}.xmp`, fs.constants.W_OK);
@@ -499,7 +501,7 @@ async function validateConnection(endpoint: string, key: string) {
}
function getAssetType(filePath: string) {
- const mimeType = mime.lookup(filePath) as string;
+ const mimeType = filePath.toLowerCase().endsWith('.arw') ? 'image/x-sony-arw' : mime.lookup(filePath) as string;
return mimeType.split('/')[0].toUpperCase();
} |
Open
3 tasks
Wow, i was thinking that just adding RAW to the array would be sufficient 😅 Probably, for the future this cli client should import the servers library for file processing to prevent this doubled maintenance overhead? 🤔 EDIT: Just saw immich-app/immich#2824 😀 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Since immich-app/immich#2156 is implemented and released now, it would be great to allow RAW files for the cli uploader.
Tried today and it seems like it is not listed in here:
CLI/bin/index.ts
Lines 25 to 48 in 5b5b325
The text was updated successfully, but these errors were encountered: