return context.res.send(bytes, 200, {'Content-Type': 'application/pdf'});
- 1
- Self Hosted
- Functions
type 'Uint8List' is not a subtype of type 'String' of 'body' #0 main (package:generate_pdf/main.dart) <asynchronous suspension> #1 Future.any.onValue (dart:async/future.dart:615) <asynchronous suspension>
Future<dynamic> main(final context) async {
final pdf = PDF();
final order = FakeOrder();
var fakeOrder = order.createFakeOrder();
context.log(fakeOrder.toJson().toString());
final Uint8List? bytes = await pdf.createAndSave(fakeOrder);
if (bytes != null) {
context.log('PDF created.');
context.log(bytes);
return context.res.send(bytes, 200, {'Content-Type': 'application/pdf'});
}
return context.error("Someting gone wrong");
}
Hmm it's a little hard to tell from what you provided. Can you figure out exactly what's throwing the error?
this line return context.res.send(bytes, 200, {'Content-Type': 'application/pdf'});
ahhhh i see. that 1st parameter is supposed to be a string: https://github.com/open-runtimes/open-runtimes/blob/4044ed47c488e269a66fc381748f3af1e179e60b/runtimes/dart-3.0/src/function_types.dart#L42
Can you create a feature request for supporting non-strings?
I have created a pull-request
Thanks for contributing β¨ Could you please also implement a test for it?
You will need to add a new case here: https://github.com/Shiba-Kar/open-runtimes/blob/main/tests/resources/functions/dart-3.0/lib/tests.dart#L118
In there, write a code that creates Uint8List, and sends it as response. To create it, you can read file, create it from string Hello World
, or any other method that makes sense to you.
Next, you will need to add execution to a test script, which can be seen here: https://github.com/Shiba-Kar/open-runtimes/blob/main/tests/Base.php#L377-L388
In there you should expect specific response. Maybe bytes? Maybe multibytes? Maybe value after utf8 encoding? Not sure, do whatever feels natural to you and I will take a look during PR review.
Doing this will make tests in all other runtimes fail, but you can ignore that if you want to only focus on Dart. I can do the remaning languages, or we could ask other contributors. Just make sure they pass in Dart 3.0
Please let me know if you are intereste in continuing this PR, and if you have any questions π
yes I am actively working on it
cmd RUNTIME='dart-3.0' TEST_CLASS='Base' ENTRYPOINT='tests.dart' sh tests.sh
What's Next?
View summary of image vulnerabilities and recommendations β docker scout quickview
Preparing for build ...
Resolving dependencies...
Got dependencies!
found user package open_runtimes_test
added user package as dependency to server.
Updated server import of user code
Building ...
Resolving dependencies...
+ archive 3.4.9
+ barcode 2.2.4
+ bidi 2.0.10
+ convert 3.1.1
+ crypto 3.0.3
+ dio 5.3.4
+ image 4.1.3
+ js 0.6.7
+ open_runtimes_test 1.0.0 from path /usr/local/build
+ path_parsing 1.0.1
+ pdf 3.10.6
+ petitparser 6.0.1
+ pointycastle 3.7.3
+ qr 3.0.1
+ vector_math 2.1.4
+ xml 6.4.2
Changed 16 dependencies!
Compiling ...
Info: Compiling with sound null safety.
Generated: /usr/local/server/server
Packing build ...
Build finished.
97f4a14c5554545bb8387b09d2e3cd25547dd94c7c7174564601f7c4fc7b34ff
Waiting for servers...
Running tests...
env: php: No such file or directory
Recommended threads
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...
- Create admin user?
I'm not really sure how this is supposed to work, I installed Appwrite through docker-compose and set it up. When I launched the app and went into it, I created...