26
loading...
This website collects cookies to deliver better user experience
center
so your existing code will not break.gravity
param and value which can be one of top, top-left, top-right, left, right, bottom, bottom-left and bottom-right50x200px top-left | 50x200px top-right | 150x200px center |
---|---|---|
![]() |
![]() |
![]() |
FutureBuilder<Uint8List>(
future: storage.getFilePreview(fileId: 'fileId', width: 300, height: 500, gravity: 'top'),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Image.memory(snapshot.data!);
}
if (snapshot.hasError) {
if (snapshot.error is AppwriteException) {
print((snapshot.error as AppwriteException).message);
}
print(snapshot.error);
}
return CircularProgressIndicator();
},
),
<script>
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2'); // Your project ID
let result = sdk.storage.getFilePreview('[FILE_ID]', 300, 500, 'top');
document.getElementById('preview').src = result;
</script>
<img src="#" id="preview">
// ... Imports
class X : Fragment() {
private lateinit var binding: FragmentXBinding
override fun onCreateView(
inflater: LayoutInflater ,
container: ViewGroup? ,
savedInstanceState: Bundle?
): View {
binding = DataBindingUtil.inflate(
inflater,
R.layout.fragment_x,
container,
false
)
binding.lifecycleOwner = viewLifecycleOwner
val storage = Storage(Client.client)
GlobalScope.launch(Dispatchers.Main) {
val result = storage.getFilePreview(
fileId = "[FILE_ID]",
gravity = "top-left",
width = 100,
height = 50
)
val image = BitmapFactory.decodeStream(result.body!!.byteStream())
binding.image.setImageBitmap(image)
}
return binding.root
}
}