Skip to content

Commit e71c2c3

Browse files
authored
Merge pull request #39 from NavAbility/23Q1/download_blob
Functionality to download blobs
2 parents 92404d4 + 3b0e215 commit e71c2c3

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "navabilitysdk",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "NavAbility SDK: Access NavAbility Cloud factor graph features from JavaScript. Note that this SDK and the related API are still in development. Please let us know if you have any issues at info@navability.io.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/navability/graphql/Blob.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ export const QUERY_BLOBS = `
77
filesize
88
filename
99
}
10-
}`;
10+
}`;
11+
12+
export const MUTATION_CREATE_DOWNLOAD = `
13+
mutation app_create_download($fileId: ID!) {
14+
url: createDownload(fileId: $fileId)
15+
}
16+
`;

src/navability/services/Blob.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
MUTATION_COMPLETE_UPLOAD,
88
} from '../graphql/QueriesDeprecated';
99
import { FileInput, UploadInfo, CompletedUploadInput, File } from '../entities/Blob';
10-
import { QUERY_BLOBS } from '../graphql/Blob';
10+
import { MUTATION_CREATE_DOWNLOAD, QUERY_BLOBS } from '../graphql/Blob';
1111

1212
// TODO: Change all these to blob.
1313

@@ -23,6 +23,15 @@ export async function queryFiles(navAbilityClient: NavAbilityClient): Promise<Fi
2323
}
2424
}
2525

26+
export async function getDownloadUrl(navAbilityClient: NavAbilityClient, fileId: string) {
27+
const result = await navAbilityClient.mutate({
28+
mutation: gql(MUTATION_CREATE_DOWNLOAD),
29+
variables: { fileId: fileId },
30+
});
31+
console.log(result);
32+
return result.data.url;
33+
}
34+
2635
export async function createUpload(
2736
navAbilityClient: NavAbilityClient,
2837
file: FileInput,

0 commit comments

Comments
 (0)