@d-mok/quasar-app-extension-quasar-axe 2.1.55 → 2.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-mok/quasar-app-extension-quasar-axe",
3
- "version": "2.1.55",
3
+ "version": "2.1.56",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -23,13 +23,15 @@
23
23
  "handsontable": "^12.4.0",
24
24
  "jszip": "^3.10.1",
25
25
  "lodash": "^4.17.21",
26
+ "mime-types": "^2.1.35",
26
27
  "papaparse": "^5.4.1",
27
- "vuedraggable": "^4.1.0",
28
- "sapphire-js": "^2.0.24"
28
+ "sapphire-js": "^2.0.24",
29
+ "vuedraggable": "^4.1.0"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@quasar/app": "^3.3.3",
32
33
  "@quasar/extras": "^1.14.2",
34
+ "@types/mime-types": "^2.1.1",
33
35
  "@types/node": "^20.2.5",
34
36
  "core-js": "^3.30.2",
35
37
  "quasar": "^2.12.0",
@@ -1,6 +1,8 @@
1
1
  import { supabase, HANDLE_ERROR, zipCreate, zipDownload } from '.'
2
2
  import { reactive } from 'vue'
3
3
  import { FileOptions } from '@supabase/storage-js'
4
+ import { exportFile } from 'quasar'
5
+ import mime from 'mime-types'
4
6
 
5
7
  export class SupbaseBucket extends Map<string, string> {
6
8
  constructor(public bucketName: string) {
@@ -96,7 +98,10 @@ export class SupbaseBucket extends Map<string, string> {
96
98
  async downloadOne(path: string, filename: string) {
97
99
  let url = this.get(path) ?? ''
98
100
  if (url === '') throw 'url not found'
99
- downloadFile(url, filename)
101
+ let file = await createFileObjectFromUrl(url, filename)
102
+ let ext = mime.extension(file.type) ?? ''
103
+ if (ext && !filename.endsWith(ext)) filename += `.${ext}`
104
+ exportFile(filename, file)
100
105
  }
101
106
 
102
107
  async downloadMany(
@@ -119,15 +124,16 @@ export class SupbaseBucket extends Map<string, string> {
119
124
  }
120
125
  }
121
126
 
122
- function downloadFile(url: string, filename: string) {
123
- // Create a link element
124
- const link = document.createElement('a')
125
- link.href = url
126
- link.download = filename
127
- link.target = '_blank'
128
-
129
- // Simulate a click event on the link element
130
- document.body.appendChild(link)
131
- link.click()
132
- document.body.removeChild(link)
127
+ async function createFileObjectFromUrl(
128
+ url: string,
129
+ filename: string
130
+ ): Promise<File> {
131
+ // Fetch the data from the URL
132
+ const response = await fetch(url)
133
+ const data = await response.blob()
134
+ const type = response.headers.get('content-type') ?? undefined
135
+ // Create a new File object with the data and filename
136
+ const file = new File([data], filename, { type })
137
+ // Return the new File object
138
+ return file
133
139
  }