1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Fileupload via SDK to AWS-cloudfront

Discussion in 'About fabrikar.com' started by marozen, Dec 18, 2019.

?

How to set up upload-file from SDK > CDN-push > S3/image > thumbnailfunction > S3/resized > CDN-get?

  1. Posting usefull information about it and create a Wiki about the step by step instruction

    0 vote(s)
    0.0%
  2. Create AWS-Cloudfront for push objects. Chance in fabrik fileupload the bucket name into the C-name

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. marozen

    marozen Member

    Level: Community
    Uploading images via SDK to an AWS S3 bucket has many benefits. Fabrik offers successfully a method to upload images to S3 buckets. However, cropping and thumbnails are not succeeding in my case. I think that is also not the job of Fabrik to fix. Because that's being done by the Lambda function of Amazon. Further there are very important features that are required to get optimal benefits from SDK uploads:

    - Content Delivery Network for uploading (push) files to the S3
    Why? Because uploading via SDK is often slower that to your own server, because your own server is often in your region and the AWS region might be far away. But if you set up Cloudfront (CDN) for uploads (push) you will upload the file to the nearest server of the CDN. That goes much faster than your own server.

    - Ability to create thumbnails
    Why? Because uploaded images might be 10mb, which cost for some website visitors a lot of internet data, and loading time. IF you create your own templates for Fabrik lists, forms, and details you can easily display the thumbnail from any source. Thumbnails can be created with the lambda function.

    - CDN for displaying thumbnails
    After uploading an image via your website via SDK and via cloudfront to your S3-bucket there will be the lambda function that automatically creates a thumbnail in another S3-bucket. And that S3-bucket should also be in a cloudfront, but only for downloads. That makes your site running much faster and you will safe data.

    An example of what might happen is that person A uploads a photo in New Sealand. The photo in because of the CDN safed as a cache in New Sealand and then sent to the S3 bucket. Person B in England views that image, so it needs to load all the way from the S3-region first, but the Person C that is also in England that views the same page will load it from England because the cache of person B is safed by the CDN in England.

    Expected results of those 3 settings:
    - faster uploads
    - faster downloads

    How to set this up?
    Setting up such a structure is not so easy. I tried to create the thumbnail function on Lambda, but it gives errors when the image arrives in the path that fabrik puts them in via SDK. I'm trying, and if I succeed will update.

    Otherwise, it would be great if an expertised member of Fabrik or AWS can give an instruction because these expected results I guess are important.
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Cropping and thumbnails work fine for me with S3. What problems are you having?

    -- hugh
     
  3. marozen

    marozen Member

    Level: Community
    Okay, I will check if it works. I also succeeded now with another Lambda function, but I prefer to handle thumbnails via Fabrik setting.

    But, I'm also trying to use AWS Cloudfront. I compared uploading an image to an S3 bucket and to filesystem. Filesystem is faster. Perhaps because my server is in Germany and the S3 bucket in Oregon. For GET requests I see that Cloudfront clearly works fast, but PUT doesn't. I read now something that might help:

    "If you want to submit PUT requests to CloudFront to upload files to your Amazon S3 bucket, you must add an x-amz-content-sha256 header to the request, and the header value must contain a SHA256 hash of the body of the request. For more information, see the documentation about the x-amz-content-sha256 header on the Common Request Headers page in the Amazon Simple Storage Service API Reference."

    Without Cloudfront perhaps the only reason to use AWS-SDK in fileuploads is to safe memory on your FTP. That's why I try to get PUT requests work on Cloudfront, then thumbnailing of images , and then GET requests of the Thumbnails.

    Right now I'm able to do thumbnailing via Lambda and GET requests of thumbnails over the Cloudfront Content Delivery Network, I just need to find out how to make uploads to edge-locations of the CDN.
     

Share This Page