-
Notifications
You must be signed in to change notification settings - Fork 223
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
docs: Add React Native samples to Storage Quick Start #1064
base: main
Are you sure you want to change the base?
Changes from 8 commits
27f75d5
ebb00f7
6ec110e
c7fc26b
fe4b26f
678f269
655c0d3
56c1460
2ffe92b
a22e4f7
7234c11
9598a60
6da8fb5
b5759ef
b21be3f
2a7caa3
4e57243
180aaa0
0280cc3
dd9610e
0e45184
babfa8e
e7f0d1e
3a8a58d
113112b
4c001ab
9e24a53
48debf9
3d32999
a23eff1
aa9fd32
27b8aeb
605ad36
cf823e3
dd67e5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,34 @@ To upload a file, add this to you web, Flutter, Apple, or Android app. | |
|
||
--cec8e8123c05ba25-- | ||
``` | ||
```client-react-native | ||
import { Client, Storage, ID, Permission } from 'react-native-appwrite'; | ||
|
||
const client = new Client() | ||
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint | ||
.setProject('<PROJECT_ID>'); // Your project ID | ||
|
||
const storage = new Storage(client); | ||
|
||
const promise = await storage.createFile( | ||
'[BUCKET_ID]', | ||
ID.unique(), | ||
{ | ||
name: 'file.jpeg', | ||
type: 'image/jpeg', | ||
uri: 'file:///data/user/0/host.exp.exponent/cache/ExperienceData/text.jpeg', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also make sure the URI is something generic and reasonable :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also ask @lohanidamodar to see if there's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed with @lohanidamodar that there are currently no |
||
size: 183799 | ||
}, // FILE | ||
Permission.read('any') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure this uses the same params as all the other examples on this page. I think some other examples don't show permission, but if you want to add it here, make sure ALL examples are updated to be consistent! |
||
); | ||
|
||
|
||
promise.then(function (response) { | ||
console.log(response); // Success | ||
}, function (error) { | ||
console.log(error); // Failure | ||
}); | ||
``` | ||
{% /multicode %} | ||
|
||
|
||
|
@@ -224,4 +251,20 @@ class MainActivity : AppCompatActivity() { | |
} | ||
} | ||
``` | ||
```client-react-native | ||
import { Client, Storage, ID } from 'react-native-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 | ||
; | ||
choir241 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); | ||
|
||
console.log(result); // Resource URL | ||
``` | ||
{% /multicode %} |
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.
@choir27 We use
<>
angle brackets universally for placeholders now. I started moving toward this but didn't finish. Make sure you stay consistent!