Is it possible to get Signed PUT URL for amity image?

After uploading image to amity and retrieving get url for that amity image, I want to add filter to the image in the backend and rewrite existing image with new image by using Signed Url with write access, would this be possible?

Hello @danielkang98, We’re afraid that rewriting an existing image with a new image using a Signed URL with write access is not possible. Once an image is uploaded to Amity and a URL is retrieved, it cannot be modified or replaced directly through the Signed URL mechanism.

Then how about can I pass in signed get url of an image location in firebase storage and pass it as an amity image? I am trying to achieve like shown below:

HOWEVER I am getting an error stating “File Not Found”

          String fileUrl = await httpPostImageServer(
            file: output,
            fields: {'createdAt': DateTime.now().toIso8601String()},
          );

          AmityFileProperties fileProperties = AmityFileProperties()
            ..fileId = const Uuid().v4()
            ..fileUrl = fileUrl
            ..createdAt = DateTime.now()
            ..updatedAt = DateTime.now()
            ..name = output.path.split("/").last
            ..ext = output.path.split("/").last.split(".").last
            ..size = output.lengthSync().toString()
            ..mimeType = lookupMimeType(output.path, headerBytes: [0xFF, 0xD8])
            ..isFull = false;

          AmityImage tempImage = AmityImage(fileProperties);

          try {
            var amitypost = await PostService().createMyImagePost(tempImage);
          } catch (exception) {
            print(exception.toString());
          }

The error “File Not Found” you’re encountering could result from several issues related to how the image file is being handled and passed to Amity through a signed URL from Firebase Storage. Here are some possible causes and solutions:

  1. Validate the Signed URL: Ensure the Firebase Storage signed URL is valid by loading it in a web browser.
  2. Check URL Expiry: Confirm the signed URL hasn’t expired before it’s used by Amity.
  3. Use HTTPS: Make sure the URL starts with https for secure connections.
  4. Ensure Proper Await Usage: Verify that all asynchronous operations are awaited correctly, and handle any exceptions that arise.
  5. Verify URL After Posting: After generating the fileUrl, check that it accurately points to the image.
  6. Meet Amity SDK Requirements: Ensure all AmityFileProperties comply with Amity SDK’s requirements, including file size and type.
  7. Review Backend Server Logic: If using a custom function for image uploads, confirm it’s functioning as expected and returns the correct URL.
  8. Enhance Logging: Implement detailed logging to identify where the error occurs and examine any caught exceptions for additional insights.

Other approaches you could consider are using the ‘custom post’ type, or alternatively, adding the URL to the post metadata and customizing the frontend to render it accordingly.

API create a post: Amity API

Custom post

  • When dataType is set as the custom name (dot separated string format, see the dataType field section), data payload can be anything but it will not support normal data capability (ex. text data will not be created) and data payload size will be limit to 100kb
  • attachments will be ignored, users need to keep them in data field and handle the file info by themselves