Skip to content
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 type error: Remove duplicate section from 'Upload and Download' docs (#330) #341

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions src/routes/docs/products/storage/upload-download/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down