diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index 7131a8e2d4..8d8554d4d4 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -489,115 +489,6 @@ class MainActivity : AppCompatActivity() { ``` {% /multicode %} -# Get File {% #get-file %} -To get a file, use the `getFile` method. - -{% multicode %} -```js -import { Client, Storage } from "appwrite"; - -const client = new Client(); - -const storage = new Storage(client); - -client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID -; - -const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]'); - -promise.then(function (response) { - console.log(response); // Success -}, function (error) { - console.log(error); // Failure -}); -``` -```dart -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - // downloading file - Future result = storage.getFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ).then((bytes) { - final file = File('path_to_file/filename.ext'); - file.writeAsBytesSync(bytes) - }).catchError((error) { - print(error.response); - }) -} - -//displaying image preview -FutureBuilder( - future: storage.getFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ), //works for both public file and private file, for private files you need to be logged in - builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory( - snapshot.data, - ) - : CircularProgressIndicator(); - }, -); -``` -```swift -import Appwrite - -func main() async throws { - let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - let storage = Storage(client) - let byteBuffer = try await storage.getFile( - bucketId: "[BUCKET_ID]", - fileId: "[FILE_ID]" - ) - - print(String(describing: byteBuffer) -} -``` -```kotlin -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val storage = Storage(client) - - GlobalScope.launch { - val result = storage.getFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" - ) - println(result); // Resource URL - } - } -} -``` -{% /multicode %} - # Get File Preview {% #get-file-preview %} To get a file preview image , use the `getFilePreview` method.