i want to display these images in oracle apex:
Images are saved on local network share folder in following path:
\\SCANS\01\01-0001.GIF
\\SCANS\01\01-0002.GIF
\\SCANS\01\01-0003.GIF
...
\\SCANS\99\99-9999.GIF
You might want to upload those images to Oracle Apex using
Application --> Shared Components --> Static files --> Upload file
Then,once the images are in Apex, you can use #APP_IMAGES#nameoftheimage.gif to reference the image and use it in your application.
Regards
Connect to SQL plus as SYS and create directory:
create directory my_img_dir as 'c:\my_images\';
Grant read privilege on directory to DAD user (ANONYMOUS):
grant read on directory my_img_dir to anonymous;
Grant read privilege on directory to your application parsing schema. Change "my_schema" to your own schema:
grant read on directory my_img_dir to my_schema;
Create new app and 2 blank pages. I assume first page (id 1) is where you show images. Second page (id 2) is just for call application process. Create application process point "On Load:Before Header"
DECLARE
l_lob BFILE;
l_length NUMBER;
BEGIN
l_lob := BFILENAME('MY_IMG_DIR', :REQUEST);
l_length := DBMS_LOB.getlength(l_lob);
htp.flush;
htp.init;
htp.p('Content-length: ' || l_length);
htp.p('Content-Disposition: inline; filename="&REQUEST."');
-- close the headers
owa_util.http_header_close;
-- download the BLOB
wpg_docload.download_file(l_lob);
--
END;
Make process conditional if page is 2. Create HTML region to page 1 and place to region source:
<img src="f?p=&APP_ID.:2:&APP_SESSION.:my_picture.gif" alt="">
Note: More info please go this link https://blog.jaris.fi/apex/f?p=BLOG:READ:::NO::ARTICLE:91800346957167
1: Create Directory to save File and add privilege to write on Directory to You User
CREATE OR REPLACE DIRECTORY STOCK_DIR2 AS 'C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\i\STOCK_IMAGE';
GRANT read, write ON DIRECTORY STOCK_DIR2 TO STOCK;
2: Create column html expression in interactive grid Report
2: to get image dynamically
Note: this code copied from another blog. but fo preview image from directory i use this code
If those images are accessible from the client's side from an URL you should be able to render them in you page without any intervention from the application server.
We have an "image bucket" from which I access most of the images required for the application and it is as simple as uploading static files to APEX.
if you want to render in an image tag you could
<img src="URL_TO_IMAGE"/>
and technically you could serve them as background images for tags using CSS
.selector{
background-image:url(URL_TO_IMAGE);
}
Related
I just imported my app into a different workspace (a developer one) and am having issues while trying to open it up. I get the following error:
Insufficient privileges, user is not a Contributor
Access denied by Application security check
Technical Info (only visible for developers)
is_internal_error: true
apex_error_code: APEX.AUTHORIZATION.ACCESS_DENIED
component.type: APEX_APPLICATION_AUTHORIZATION
component.id: 7520010788215408503
component.name: End User Role
error_backtrace:
----- PL/SQL Call Stack -----
object line object
handle number name
0x6e2ee250 960 package body APEX_210100.WWV_FLOW_ERROR.INTERNAL_GET_ERROR
0x6e2ee250 1028 package body APEX_210100.WWV_FLOW_ERROR.INTERNAL_ADD_ERROR
0x6e2ee250 1420 package body APEX_210100.WWV_FLOW_ERROR.RAISE_INTERNAL_ERROR
0xab143348 831 package body APEX_210100.WWV_FLOW_AUTHORIZATION.IS_AUTHORIZED
0x6137ca48 2919 package body APEX_210100.WWV_FLOW.SHOW
0x6137ca48 5323 package body APEX_210100.WWV_FLOW.RESOLVE_FRIENDLY_URL
0xb05740f0 4 anonymous block
I tried to add myself as an admin using the following procedure:
begin
APEX_ACL.ADD_USER_ROLE (
p_application_id => 255,
p_user_name => 'SCOTT',
p_role_static_id => 'ADMINISTRATOR' );
end;
And I actually see myself on the apex_appl_acl_user_roles table but still get the same result when trying to open up my app.
Authorization Scheme (shared components -> security) is set to 'End User' (which is basically two levels down on the hierarchy. Admin being the top one).
Does anyone know how to fix this?
thanks!
Roles are exported along with the app, users are not. Try giving yourself all roles via Shared Components > Application Access Control. Or use sql commands to backup the other apps' roles and restore them in this workspace. Here is a blog explaining how you can do that: https://seanstuber.com/2019/06/06/extracting-apex-access-control-users/
I'm running Apex 19.2.
I have a pdf stored as blob file in a table. I'm trying to download the blob in a page process.
The process works fine however, the file doesn't download but gets displayed in the browser instead.
Can anyone help please ? I need the file to download and not show in the browser...
Here is my code :
File Blob; -- Blob content is set somewhere else...
sys.HTP.init;
sys.OWA_UTIL.mime_header(MimeType, FALSE);
sys.HTP.p('Content-Length: ' || DBMS_LOB.getlength(File));
sys.HTP.p('Content-Disposition: filename="report.pdf"');
sys.OWA_UTIL.http_header_close;
sys.WPG_DOCLOAD.download_file(file);
apex_application.stop_apex_engine;
Thanks,
Cheers,
Change this line:
sys.HTP.p('Content-Disposition: filename="report.pdf"');
To this:
sys.HTP.p('Content-Disposition: attachment; filename="report.pdf"');
By default this is an individual browser setting, a preference configurable by end users.
https://www.makeuseof.com/tag/download-pdf-files-chrome/
https://answers.microsoft.com/en-us/edge/forum/all/how-to-change-microsoft-edge-to-download-pdf-files/b24dc4b7-14b5-4fe4-85ac-71e28953635e
https://support.mozilla.org/en-US/questions/985483
It does appear that it can be forced through the link/URL that generates the PDF:
Force to open "Save As..." popup open at text link click for PDF in HTML
I am having an erratic problem using Azure blob storage where my images do not load consistently. The problem is that sometimes when I load a web page, the browser will not show the image, but if I refresh it will load correctly.
When the image doesn't load, the browser shows the default image placeholder. Here is an example:
If I check the hyperlink for the image placeholder, I find that it is the same as the when the image loads successfully, except the Shared Access Signature is different.
Sometimes the same image will fail to load for one link but load successfully for another link even in the same page and same page load. The only difference in the URL is the Shared Access Signature.
Here is my code to build the URL with the shared signature
// Get reference to blob (file) that is to be downloaded
blob = blobContainer.GetBlobReference(blobURL.ToString());
// Get shared access signature to download file from azure blob (valid upto "active duration" minutes) from now
signature = blob.GetSharedAccessSignature(new SharedAccessPolicy()
{
SharedAccessStartTime = null,
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(60),
Permissions = SharedAccessPermissions.Read
});
// Append signature query string to blob / file that is to be downloaded
downloadURL = string.Format("{0}{1}", blob.Uri.AbsoluteUri, signature);
This is the final HTML image link on the web page, i.e. if I show source on the web page in the browser:
<img alt="Profile Picture" src="https://mystorageaccount2.blob.core.windows.net/abcdefg1-hi23-40b5-86de-a20b568f5626/1601/1234d664d1b74ce1aebf4403e5b74af7.jpg?se=2015-10-31T11%3A38%3A39Z&sr=b&sp=r&sig=SaiUToJg%5Ab3zcdef8EeOq84urHf6HQqS%2BAFt1dEQMNI%3D">
Has anyone else seen this problem? Any recommendations on what I might be doing wrong?
I suspect this could be related to the expiry period which you have set on your image blob's shared access signature (SAS). Is there any good reason where you need to set the SAS to 1 minute when you have set it's permission to read-only?
I want to add validation in filefield of ExtJs4 , so that user can only browse .png , .jpeg image files..How should I do it ?
{
xtype: 'filefield',
id:'photoUpload',
buttonOnly:true,
buttonText: 'Photo'
}
I think it is important to understand how file upload works, so to prevent yourself from troubles in the future...
For security reasons, the following applies:
Browsers cannot access the file system unless the user has explicitly clicked on an upload field.
Browser has minimal access to the file being uploaded, in particular - you JS code may be able to see the file name (the browser has to display it in the field), but nothing else (the path itself on most browsers is not the correct one).
The upload process itself happens in these steps:
The user clicks on an upload field, initiating the file select dialog.
The browser implements access to the file system through the dialog, allowing the user to select a file.
Upon OK click, the browser sends the file to the server.
The server places the file in its temp directory (configured per server).
Once upload is complete, the upload script on the server is called with the file details, and that script will have full access to the uploaded file.
The last step is the only point where you have full access to the file details, including the real actual name, its size, and its content.
Anything the browser gives javascript is browser depended. Even the file name will vary between browsers although all the browsers I know do keep the actual file name (but not the real actual path), you cannot rely on this to work with future versions. The reason for this is that the file name is displayed on the client side.
So the recommendation is this:
Do all file upload checks on the server side.
Again, you may get away with the file name on the JS client side, particularly if you know and can test what browsers your clients will use, but I'd strongly recommend to to this test on the server.
The last thing you have to remember is that users might upload a file ending with .png, but the file itself is a .zip with the extension changed - so to really confirm that the file is .png you need to actually look into the file data, which only the server can do.
{
xtype: 'filefield',
id:'photoUpload',
buttonOnly:true,
vtype:'fileUpload',
buttonText: 'Photo'
}
And Vtype which I have use..
Ext.apply(Ext.form.VTypes, {
fileUpload: function(val, field) {
var fileName = /^.*\.(gif|png|bmp|jpg|jpeg)$/i;
return fileName.test(val);
},
fileUploadText: 'Image must be in .gif,.png,.bmp,.jpg,.jpeg format'
});
Try following snippet in your 'filefield' xtype config
regex : (/.(gif|jpg|jpeg|png)$/i),
regexText : 'Only image files allowed for upload',
msgTarget : 'under'
I've set a ondrop event on my drop area and it receives an event when I drag an image from my desktop to the drop area.
However, according to the Recommended_Drag_Types document:
https://developer.mozilla.org/en/DragDrop/Recommended_Drag_Types
A local file is dragged using the application/x-moz-file type with a data value that is an nsIFile object. Non-privileged web pages are not able to retrieve or modify data of this type.
That makes sense, but how do I prompt the user to escalate privileges to get access to the file data and send it via an XMLHttpRequest?
If I try it without escalating privileges when I do this code:
event.dataTransfer.mozSetDataAt("application/x-moz-file", file, 0);
Javascript returns this error:
Permission denied for domain.com to create wrapper for object of class UnnamedClass
The only article I can find on this is one from 2005 but I can't tell if the directions still apply to Firefox 3, it suggest doing this:
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
which doesn't seem to work.
If you haven't upgraded to 3.5 yet, you can use the dragdropupload extension.
I found out that if instead of escalating privileges globally:
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
...
function doDrop(event) {
...
var file = event.dataTransfer.mozGetDataAt("application/x-moz-file", 0);
...
}
I escalate privileges in the function's body:
...
function doDrop(event) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
...
var file = event.dataTransfer.mozGetDataAt("application/x-moz-file", 0);
...
}
I get rid of the error you described and gain access to the nsIFile instance I was looking for.