Ossn_data - some assistance please?

Kevin B Posted in Component Development 4 years ago

Hi all,

~Z~ has recommended I use the ossn_data folder for uploaded images / thumbnails - which I totally agree with! I am struggling a little bit to find an example of using the ossn_data folder to store files though? I tried searching my whole installation for 'ossn_data' but nothing useful came up.

I think I need to set the file path for the images something like - ossn_data_path("images/users") (i'm guessing the function name - so I know its wrong)

And then there needs to be a view registered for ossn_data/images to wwwroot/images so that they can still be served to the end client.

Am I on the right tracks?

Thanks again for all the help guys :)

Replies
Catalan Fouad Moussaoui Replied 4 years ago

@Arsalan Shah I did ! and it works ! Thank you champion !!!

Catalan Fouad Moussaoui Replied 4 years ago

Hi everyone , I have this message (A system error has occurred. Please try again later. You may email the details of this error to the system administrator at myeamail.com) .. I m traying to fill in my ossn page installation .. and the result is the same error message .. Any suggestion please ? Thanks

gb Kevin B Replied 4 years ago

Yes the filenames are randomly generated and I'll check the logged in user is a member of the respective group before streaming the image, or just send a 404 error. :)

Indonesian Arsalan Shah Replied 4 years ago

You need to make sure these image file names are random / encrypted so know one can guess maybe adding a message ID to image so you know if image is public or not before outputting to browser.

gb Kevin B Replied 4 years ago

Oooh, ok I like that. So rather than letting them have the image files, we are actually just providing the image as a stream. Very nice.

So that page handler bit, I register a page in ossn_com.php (something like "images") and then just use a parameter (like www.website.com/images?src=12345.png ) which I could then check if the photo is public, or whether you are friends etc before starting the stream?

And the code you provided at the bottom is the PHP referenced in the register page section - and is where I do all the auth?

I think I got it. :D

Thats very helpful, thank you Arsalan. :)

Indonesian Arsalan Shah Replied 4 years ago

You need to create a custom folder in data path, example

<?php
..
..
$data = ossn_data_path("com_webchat/images/");
 if(!is_dir($data)){
     mkdir($data....
 }

Then you need to know which file you wanted to get and make sure user can not get any file he wants other then his own file.

Then using a page hander example webchat_image_loader

<?php
   $file = input('name')...
  $data = ossn_data_path("com_webchat/images/");
  if(is file .... then
       use php code to load image file and server as format example jpg
  end if;

You can not use views to load files from data folder.