kkazuo / dart-azblob

ISC License
8 stars 6 forks source link

Error on Web platform #12

Open armthanachot opened 1 year ago

armthanachot commented 1 year ago

i got error when i run on web

pubspec.yaml

Screenshot 2566-11-27 at 16 04 37

ClientException: XMLHttpRequest error., uri=https://fileStore1.blob.core.windows.net/myfile/pdf-27-11-2023-15-58-4-0-0.pdf

kkazuo commented 12 months ago

I have no idea for run on web for now. But I have released azblob 3.0.0 that uses universal_io for internal http clients. You may be try them.

Thank you,

noahjoshua commented 10 months ago

Any update to this?

kkazuo commented 10 months ago

You can use azblob 3.0.1 on web. If you not, please show the reproduce code and show all the error messages.

As a side note. Azure Storage is not CORS enabled by default. You need to enable it yourself.

List CORS settings

az storage cors list --connection-string=$CS

Add CORS settings

az storage cors add --methods 'GET,POST,PUT,DELETE' --origins '*' --services=b --allowed-headers=authorization,x-ms-date,x-ms-version --connection-string=$CS

($CS is your connection string)

Thanks,

noahjoshua commented 10 months ago

Azblob does definitely not support web, as it depends on Universal IO, which despite claiming to support web, does not.

dart-sdk/lib/async/stream_impl.dart 402:7 [_sendDone] dart-sdk/lib/async/stream_impl.dart 291:7 [_close] dart-sdk/lib/async/stream_transformers.dart 87:11 [_close] dart-sdk/lib/async/stream_transformers.dart 21:5 close dart-sdk/lib/convert/string_conversion.dart 241:5 close dart-sdk/lib/convert/string_conversion.dart 295:7 close dart-sdk/lib/convert/chunked_conversion.dart 78:5 close dart-sdk/lib/async/stream_transformers.dart 132:7 [_handleDone] dart-sdk/lib/async/zone.dart 1582:9 runGuarded dart-sdk/lib/async/stream_impl.dart 392:7 sendDone dart-sdk/lib/async/stream_impl.dart 402:7 [_sendDone] dart-sdk/lib/async/stream_impl.dart 534:13 perform dart-sdk/lib/async/stream_impl.dart 620:10 handleNext dart-sdk/lib/async/stream_impl.dart 591:7 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7 <fn>

kkazuo commented 10 months ago

I’m currently working next release. It will work without universal_io. And it will work on flutter-web too. Have a good weekend!

kkazuo commented 10 months ago

Thank you for your patience. I have released the next version of azblob as 4.0.0. This version uses http instead of universal_io for HTTP client requests. The public API are almost compatible I think. You can try this. Any feedbacks are appriciated.


Please dont forget CORS enabled for using Azure Storage from Web.

az storage cors add --methods 'GET,POST,PUT,DELETE' --origins '*' --services=b --allowed-headers=authorization,x-ms-blob-type,x-ms-date,x-ms-version --connection-string=$your_conn_str
xeladu commented 9 months ago

I can confirm that this works on Flutter web!

noahjoshua commented 9 months ago

This is still not working on web: await storage.putBlob('reports/test.pdf', bodyBytes: file.files.first.bytes, contentType: 'application/pdf');

Error: The MAC signature found in the HTTP request '...' is not the same as any computed signature

kkazuo commented 9 months ago

@noahjoshua could you try this?

await storage.putBlob('/reports/test.pdf', bodyBytes: file.files.first.bytes, contentType: 'application/pdf');
//---------------------^ path starts with slash (/)
noahjoshua commented 9 months ago

Already did, still same result unfortunately

noahjoshua commented 9 months ago

Apologies, I've found the issue in the package being outdated on my end :)