Open alexdess opened 1 week ago
Thank you for the detailed bug report!
We need to take a pass on the bucket implementation. There is already a PR for a complete new implementation of the GCP bucket using the real google endpoints rather than AWS compatibility layer. You can find the PR here: https://github.com/serverpod/serverpod/pull/2745.
The final implementation may differ from what is in there right now, but that code does work and should solve most if not all the above mentioned issues.
Thanks for your reply. PR looks promising What about uploading ByteData files from the client to the server. Is this the right approach, or is it not planned to be able to transit files in this way?
This is possible today already. You can use the file upload API, there is only one serverside integration for this and it writes the file to the db.
If you want to manage this in memory you can set the maxRequestSize
in the config to increase the byte limit in the endpoints. See: https://docs.serverpod.dev/concepts/configuration#configuration-options
Thank you for opening this issue. I have been also facing this using GCP Storage.
1) I get the file description and the file get uploaded. But it returns success: false.
2) The verify File exists and getPublicUrl is not working correctly.
3) The privacy concerns that every person shall only see their own files is very important.
Happy seeing there will be progress. When we can get the new implementation because it's required for our app. Thank you.
Describe the bug I am encountering several issues when using file upload and retrieval through Google Cloud Platform (GCP). After reading the existing issues and setting up my bucket and configuration files, I am facing the following errors:
Issue with direct ByteData upload: When I try to upload a ByteData object to a custom endpoint, I get the following error:
Connection closed before full header was received, uri = http://localhost:8080/[endpointName]
The test was performed with a png of 1.6MBytes.Issue with file permissions after upload: When using the FileUpload component on the client side, the file uploads successfully but is made public, even though I have configured the bucket for private files (public: false).
Issue with server-side file retrieval: When I try to retrieve a file server-side, it only works if the file is at the root of the bucket. For example:
succursale/logo.png
does not work.logo.png
works.This happens with the retrieveFile and getPublicURL methods.
To Reproduce Steps to reproduce the behavior:
Expected behavior
2.. Respect file privacy settings during upload: When I upload a file using the FileUpload method, the file should be stored as private in GCP, as configured (public: false).
Serverpod versions
Platform information Db and redis on Docker. Server and client on localhost using vscode debugger
Additional context
client code
```dart Future _updateLogoDirect(BuildContext context, String id) async { var succId = int.tryParse(id); if (succId == null) { return; } // ask user to upload image FilePickerResult? result = await FilePicker.platform.pickFiles( allowMultiple: false, type: FileType.image, ); if (result == null) { return; } var file = result.files.single; var bytes = await file.xFile.readAsBytes(); if (bytes == null) { return; } var byteData = bytes.buffer.asByteData(); await client.succursale.setLogo(succId, byteData); } Future _updateLogoFileUploader(BuildContext context, String id) async { var succId = int.tryParse(id); if (succId == null) { return; } // ask user to upload image FilePickerResult? result = await FilePicker.platform.pickFiles( allowMultiple: false, type: FileType.image, ); if (result == null) { return; } var file = result.files.single; var bytes = await file.xFile.readAsBytes(); if (bytes == null) { return; } var logoStoragePath = await client.succursale.getLogoStoragePath(succId); if (logoStoragePath == null) { return; } FileUploader uploader = FileUploader(logoStoragePath); var byteData = bytes.buffer.asByteData(); uploader.uploadByteData(byteData); } ```server code
```dart Future