mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Fixed file upload bug
This commit is contained in:
parent
3eaa00bddb
commit
739efa5a36
@ -18,12 +18,8 @@ export default class ContentFileSelect extends Component {
|
||||
|
||||
@action
|
||||
fileSelected(fileList) {
|
||||
console.log('File list: ' + JSON.stringify(fileList));
|
||||
|
||||
let [file] = Array.from(fileList);
|
||||
|
||||
console.log('Validating file: ' + JSON.stringify(file));
|
||||
|
||||
try {
|
||||
this._validateFileType(file);
|
||||
this.error = null;
|
||||
@ -32,8 +28,6 @@ export default class ContentFileSelect extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Setting file to: ' + JSON.stringify(file));
|
||||
|
||||
this.args.setFile(file);
|
||||
}
|
||||
|
||||
@ -67,14 +61,16 @@ export default class ContentFileSelect extends Component {
|
||||
event.preventDefault();
|
||||
this.dragClass = null;
|
||||
if (event.dataTransfer.files) {
|
||||
console.log("dropped: ", event.dataTransfer.files);
|
||||
this.fileSelected(event.dataTransfer.files);
|
||||
}
|
||||
}
|
||||
|
||||
_validateFileType(file) {
|
||||
console.log(file);
|
||||
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
||||
|
||||
if (extension.toLowerCase() !== 'json' || extension.toLowerCase() !== 'zip') {
|
||||
if (extension.toLowerCase() !== 'json' && extension.toLowerCase() !== 'zip') {
|
||||
throw new UnsupportedMediaTypeError({
|
||||
message: 'The file type you uploaded is not supported'
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user