wave icon indicating copy to clipboard operation
wave copied to clipboard

Uploads fail if file has no extension

Open g-eoj opened this issue 3 years ago • 3 comments

Wave SDK Version, OS

0.23.0, Mac OSX

Actual behavior

Uploaded an AWS credentials file using ui.file_upload, file gets created on wave server with text "Not Found".

Logs show when I try to download the file:

2022/09/16 17:07:33 # {"error":"not found","path":"/_f/80b79c0e-5685-42df-8c2c-450a19f60689/credentials","t":"file_download"}

Expected behavior

Ability to upload files without extensions.

g-eoj avatar Sep 17 '22 00:09 g-eoj

Thanks for opening the issue @g-eoj! Unfortunately, I am not able to repro:

# Form / File Upload
# Use a file #upload component to allow users to upload files.
# #form #file_upload
# ---
from h2o_wave import main, app, Q, ui


@app('/demo')
async def serve(q: Q):
    if 'file_upload' in q.args:
        q.client.file_upload = q.args.file_upload[0]
        q.page['example'] = ui.form_card(box='1 1 4 10', items=[
            ui.text(f'file_upload={q.args.file_upload}'),
            ui.button(name='download', label='Download'),
        ])
    elif q.args.download:
        foo = await q.site.download(q.client.file_upload, '.')
    else:
        q.page['example'] = ui.form_card(
            box='1 1 4 10',
            items=[
                ui.file_upload(name='file_upload', label='Upload!', multiple=True, max_file_size=10, max_size=15)
            ]
        )
    await q.page.save()

Can you maybe add a min repro code along side with the file you are trying to upload (with fake creds ofc).

mturoci avatar Sep 19 '22 14:09 mturoci

Hi @mturoci, I tried your repro file and still got the error.

Here's a better description of the error, see the "not found" messages and file contents:

Screen Shot 2022-09-21 at 9 48 20 AM

Here's the file info I reproed with (I can't upload it, probably dud to the file name):

Screen Shot 2022-09-21 at 9 54 48 AM

g-eoj avatar Sep 21 '22 16:09 g-eoj

I can repro @g-eoj 's issue with Wave v0.23.1 on MacOS using any file without an extension (content inside file doesn't matter).

vopani avatar Sep 21 '22 17:09 vopani

Reproed. It confused me that there was no err thrown in python terminal and file got created anyway, it's just not cattable. Thanks both @g-eoj and @vopani!

mturoci avatar Sep 22 '22 07:09 mturoci

After a bit of digging into the code it seems like we do not support ext-less files on purpose. @lo5 maybe extensionless files could be handy in some scenarios? Adding the functionality shouldn't be that hard either - just a check if the extensionless file is present on the disk. Wdyt?

Will also add a proper err handling to the py download function so that the err is obvious.

mturoci avatar Sep 22 '22 08:09 mturoci