appwrite / docs

The official https://appwrite.io/docs documentation 📝
BSD 3-Clause "New" or "Revised" License
83 stars 118 forks source link

File Input Documentation #339

Closed gewenyu99 closed 1 year ago

gewenyu99 commented 1 year ago

What does this PR do?

We have a gap in our storage docs. After introducing the InputFile class in many SDKs, we don't document this behavior clearly. This will be added, and the createFile endpoints will have updated descriptions that point here.

@Meldiron @abnegate @lohanidamodar Please help me fill in the InputFile implementations you worked on.

If no InputFile class is available, you can document some examples like this.

Screenshot 2023-02-21 at 5 46 18 PM

If InputFile is available with multiple ways to use, you can use a table:

Screenshot 2023-02-21 at 5 49 21 PM

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

abnegate commented 1 year ago

@gewenyu99

Apple/Swift InputFile.fromPath(_ path: String): Used to upload files from a provided path. InputFile.fromData(_ data: Data, filename: String, mimeType: String): Used to upload files from a Data object. InputFile.fromBuffer(_ buffer: ByteBuffer, filename: String, mimeType: String): Used to upload files from a NIO ByteBuffer object.

Kotlin/Android: InputFile.fromPath(path: String): Used to upload files from a provided path. InputFile.fromFile(file: File): Used to upload files from a provided File object. InputFile.fromBytes(bytes: ByteArray, filename: String, mimeType: String): Used to upload files from a ByteArray object.

Ruby: InputFile.from_path(path): Used to upload files from a provided path. InputFile.from_string(string): Used to upload files from string content. InputFile.from_bytes(bytes): Used to upload files from an array of bytes.

Python: InputFile.from_path(path): Used to upload files from a provided path. InputFile.from_bytes(bytes): Used to upload files from an array of bytes.

gewenyu99 commented 1 year ago

@Meldiron @lohanidamodar Can you provide some information about the InputFile classes you implemented ? 😃

Meldiron commented 1 year ago

Rest - no changes GraphQL - no changes CLI - no changes Web: No changes (we probably should implement) Dart: constructor with path or bytes ( https://github.com/appwrite/sdk-for-dart/blob/master/lib/src/input_file.dart#L11 ) Flutter: Same as Dart ( https://github.com/appwrite/sdk-for-flutter/blob/master/lib/src/input_file.dart#L11 ) Deno: fromPath() fromBuffer() fromPlainText() ( https://github.com/appwrite/sdk-for-deno/blob/master/src/inputFile.ts#L15-L33 ) Node: fromPath(), fromBuffer(), fromBlob(), fromStream(), fromPlainText() ( https://github.com/appwrite/sdk-for-node/blob/master/lib/inputFile.js#L10-L38 ) PHP: withPath() and withData() ( https://github.com/appwrite/sdk-for-php/blob/master/src/Appwrite/InputFile.php#L32-L50 )

lohanidamodar commented 1 year ago

@gewenyu99 @Meldiron @eldadfux I'm thinking of deprecating the constructors that accepts either path or bytes and instead introduce InputFile.fromBytes and InputFile.fromPath just like that of swift and android?