Skip to content

Commit

Permalink
pass content-type when uploading to Nuclia (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrehault authored Feb 8, 2023
1 parent 5d70d74 commit 1f4f192
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
15 changes: 12 additions & 3 deletions apps/desktop/src/app/sync/destinations/nuclia-cloud.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { FIELD_TYPE, INuclia, Nuclia, NucliaOptions, ResourceProperties, WritableKnowledgeBox } from '@nuclia/core';
import { map, Observable, of, switchMap, delay } from 'rxjs';
import { INuclia, Nuclia, NucliaOptions, WritableKnowledgeBox } from '@nuclia/core';
import { map, Observable, of, switchMap } from 'rxjs';
import {
ConnectorParameters,
ConnectorSettings,
DestinationConnectorDefinition,
Field,
IDestinationConnector,
} from '../models';
import { lookup } from 'mime-types';

const ACCOUNT_KEY = 'NUCLIA_ACCOUNT';

Expand Down Expand Up @@ -52,7 +53,15 @@ class NucliaCloudKBImpl implements IDestinationConnector {
const kb$ = this.kb
? of(this.kb)
: this.nuclia.db.getKnowledgeBox(localStorage.getItem(ACCOUNT_KEY) || '', params['kb']);
return kb$.pipe(switchMap((kb) => kb.upload(new File([blob], filename)).pipe(map(() => undefined))));
return kb$.pipe(
switchMap((kb) =>
kb
.upload(new File([blob], filename), false, {
contentType: lookup(filename) || 'application/octet-stream',
})
.pipe(map(() => undefined)),
),
);
} else {
return of(undefined);
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuclia",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",
"author": "Nuclia.cloud",
"description": "Nuclia frontend apps and libs",
Expand Down Expand Up @@ -56,6 +56,7 @@
"fuse.js": "^3.6.1",
"googleapis": "^110.0.0",
"latinize": "^0.5.0",
"mime-types": "^2.1.35",
"mrs-developer": "^1.7.1",
"ngx-captcha": "^12.0.2",
"node-machine-id": "^1.1.12",
Expand Down Expand Up @@ -109,6 +110,7 @@
"@types/jexl": "^2.2.0",
"@types/latinize": "^0.2.15",
"@types/lru-cache": "^5.1.0",
"@types/mime-types": "^2.1.1",
"@types/node": "18.7.1",
"@types/perfect-scrollbar": "^1.3.0",
"@types/spark-md5": "^3.0.2",
Expand Down
11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7386,6 +7386,13 @@ __metadata:
languageName: node
linkType: hard

"@types/mime-types@npm:^2.1.1":
version: 2.1.1
resolution: "@types/mime-types@npm:2.1.1"
checksum: 106b5d556add46446a579ad25ff15d6b421851790d887edcad558c90c1e64b1defc72bfbaf4b08f208916e21d9cc45cdb951d77be51268b18221544cfe054a3c
languageName: node
linkType: hard

"@types/mime@npm:^1":
version: 1.3.2
resolution: "@types/mime@npm:1.3.2"
Expand Down Expand Up @@ -18302,7 +18309,7 @@ __metadata:
languageName: node
linkType: hard

"mime-types@npm:^2.1.11, mime-types@npm:^2.1.12, mime-types@npm:^2.1.27, mime-types@npm:^2.1.31, mime-types@npm:~2.1.17, mime-types@npm:~2.1.19, mime-types@npm:~2.1.24, mime-types@npm:~2.1.34, mime-types@npm:~2.1.7":
"mime-types@npm:^2.1.11, mime-types@npm:^2.1.12, mime-types@npm:^2.1.27, mime-types@npm:^2.1.31, mime-types@npm:^2.1.35, mime-types@npm:~2.1.17, mime-types@npm:~2.1.19, mime-types@npm:~2.1.24, mime-types@npm:~2.1.34, mime-types@npm:~2.1.7":
version: 2.1.35
resolution: "mime-types@npm:2.1.35"
dependencies:
Expand Down Expand Up @@ -19397,6 +19404,7 @@ __metadata:
"@types/jexl": ^2.2.0
"@types/latinize": ^0.2.15
"@types/lru-cache": ^5.1.0
"@types/mime-types": ^2.1.1
"@types/node": 18.7.1
"@types/perfect-scrollbar": ^1.3.0
"@types/spark-md5": ^3.0.2
Expand Down Expand Up @@ -19433,6 +19441,7 @@ __metadata:
jest-environment-jsdom: 28.1.1
jest-preset-angular: 12.2.2
latinize: ^0.5.0
mime-types: ^2.1.35
mrs-developer: ^1.7.1
ng-mocks: ^14.1.1
ng-packagr: 14.2.0
Expand Down

0 comments on commit 1f4f192

Please sign in to comment.