Sign in
Log inSign up
Louis Moreaux

2 likes

·

739 reads

6 comments

Jon Dixon
Jon Dixon
Aug 24, 2022

Nice! This is now my reference document for APEX CKEditor image handling in the cloud.

1
·
·1 reply
Louis Moreaux
Louis Moreaux
Author
·Aug 24, 2022

Thanks Jon Dixon for challenging me! Really motivating 🙏

·
Nicolas Pilot
Nicolas Pilot
Aug 25, 2022

Excellent Louis, Thanks for sharing this.

Yes I think that for this case (CKEditor Image), this is the best solution (because of the simplicity).

For other use cases, with a lot of file uploads by users, we definitely need to avoid the files handling by the database and send the files directly from the browser to the cloud storage...

1
·
·1 reply
Louis Moreaux
Louis Moreaux
Author
·Aug 25, 2022

Thanks Nicolas Pilot! Yes, I will maybe look some days at the custom adapter 🙂

1
·
Yuji Nakakoshi
Yuji Nakakoshi
Aug 26, 2022

Thank you very much, Louis. I followed your instruction and add some changes.

  1. In ORDS POST hander, return Object Storage URL instead of ORDS GET URL.
  2. Get pre authenticated request URL just after APEX session is authenticated and store it in Application Item. (by Application Computation)
declare
    l_response dbms_cloud_oci_obs_object_storage_create_preauthenticated_request_response_t;
    l_result   dbms_cloud_oci_object_storage_preauthenticated_request_t;
    l_details dbms_cloud_oci_object_storage_create_preauthenticated_request_details_t;
    l_url varchar2(4000);
    preauth_request_error exception;
begin
    l_details := dbms_cloud_oci_object_storage_create_preauthenticated_request_details_t;
    l_details.name := 'standard-' || sys_guid();
    l_details.bucket_listing_action := 'Deny';
    l_details.object_name := null;
    l_details.access_type := 'AnyObjectRead';
    l_details.time_expires := systimestamp + interval '1' day;
    l_response := dbms_cloud_oci_obs_object_storage.create_preauthenticated_request (
        namespace_name => :G_NAMESPACE
        , bucket_name => :G_BUCKET
        , create_preauthenticated_request_details => l_details
        , region => :G_REGION
        , credential_name => :G_CREDENTIAL
    );
    if l_response.status_code != 200 then
        raise preauth_request_error;
    end if;
    l_result := l_response.response_body;
    l_url := 'https://objectstorage.' || :G_REGION || '.oraclecloud.com' || l_result.access_uri;
    return l_url;
end;
  1. Replace the image URL to Pre authenticated URL within editingDowncat.
                    if ( data.attributeNewValue ) {
                        if ( data.attributeNewValue.startsWith("&G_OBJECT_STORAGE_URL.")) {
                            data.attributeNewValue = data.attributeNewValue.replace("&G_OBJECT_STORAGE_URL.","&G_PREAUTH_URL.");
                        }
                    }

I hope you find it interesting.

1
·
·1 reply
Louis Moreaux
Louis Moreaux
Author
·Aug 29, 2022

Hi Yuji, This is amazing, thanks for sharing it here. I will definitely dig deeper into pre-authenticated requests because it seems like the perfect solution for this use case.

·