@live-change/image-service 0.8.15 → 0.8.16
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/image.js +12 -3
- package/package.json +4 -4
package/image.js
CHANGED
|
@@ -52,6 +52,7 @@ const Image = definition.model({
|
|
|
52
52
|
|
|
53
53
|
import { move, copy, mkdir, rmdir } from './fsUtils.js'
|
|
54
54
|
import fs from 'fs'
|
|
55
|
+
import path from 'path'
|
|
55
56
|
import sharp from 'sharp'
|
|
56
57
|
import download from 'download'
|
|
57
58
|
|
|
@@ -107,10 +108,10 @@ definition.action({
|
|
|
107
108
|
}
|
|
108
109
|
const uploadRow = await Upload.get(upload)
|
|
109
110
|
if(!uploadRow) throw new Error("upload_not_found")
|
|
110
|
-
if(uploadRow.state
|
|
111
|
+
if(uploadRow.state !== 'done') throw new Error("upload_not_done")
|
|
111
112
|
|
|
112
113
|
let extension = uploadRow.fileName.match(/\.([A-Z0-9]+)$/i)[1].toLowerCase()
|
|
113
|
-
if(extension
|
|
114
|
+
if(extension === 'jpg') extension = "jpeg"
|
|
114
115
|
const dir = `${imagesPath}${image}`
|
|
115
116
|
|
|
116
117
|
emit({
|
|
@@ -173,7 +174,15 @@ definition.trigger({
|
|
|
173
174
|
const downloadPath = `${uploadsPath}download_${image}`
|
|
174
175
|
await download(url, uploadsPath, { filename: `download_${image}` })
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
/*console.log("DOWNLOADED", url, uploadsPath, '=>', downloadPath)
|
|
178
|
+
const downloadExists = await fs.promises.access(downloadPath, fs.constants.F_OK)
|
|
179
|
+
.then(() => true)
|
|
180
|
+
.catch(() => false)
|
|
181
|
+
console.log("DOWNLOAD EXISTS", downloadExists)*/
|
|
182
|
+
|
|
183
|
+
const data = await fs.promises.readFile(downloadPath)
|
|
184
|
+
const metadata = await sharp(data).metadata()
|
|
185
|
+
//const metadata = await sharp(downloadPath).metadata()
|
|
177
186
|
|
|
178
187
|
emit({
|
|
179
188
|
type: "ownerOwnedImageCreated",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/image-service",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.8.
|
|
25
|
-
"@live-change/relations-plugin": "^0.8.
|
|
24
|
+
"@live-change/framework": "^0.8.16",
|
|
25
|
+
"@live-change/relations-plugin": "^0.8.16",
|
|
26
26
|
"download": "^8.0.0",
|
|
27
27
|
"pluralize": "^8.0.0",
|
|
28
28
|
"sharp": "^0.32.5"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "b8ac84cbe1a8c435c7b5003dfc64ddc41a4e15a6",
|
|
31
31
|
"type": "module"
|
|
32
32
|
}
|