mirror of
https://github.com/strapi/strapi.git
synced 2025-11-25 22:51:33 +00:00
Revert previous changes and save hash to new field sha256
This commit is contained in:
parent
2ad3121494
commit
4771cc9575
@ -18,6 +18,10 @@
|
|||||||
"configurable": false,
|
"configurable": false,
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
"sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"configurable": false
|
||||||
|
},
|
||||||
"ext": {
|
"ext": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"configurable": false
|
"configurable": false
|
||||||
@ -48,4 +52,4 @@
|
|||||||
"configurable": false
|
"configurable": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,6 +10,7 @@ const fs = require('fs');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const toArray = require('stream-to-array');
|
const toArray = require('stream-to-array');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const uuid = require('uuid/v4');
|
||||||
|
|
||||||
function niceHash(buffer) {
|
function niceHash(buffer) {
|
||||||
return crypto.createHash('sha256')
|
return crypto.createHash('sha256')
|
||||||
@ -41,7 +42,8 @@ module.exports = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: stream.name,
|
name: stream.name,
|
||||||
hash: niceHash(buffer),
|
sha256: niceHash(buffer),
|
||||||
|
hash: uuid().replace(/-/g, ''),
|
||||||
ext: stream.name.split('.').length > 1 ? `.${_.last(stream.name.split('.'))}` : '',
|
ext: stream.name.split('.').length > 1 ? `.${_.last(stream.name.split('.'))}` : '',
|
||||||
buffer,
|
buffer,
|
||||||
mime: stream.type,
|
mime: stream.type,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user