-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix File Create Docs #429
Fix File Create Docs #429
Conversation
@lohanidamodar I feel like the behavior of the Dart SDK isn't consistent with the other SDKs. It still takes an object like this: Future result = storage.createFile(
bucketId: 'default',
fileId: 'unique()',
file: InputFile(path: './test.file', filename: 'test.file'),
); When I update the docs, I will change the parameter description from We either have to make the description different for Dart (which I don't think is possible (?)) or we should change the current Dart SDK to also take a string. |
@TorstenDittmann See if these changes look good. |
We don't take path and instead use our own object, as we also accept MultiPart file, perks of Flutter web and Dart JS. So we cannot change this to accept file path. For now it's ok to leave the param description as it is, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. Can we also test all of these to make sure they are correct? We could test and document all regarding relative and absolute path.
src/SDK/Language/Node.php
Outdated
@@ -127,7 +127,7 @@ public function getParamExample(array $param) | |||
$output .= '{}'; | |||
break; | |||
case self::TYPE_FILE: | |||
$output .= "fs.createReadStream(__dirname + '/file.png')"; | |||
$output .= "__dirname + '/file.png'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be as simple as Deno, IIRC 'file.png'
src/SDK/Language/Node.php
Outdated
@@ -146,11 +146,11 @@ public function getParamExample(array $param) | |||
$output .= "'{$example}'"; | |||
break; | |||
case self::TYPE_FILE: | |||
$output .= "fs.createReadStream(__dirname + '/file.png')"; | |||
$output .= "__dirname + '/file.png'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
src/SDK/Language/PHP.php
Outdated
@@ -309,7 +309,7 @@ public function getParamExample(array $param) | |||
$output .= '[]'; | |||
break; | |||
case self::TYPE_FILE: | |||
$output .= "new \CURLFile('/path/to/file.png', 'image/png', 'file.png')"; | |||
$output .= "'/path/to/file.png'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how absolute path would work. Can we keep this relative? Also, can we keep all examples consistant? We could do just 'file.png'
everywhere
src/SDK/Language/PHP.php
Outdated
@@ -330,7 +330,7 @@ public function getParamExample(array $param) | |||
$output .= "'{$example}'"; | |||
break; | |||
case self::TYPE_FILE: | |||
$output .= "new \CURLFile('/path/to/file.png', 'image/png', 'file.png')"; | |||
$output .= "'/path/to/file.png'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@Meldiron Sounds good. Let's standardize all the paths in examples. There's no reason to use a million different things |
Yep I tested these examples manually. I will do them again with the the same type of path params (ideally use the same path parameters) I'm going to be out until May 1st, so I'll get on it when I get back. |
@lohanidamodar I believe I've covered every SDK that now uses a path instead of a buffer. There are several that did not change. |
Team, I hate to say it but your node.js documentation is still wrong. Your example on The AppWrite documentation uses the object you discuss as a Dart object above:
But there is no class InputFile in Node. Thus, using the example code results in an undefined error wherever this line exists in my code.
In #32 the OP says it takes a string on line 332 of storage.js. I find that in the current version it is back to taking an InputFile: Linked Code, not sure how to make it preview like OP did. There is nothing complex about my test code and in looking at the SDK it appears you define the model for InputFile and export it apparently properly but it's not working?
fs.readdir returns a string array by default, so file should be a string and this should work if the compiler could find InputFile's definition. Any thoughts? Thanks! |
Team, Further to the above it occurred to me I could do named imports from the package. So, a working snippet that should be along the lines of what's in documentation: `const { Client, InputFile, Storage } = require( 'node-appwrite' ); // Init SDK const storage = new Storage( client ); client var path = '/your-path/'; //passsing directoryPath and callback function
}); Best regards, EP |
Currently, the documentation for creating files passes in a file binary. Our current implementation only accepts a file path. This must be corrected in the documentation for all SDKs.
Node SDK ✅
Deno SDK ✅
PHP SDK ✅
Python SDK ✅
Ruby SDK ✅
Dart SDK ✅ (this hasn't changed)
Kotlin (Java) ✅ (this hasn't changed)
Kotlin (Kotlin) ✅ (this hasn't changed)
Swift ✅ (this hasn't changed)
Related to
appwrite/sdk-for-node#32