Skip to content

Commit

Permalink
[Maps][File upload] Remove usage of max file size advanced setting 1G…
Browse files Browse the repository at this point in the history
…B limit in geo file upload (#127639)

* #93261 - Usage of maxFileSize in geo upload form is removed

* 93261 - refactoring

* 93261 - fixed translation checks

* 93261 - documentation updates

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
maksimkovalev and kibanamachine authored Mar 16, 2022
1 parent 71af73c commit 0cd251e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 14 deletions.
3 changes: 0 additions & 3 deletions docs/maps/import-geospatial-data.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ To import geospatical data into the Elastic Stack, the data must be indexed as {
Geospatial data comes in many formats.
Choose an import tool based on the format of your geospatial data.

TIP: When you upload files in {kib}, there is a file size
limit, which is configurable in <<fileupload-maxfilesize,Advanced Settings>>.

[discrete]
[[import-geospatial-privileges]]
=== Security privileges
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import React, { Component } from 'react';
import { EuiFilePicker, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { MB } from '../../../common/constants';
import { getMaxBytesFormatted } from '../../importer/get_max_bytes';
import { GEO_FILE_TYPES, geoImporterFactory } from '../../importer/geo';
import type { GeoFileImporter, GeoFilePreview } from '../../importer/geo';

Expand Down Expand Up @@ -135,11 +134,6 @@ export class GeoFilePicker extends Component<Props, State> {
defaultMessage: 'Formats accepted: {fileTypes}',
values: { fileTypes: GEO_FILE_TYPES.join(', ') },
})}
<br />
{i18n.translate('xpack.fileUpload.geoFilePicker.maxSize', {
defaultMessage: 'Max size: {maxFileSize}',
values: { maxFileSize: getMaxBytesFormatted() },
})}
</span>
);
}
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/file_upload/public/importer/geo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { ShapefileImporter, SHAPEFILE_TYPES } from './shapefile_importer';
import { getFileExtension, validateFile } from '../validate_file';

export const GEO_FILE_TYPES = [...GEOJSON_FILE_TYPES, ...SHAPEFILE_TYPES];
const OPTIONS = { checkSizeLimit: false };

export function geoImporterFactory(file: File): GeoFileImporter {
validateFile(file, GEO_FILE_TYPES);
validateFile(file, GEO_FILE_TYPES, OPTIONS);

const extension = getFileExtension(file);
return GEOJSON_FILE_TYPES.includes(extension)
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/file_upload/public/importer/validate_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function getFileExtension(file: File) {
return '.' + extension;
}

export function validateFile(file: File, types: string[]) {
if (file.size > getMaxBytes()) {
export function validateFile(file: File, types: string[], options?: { checkSizeLimit?: boolean }) {
if (file.size > getMaxBytes() && options?.checkSizeLimit) {
throw new Error(
i18n.translate('xpack.fileUpload.fileSizeError', {
defaultMessage: 'File size {fileSize} exceeds maximum file size of {maxFileSize}',
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -11628,7 +11628,6 @@
"xpack.fileUpload.fileTypeError": "ファイルは使用可能なタイプのいずれかではありません。{types}",
"xpack.fileUpload.geoFilePicker.acceptedFormats": "使用可能な形式:{fileTypes}",
"xpack.fileUpload.geoFilePicker.filePicker": "ファイルを選択するかドラッグ &amp;amp; ドロップしてください",
"xpack.fileUpload.geoFilePicker.maxSize": "最大サイズ:{maxFileSize}",
"xpack.fileUpload.geoFilePicker.noFeaturesDetected": "選択したファイルには特徴量がありません。",
"xpack.fileUpload.geoFilePicker.previewSummary": "{numFeatures}個の特徴量。ファイルの{previewCoverage}%。",
"xpack.fileUpload.geojsonImporter.noGeometry": "特長量には必須フィールド「ジオメトリ」が含まれていません",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -11649,7 +11649,6 @@
"xpack.fileUpload.fileTypeError": "文件不是可接受类型之一:{types}",
"xpack.fileUpload.geoFilePicker.acceptedFormats": "接受的格式:{fileTypes}",
"xpack.fileUpload.geoFilePicker.filePicker": "选择或拖放文件",
"xpack.fileUpload.geoFilePicker.maxSize": "最大大小:{maxFileSize}",
"xpack.fileUpload.geoFilePicker.noFeaturesDetected": "选定文件中未找到任何特征。",
"xpack.fileUpload.geoFilePicker.previewSummary": "正在预览 {numFeatures} 个特征、{previewCoverage}% 的文件。",
"xpack.fileUpload.geojsonImporter.noGeometry": "特征不包含必需的字段“geometry”",
Expand Down

0 comments on commit 0cd251e

Please sign in to comment.