https://metaplay.io logo
Image transfer, best to offload to HTTP?
# questions-and-feedback
a
Hi again. In our game, we submit images from the client to the backend, and image responses back as well. Is the Metaplay protocol suitable for image transfers? I tested just putting JPG and PNG bytes in an array in an action, and it works, but I don't know if it's actually wise. Maybe we should just offload that to HTTP instead? We are already using the CDN and HTTP for images in the app in other places, but not yet for uploads from the client. We haven't had probs with the byte arrays in actions otherwise, but also have not tested over flaky connections. And we did hit this size limit: > Maximum packet on-wire size exceeded for PlayerExecuteUnsynchronizedServerAction (size=1100151, uncompressedSize=1099809, max=1048576, uncompressedMax=5242880)
n
I would say no to sending images over the Metaplay protocol unless it's something very small and simple. It will work as you tried already, but it's definitely not what it has been designed for 😅 The Metaplay SDK does some duplication and serialization/deserialization of the actions and messages, so having large binary blobs in that data will significantly slow things down and eat up unecessary memory. Having a separate service for image uploads and distribution (over http or any other suitable protocol) is probably the best solution, which could be built as a server side entity to easily talk with the other server components. You'll have to talk to our infra team to set up the necessary cloud magic for that, though. Or figure out the best way to do it in our cloud infra, I'm not sure.
a
yep yep. i did the change already for server -> client images, already had the code to make public CDN blobs and am now using them in all places. i also found a way to do signed S3 upload URLs using the S3 BlobStorage from Metaplay, I did need to add one method there for that .. didn't take that to use yet, as the client -> server images we do are small and working fine in the internal proto, but i'll probably switch that too soon
that's what I added to your S3BlobStorage, didn't test yet
Copy code
csharp
        public string GetPresignedUrlForUpload(string filePath)
        {
            var request = new GetPreSignedUrlRequest
            {
                BucketName = _bucketName,
                Key = GetEntryKeyName(filePath),
                Verb = HttpVerb.PUT, // Specify PUT for upload
                Expires = DateTime.Now.AddDays(7),
            };

            string preSignedUrl = _client.GetPreSignedURL(request);
            return preSignedUrl;
        }
n
Ah, that looks like a great solution. 👍 Let me know how it works out for you.