hummingbird-me/kitsu-web

View on GitHub
app/utils/is-file-valid.js

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
import { get } from '@ember/object';

export default function isFileValid(file, accept) {
  const type = get(file, 'type');
  if (type && !accept.includes(type)) {
    return false;
  }
  const size = get(file, 'size');
  const sizeInMb = size / 1000000;
  if (sizeInMb >= 20) {
    return false;
  }
  return true;
}