2 likes
路
555 reads
6 comments
Nice! This is now my reference document for APEX CKEditor image handling in the cloud.
Thanks Jon Dixon for challenging me! Really motivating 馃檹
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...
Thanks Nicolas Pilot! Yes, I will maybe look some days at the custom adapter 馃檪
Thank you very much, Louis. I followed your instruction and add some changes.
- In ORDS POST hander, return Object Storage URL instead of ORDS GET URL.
- 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 := 'objectstorage.' || :G_REGION || '.oraclecloud.com' || l_result.access_uri;
return l_url;
end;
- 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.
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.