Looking for an image hosting api for app-user uploads / maybe with mongodb-realm integration

Hi there,
we are having a question regarding finding a good image hosting API for app-user image uploads which can work best with Realm.
does mongo db have any solution for app-user image uploads? or any third-party api you recommend?

Kind regards,
Behzad :slight_smile:

Hi @Behzad_Pashaie,

I use Amazon S3 with Realm API integration (storing the s3 metadata in Realms):
https://docs.mongodb.com/realm/services/aws

The following blog uses stitch but has the same concept as it works with realm:

Thanks
Pavel

When you say ‘image hosting’ and ‘app-user uploads’ can you be more specific about the use case?

We’ve been using Firebase Could Storage for a number of years and it’s a pretty solid solution depending on what your needs are. It’s not directly integrated with realm but the API is pretty transparent and would with with a variety of other products.

@Jay,

I assume you can use Firebase storage with a rest api call from realm , but I truly believe that aws service is a much easier and cleaner way by using the S3 api.

Thanks
Pavel

@Pavel_Duchovny

Yes - REST calls are fully supported, along SDK’s for with Swift, Java, ObjC, C++

Not advocating by any means but we really like the simplicity of implementation for the Firebase Storage product. Once the pod file and project is updated, uploading and downloading files are just a few lines of code with no real struggle to add it to an existing (or new) project.

The issue we had with S3 and Stitch is the amount of hoops we went through trying to implement it (not REST) - after months of effort your team determined that the Stitch SDK isn’t supported (and doesn’t work) on macOS and they “have no plans to make it work on macOS”

There are also a number of issues with iOS and were finally told we should stick with REST (which is not part of our project implementation). So it wasn’t a solution for us.

However, for any projects relying on REST, it seems to be a smoother ride.

As a side note - it would be pretty awesome to have a connection to AWS S3 and cloud storage directly from MongoDB Realm SDK.

Just my 02. - your milage may vary.

@Jay,

The blog on stitch i mentionedd work on realm this is js sdk code working directly with S3 service:

 return convertImageToBSONBinaryObject(file)
   .then(result => {
     // AWS S3 Request
     const args = {
       ACL: 'public-read',
       Bucket: bucket,
       ContentType: file.type,
       Key: key,
       Body: result
     }

     const request = new AwsRequest.Builder()
       .withService('s3')
       .withAction('PutObject')
       .withRegion('us-east-1')
       .withArgs(args)
       .build()

     return this.aws.execute(request)
   })
   .then(result => {
     // MongoDB Request
     const picstream = this.mongodb.db('data').collection('picstream')
     return picstream.insertOne({
       owner_id: this.client.auth.user.id,
       url,
       file: {
         name: file.name,
         type: file.type
       },
       ETag: result.ETag,
       ts: new Date()
     })
   })
   .then(result => {
     // Update UI
     this.getEntries()
   })

Thanks
Pavel

@Pavel_Duchovny That’s great info!

We are Swift based and would love to take advantage of that; Is an S3 connection something included in the MongoDB Realm Swift/ObjC SDK? We don’t do any js at all so that would be fantastic if it did.

Hi @Jay,

I couldn’t find docs on the realm sdk, but the stitch has it:
http://stitch-sdks.s3-website-us-east-1.amazonaws.com/stitch-sdks/swift/6/Protocols/AWSServiceClient.html

Test if similar ways work with realm sdks.

If it won’t you can call functions from sdk, this is definitely supported and pass base64 data to them for upload:
https://docs.mongodb.com/realm/services/snippets/s3/#upload-an-image-to-s3

Thanks
Pavel

@Pavel_Duchovny

Thanks - as mentioned we are macOS based and Stitch does not work on macOS.

It looks like the S3 connectivity is not included in any of the current SDK’s according to this thread so we will just have to stick with Firebase Storage for now.

Hi @Pavel_Duchovny. Sorry for a bitt late reply.
Thanks for kind reply. Will check it out .
Wish you a nice day forward :pray: :blush:

Hi @Jay . Sorry for a bitt late reply.
Thanks for kind reply. More specific is, when user add an item so we have form with fields and an upload field for images. What i ment is an api service where we upload these images. And later GET them to be viewed in item page.
Wish you a nice day forward :pray: :blush: