Rank 4: Virtual Machine
I've got a cloud function written in Dart-3.12 that I'm trying to create a file in a file bucket. I'm using the latest dart_appwrite sdk (26.1.0) and Appwrite 1.9.5 on a local selfhosted instance. I'm using http://host.docker.internal/v1 as the endpoint inside of the function. I've tried using the dynamic api key generated for the function as well as a manually created api key (that is saved in an env var), and both have the issue even though they have all scopes. Below is where I'm creating the client that is then fed into the Storage(client) object for saving the file in a bucket.
final client = Client() ..setEndpoint(injectedEndpoint.contains('localhost') ? 'http://host.docker.internal/v1' : injectedEndpoint) ..setProject(Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'] as String) ..setKey(context.req.headers['x-appwrite-key'] ?? context.req.headers['X-Appwrite-Key']);Again, I've logged exactly what is being saved for each of those and the expected values are used. Whenever I do:
var fileBytes = await Storage(client).getFileDownload( bucketId: importDataBucketId, fileId: fileId, );then I get this error:
AppwriteException: project_id_missing, When using project API key, make sure to pass x-appwrite-project header with your project ID. (403)