Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit db94dfd

Browse files
shailrshahShail R. Shah
andauthored
Change "Mb" to "MB" (#133)
Co-authored-by: Shail R. Shah <shailshh@amazon.com>
1 parent 23a5025 commit db94dfd

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ python -m pip install dash-uploader --pre
5252
| | dash-uploader | [dcc.Upload](https://dash.plotly.com/dash-core-components/upload) |
5353
| --------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
5454
| Underlying technology | [flow.js](https://github.com/flowjs/flow.js/) | HTML5 API |
55-
| File size | Unlimited | max ~150-200Mb ([link](https://community.plotly.com/t/dash-upload-component-decoding-large-files/8033/11)) |
55+
| File size | Unlimited | max ~150-200MB ([link](https://community.plotly.com/t/dash-upload-component-decoding-large-files/8033/11)) |
5656
| Uploads to | Hard disk (server side) | First to browser memory (user side) Then, to server using callbacks. |
5757
| Data type | Uploaded as file; no need to parse at server side. | Uploaded as byte64 encoded string -> Needs parsing |
5858
| See upload progress? | Progressbar out of the box | No upload indicators out of the box. Generic loading indicator possible. [Progressbar not possible](https://community.plotly.com/t/upload-after-confirmation-and-progress-bar/7172). |
@@ -110,7 +110,7 @@ du.configure_upload(app, UPLOAD_FOLDER_ROOT)
110110
def get_upload_component(id):
111111
return du.Upload(
112112
id=id,
113-
max_file_size=1800, # 1800 Mb
113+
max_file_size=1800, # 1800 MB
114114
filetypes=['csv', 'zip'],
115115
upload_id=uuid.uuid1(), # Unique session id
116116
)

docs/dash-uploader.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ The maximum file size in Megabytes. Default: 1024 (=1Gb).
159159
#### chunk_size: numeric
160160
*New in version **[0.6.0]***
161161

162-
The chunk size in Megabytes. Optional. Default: 1 (=1Mb).
162+
The chunk size in Megabytes. Optional. Default: 1 (=1MB).
163163

164164
#### default_style: None or dict
165165
Inline CSS styling for the main div element.

src/lib/components/Upload_ReactComponent.react.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import './uploader.css';
2222
* @return {number} size_mb - Bytes converted to megabytes
2323
*/
2424
function bytest_to_mb(size_bytes) {
25-
// Mb = 1024*1024 bytes
25+
// MB = 1024*1024 bytes
2626
return size_bytes / 1048576;
2727
}
2828

@@ -171,7 +171,7 @@ export default class Upload_ReactComponent extends Component {
171171
sumOfSizes += file.size
172172
}, this);
173173
if (sumOfSizes > this.props.maxTotalSize) {
174-
alert('Total file size too large (' + bytest_to_mb(sumOfSizes).toFixed(1) + ' Mb) ! Maximum total filesize is: ' + bytest_to_mb(this.props.maxTotalSize).toFixed(1) + ' Mb')
174+
alert('Total file size too large (' + bytest_to_mb(sumOfSizes).toFixed(1) + ' MB) ! Maximum total filesize is: ' + bytest_to_mb(this.props.maxTotalSize).toFixed(1) + ' MB')
175175
return false
176176
}
177177
}
@@ -181,7 +181,7 @@ export default class Upload_ReactComponent extends Component {
181181
onProgress = () => {
182182

183183
let parenthesisTxt = (bytest_to_mb(this.flow.sizeUploaded())).toFixed(2)
184-
+ ' Mb'
184+
+ ' MB'
185185
let filenameTxt = ''
186186

187187
if (this.props.totalFilesCount > 1) {
@@ -327,9 +327,9 @@ export default class Upload_ReactComponent extends Component {
327327
}, this);
328328

329329
if (n_too_large_files == 1) {
330-
alert('1 file could not be uploaded, as the file is too large! Maximum allowed file size is ' + bytest_to_mb(this.props.maxFileSize).toFixed(1) + 'Mb')
330+
alert('1 file could not be uploaded, as the file is too large! Maximum allowed file size is ' + bytest_to_mb(this.props.maxFileSize).toFixed(1) + 'MB')
331331
} else if (n_too_large_files > 1) {
332-
alert(n_too_large_files.toString() + ' files could not be uploaded, as the file is too large! Maximum allowed file size is ' + bytest_to_mb(this.props.maxFileSize).toFixed(1) + 'Mb')
332+
alert(n_too_large_files.toString() + ' files could not be uploaded, as the file is too large! Maximum allowed file size is ' + bytest_to_mb(this.props.maxFileSize).toFixed(1) + 'MB')
333333
}
334334
}
335335

@@ -682,13 +682,13 @@ Upload_ReactComponent.propTypes = {
682682
totalFilesCount: PropTypes.number,
683683

684684
/**
685-
* Size of uploaded files (Mb). Mb = 1024*1024 bytes.
685+
* Size of uploaded files (MB). MB = 1024*1024 bytes.
686686
*/
687687
uploadedFilesSize: PropTypes.number,
688688

689689
/**
690-
* Total size of uploaded files to be uploaded (Mb).
691-
* Mb = 1024*1024 bytes.
690+
* Total size of uploaded files to be uploaded (MB).
691+
* MB = 1024*1024 bytes.
692692
*/
693693
totalFilesSize: PropTypes.number,
694694
}

tests/apps/disabled.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_upload_component(id):
2828
text="Drag and Drop files here",
2929
text_completed="Completed: ",
3030
cancel_button=True,
31-
max_file_size=1800, # 1800 Mb
31+
max_file_size=1800, # 1800 MB
3232
filetypes=["csv", "zip"],
3333
upload_id=uuid.uuid1(), # Unique session id
3434
max_files=2,

tests/apps/testapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_upload_component(id):
2323
text_completed="Completed: ",
2424
cancel_button=True,
2525
pause_button=True,
26-
# max_file_size=130, # 130 Mb
26+
# max_file_size=130, # 130 MB
2727
# max_total_size=350,
2828
# filetypes=["csv", "zip"],
2929
upload_id=uuid.uuid1(), # Unique session id

tests/apps/testapp_noretry_remove_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_upload_component(id):
3636
text_completed="Completed: ",
3737
cancel_button=True,
3838
pause_button=True,
39-
# max_file_size=130, # 130 Mb
39+
# max_file_size=130, # 130 MB
4040
# max_total_size=350,
4141
# filetypes=["csv", "zip"],
4242
upload_id=uuid.uuid1(), # Unique session id

tests/test_disabled.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
@pytest.fixture
31-
def testfile10Mb_csv():
31+
def testfile10MB_csv():
3232
file = Path(__file__).resolve().parent / "mytestfile.csv"
3333
create_file(file, filesize_mb=10)
3434
yield file
@@ -130,7 +130,7 @@ def test_disabled01_check_disabled_property_update(dash_duo):
130130

131131

132132
def test_disabled02_check_disabled_effect(
133-
dash_duo, testfile10Mb_csv, testfileWrongType, js_drag_and_drop
133+
dash_duo, testfile10MB_csv, testfileWrongType, js_drag_and_drop
134134
):
135135
"""Check the effectiveness of the disabled and disableDragAndDrop property.
136136
The upload component with "disabled" triggered would not accept any files.
@@ -176,7 +176,7 @@ def upload_test_file_and_validate(
176176
drag_and_drag_input = driver.execute_script(
177177
js_drag_and_drop, upload, 20, 20
178178
)
179-
drag_and_drag_input.send_keys(str(testfile10Mb_csv))
179+
drag_and_drag_input.send_keys(str(testfile10MB_csv))
180180
else:
181181
# Ensure the uploading button is clickable.
182182
if expect_success:
@@ -192,7 +192,7 @@ def upload_test_file_and_validate(
192192
return
193193

194194
# Wait until file is uploaded
195-
upload_input.send_keys(str(testfile10Mb_csv))
195+
upload_input.send_keys(str(testfile10MB_csv))
196196

197197
# The fail case would be used for checking the drag and drop mode.
198198
if expect_success:
@@ -218,9 +218,9 @@ def upload_test_file_and_validate(
218218
uploaded_file = callback_output.find_element(By.XPATH, "//ul").text
219219
uploaded_file = Path(uploaded_file)
220220

221-
assert uploaded_file.name == testfile10Mb_csv.name
221+
assert uploaded_file.name == testfile10MB_csv.name
222222
assert uploaded_file.exists()
223-
assert uploaded_file.stat().st_size == testfile10Mb_csv.stat().st_size
223+
assert uploaded_file.stat().st_size == testfile10MB_csv.stat().st_size
224224

225225
# cleanup
226226
shutil.rmtree(uploaded_file.parent)

tests/test_usage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
@pytest.fixture
24-
def testfile10Mb_csv():
24+
def testfile10MB_csv():
2525
file = Path(__file__).resolve().parent / "mytestfile.csv"
2626
create_file(file, filesize_mb=10)
2727
yield file
@@ -42,7 +42,7 @@ def test_render01_render_component(dash_duo):
4242

4343

4444
# Run with pytest -k upload01
45-
def test_upload01_upload_a_file(dash_duo, testfile10Mb_csv):
45+
def test_upload01_upload_a_file(dash_duo, testfile10MB_csv):
4646
app = import_app("usage")
4747
dash_duo.start_server(app)
4848

@@ -57,7 +57,7 @@ def test_upload01_upload_a_file(dash_duo, testfile10Mb_csv):
5757
upload_input = upload.find_element(
5858
By.XPATH, "//input[@name='dash-uploader-upload']"
5959
)
60-
upload_input.send_keys(str(testfile10Mb_csv))
60+
upload_input.send_keys(str(testfile10MB_csv))
6161
# Wait until file is uploaded
6262

6363
upload_label = upload.find_element(By.XPATH, "//label")
@@ -77,9 +77,9 @@ def test_upload01_upload_a_file(dash_duo, testfile10Mb_csv):
7777
uploaded_file = callback_output.find_element(By.XPATH, "//ul").text
7878
uploaded_file = Path(uploaded_file)
7979

80-
assert uploaded_file.name == testfile10Mb_csv.name
80+
assert uploaded_file.name == testfile10MB_csv.name
8181
assert uploaded_file.exists()
82-
assert uploaded_file.stat().st_size == testfile10Mb_csv.stat().st_size
82+
assert uploaded_file.stat().st_size == testfile10MB_csv.stat().st_size
8383

8484
# cleanup
8585
shutil.rmtree(uploaded_file.parent)

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def create_file(filename, filesize_mb=1):
3636
filename: str
3737
The filename
3838
filesize_mb: numeric
39-
The file size in Mb.
39+
The file size in MB.
4040
"""
4141
with open(filename, "wb") as f:
4242
f.seek(int(1024 * 1024 * filesize_mb))

usage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_upload_component(id):
2424
text_completed="Completed: ",
2525
cancel_button=True,
2626
pause_button=True,
27-
max_file_size=130, # 130 Mb
27+
max_file_size=130, # 130 MB
2828
max_total_size=350,
2929
# filetypes=["csv", "zip"],
3030
upload_id=uuid.uuid1(), # Unique session id

0 commit comments

Comments
 (0)