File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,12 @@ import '@vue/runtime-core'
6
6
declare module '@vue/runtime-core' {
7
7
export interface GlobalComponents {
8
8
AppButton : typeof import ( './src/components/AppButton.vue' ) [ 'default' ]
9
+ AppImageDropzone : typeof import ( './src/components/AppImageDropzone.vue' ) [ 'default' ]
10
+ AppLoader : typeof import ( './src/components/AppLoader.vue' ) [ 'default' ]
9
11
AppPageHeading : typeof import ( './src/components/AppPageHeading.vue' ) [ 'default' ]
10
12
BoardCard : typeof import ( './src/components/BoardCard.vue' ) [ 'default' ]
11
13
BoardDragAndDrop : typeof import ( './src/components/BoardDragAndDrop.vue' ) [ 'default' ]
14
+ BoardMenu : typeof import ( './src/components/BoardMenu.vue' ) [ 'default' ]
12
15
HelloWorld : typeof import ( './src/components/HelloWorld.vue' ) [ 'default' ]
13
16
IconCommunity : typeof import ( './src/components/icons/IconCommunity.vue' ) [ 'default' ]
14
17
IconDocumentation : typeof import ( './src/components/icons/IconDocumentation.vue' ) [ 'default' ]
@@ -18,6 +21,7 @@ declare module '@vue/runtime-core' {
18
21
RouterLink : typeof import ( 'vue-router' ) [ 'RouterLink' ]
19
22
RouterView : typeof import ( 'vue-router' ) [ 'RouterView' ]
20
23
TaskCard : typeof import ( './src/components/TaskCard.vue' ) [ 'default' ]
24
+ TaskCreator : typeof import ( './src/components/TaskCreator.vue' ) [ 'default' ]
21
25
TheAlerts : typeof import ( './src/components/TheAlerts.vue' ) [ 'default' ]
22
26
TheDrawer : typeof import ( './src/components/TheDrawer.vue' ) [ 'default' ]
23
27
TheWelcome : typeof import ( './src/components/TheWelcome.vue' ) [ 'default' ]
Original file line number Diff line number Diff line change
1
+ import gql from "graphql-tag" ;
2
+ import { useMutation , useQuery } from "@vue/apollo-composable" ;
3
+
4
+ const IMAGE_UPLOAD_QUERY = gql `
5
+ query {
6
+ fileUploadInfo {
7
+ policy
8
+ signature
9
+ apiKey
10
+ path
11
+ }
12
+ }
13
+ ` ;
14
+
15
+ const FILE_CREATE_MUTATION = gql `
16
+ mutation CREATE_FILE($fileId: String!, $filename: String!) {
17
+ fileCreate(data: { fileId: $fileId, filename: $filename }) {
18
+ id
19
+ }
20
+ }
21
+ ` ;
22
+
23
+ export function useStorage ( ) {
24
+ const { result } = useQuery ( IMAGE_UPLOAD_QUERY ) ;
25
+ const { mutate : createFileIn8base } = useMutation ( FILE_CREATE_MUTATION ) ;
26
+
27
+ async function uploadAsset ( file : File ) {
28
+ if ( ! result . value || ! result . value . fileUploadInfo ) {
29
+ throw new Error ( "File Upload info not yet available" ) ;
30
+ }
31
+ const res = await fetch (
32
+ `https://www.filestackapi.com/api/store/S3?key=${ result . value . fileUploadInfo . apiKey } &policy=${ result . value . fileUploadInfo . policy } &signature=${ result . value . fileUploadInfo . signature } &path=${ result . value . fileUploadInfo . path } ` ,
33
+ {
34
+ method : "POST" ,
35
+ headers : {
36
+ "Content-Type" : file . type ,
37
+ } ,
38
+ body : file ,
39
+ }
40
+ ) ;
41
+ const data = await res . json ( ) ;
42
+ return createFileIn8base ( {
43
+ fileId : data . url . split ( "/" ) . at ( - 1 ) ,
44
+ filename : data . filename ,
45
+ } ) ;
46
+ }
47
+ return {
48
+ uploadAsset,
49
+ } ;
50
+ }
51
+ export default useStorage ;
You can’t perform that action at this time.
0 commit comments