Skip to content

Can't upload a file to S3. Can't see the problem. #2655

Closed

Description

@qiqetes

Discussed in #2651

Originally posted by qiqetes August 21, 2024

// CLIENT CODE
String? uploadDescription =
    await client.X.getUploadImageDescription();

if (uploadDescription == null) return;

final image = File(state.compressedImagePath!);
print("Attempting upload: ${image.path}");
final Stream<List<int>> stream = image.openRead();

final fileUploader = FileUploader(uploadDescription);
bool uploaded =
    await fileUploader.upload(stream, image.readAsBytesSync().length);
print("Was uploaded $uploaded"); // Always FALSE, nothing on the S3
// bool uploaded = await client.X.verifyUpload();

I get the uploadDescription, looks ok, the image that I'm trying to upload is 8kb. I wish it wasn't a true/false but an Exception with some message what comes from upload method. I don't know what I'm doing wrong.

I think I have followed the docs very meticulously, still can't upload there. I have set the S3 private with a CloudFront, and this at the server side:

return await session.storage
      .createDirectFileUploadDescription(storageId: "private", path: "noslashatstart/whatever/x"); 

In server.dart:

 pod.addCloudStorage(s3.S3CloudStorage(
    serverpod: pod,
    storageId: 'private',
    public: false,
    region: 'us-west-1',
    bucket: 'xxx',
    publicHost: 'xxxx.cloudfront.net',
  ));

After debugging I get the error:
<Error><Code>AccessControlListNotSupported</Code><Message>The bucket does not allow ACLs</Message>
With statusCode 400, but if ACL is not allowed in my bucket it shouldn't try to upload with ACL.

I don't know if it's my fault or this case is not contemplated by serverpod.

Activity

  1. added
    area: storage
    on Sep 2, 2024
  2. added
    bug
    on Jan 3, 2025
  3. LeonidVeremchuk commented on Jul 16, 2025

    @LeonidVeremchuk
    Contributor
    Image

    The SDK is missing the public parameter when retrieving the file descriptor. I'm too lazy to submit a PR, but hopefully this will get fixed eventually.

  4. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: storagebug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions