FileSystemException: Cannot open file, path = 'file:///usr/local/server/src/static/index.html' (OS E
- 1
- Self Hosted
- Functions
Just copied the util.dart file
To my code
And pushed using the CLI
What's your folder structure and what's the function in your appwrite.json?
"projectId": "64fff1b78429690cbb74",
"projectName": "windope",
"functions": [
{
"$id": "65480141667102a7bf37",
"name": "site",
"runtime": "dart-2.17",
"execute": [],
"events": [],
"schedule": "",
"timeout": 15,
"enabled": true,
"logging": true,
"entrypoint": "lib/main.dart",
"commands": "dart pub get",
"ignore": [
".packages",
".dart_tool"
],
"path": "./"
}
]
}
final String _dirname = Platform.script.toFilePath();
final String staticFolder = '${Uri.file(_dirname).resolve('../static')}';
/// Throws an error if any of the keys are missing from the object
/// @param obj - The object to check
/// @param keys - The list of keys to check for
/// @throws Exception
void throwIfMissing(Map<String, dynamic> obj, List<String> keys) {
final missing = <String>[];
for (var key in keys) {
if (!obj.containsKey(key) || obj[key] == null) {
missing.add(key);
}
}
if (missing.isNotEmpty) {
throw Exception('Missing required fields: ${missing.join(', ')}');
}
}
/// Returns the contents of a file in the static folder
/// @param fileName - The name of the file to read
/// @returns Contents of static/{fileName}
Future<String> getStaticFile(String fileName) {
return File('index.html').readAsString();
}
even I have done this dart return File('index.html').readAsString();
Look at the files in the template. The html file should be in a folder named static
yes I have done that only in the begning
still same error
What?
return File('index.html').readAsString();
}
``` have hardcored the file path
Have you tried doing it as the template does?
In the starting I have followed the same file structure
Yes I have
getting the same error
Please share what you have after you change it to what the template did
its simply serves a index.html on GET at /
hmm odd...let me check with the team
yes I am contributing to appwrite/template ,
pull request just pending on this @Drake
For now, you might want to put a string in your code rather than trying to have a static file
I'm experiencing the same problem. any solution?
Error:- PathNotFoundException: Cannot open file, path = 'file:///usr/local/server/src/static/index.html' (OS Error: No such file or directory, errno = 2)
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...