Welcome Guest, Not a member yet? Register   Sign In
keeping user images in the assets/uploads dir - multiprocess question
#1

(This post was last modified: 07-16-2021, 01:31 PM by richb201.)

My system allows users to upload images. After each upload (to /assets/uploads) I also copy this file to my S3 bucket for this user. At the end of their system use and logoff, I delete all of the images in /assets/uploads since I have already copied their files to their s3 bucket. 
My system is multiuser. Does each user have their own copy of the CI environment on disk? I am asking if two users are sharing the same directory space in /asset/uploads. If that is so I really should NOT delete *.png from /assets/uploads? I do have the names of all of each users files in my table and could delete them one by one.  I guess I am confused since each php program (I think) is a separate process, unlike the way we used to program in multi threading in C where all the code was shared with the use of a state machine. In CI3 does each process have its own copy of the code on the hard drive?
proof that an old dog can learn new tricks
Reply
#2

(This post was last modified: 07-16-2021, 01:43 PM by craig.)

Quote:Does each user have their own copy of the CI environment on disk?

No.

Quote: I am asking if two users are sharing the same directory space in /asset/uploads

Yes, all users are - unless you code it otherwise.


CI and the file storage system has no concept of different or separate users of your application. As the developer, it is your responsibility to segregate the files in whatever way makes sense to you. All CI is doing is taking an uploaded file and placing it in a folder that you tell it to.

My suggestions would be to do one of the following:

1) Delete the file as soon as it's successfully uploaded to S3.

2) Track files in the database, with a field to mark whether it has successfully uploaded to S3 (For example: 0 by default, 1 on success). Then you can SELECT the files where S3=1, and delete them - either in a cron job function, or periodically from pages that users visit in your site.

3) Create a folder for each user's files.
Reply
#3

(This post was last modified: 07-16-2021, 03:10 PM by richb201.)

Thanks. I need to leave them on the local disk because otherwise koolreport can't access them Sad. I think that I will just run through my table and delete them one at a time. Thanks for clearing that up.

If the user logs off I can easily clean up their files. But if they x out of the tab, I have a deeper issue. Perhaps once a week I can take the system down and run a cron job to clear it out but it seems like a huge pita.
proof that an old dog can learn new tricks
Reply
#4

Assign each user their own image folder and only allow them to view it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 07-18-2021, 04:35 AM by richb201.)

Hi Insite. I would, except this has been designed to run on multiple servers. Why? The calculations take a significant amount of time to build the temporary tables and I am concerned about having multiple users running at the same time. Which leads me to another question, perfect for you,  since I think you had recommended using Create Temporary in mysql. Is the temporary table going to be deleted when the current user logs off? From mysql's POV, there is only one user, I think. How about if two users are logged in at the same time? Do they each get their own temporary table? I could make separate temp tables for each user.
proof that an old dog can learn new tricks
Reply
#6

It ends automatically when the session or the database is closed, you can also use drop table when your done with it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

Each user has a new session (I sure hope). So in that case if two users are on at the same time, and each has a temporary file of the same name? Should I assume that temp files are in memory, and not on the drive?
proof that an old dog can learn new tricks
Reply
#8

(This post was last modified: 07-19-2021, 02:21 AM by InsiteFX.)

You should assign a random number for wach temp table for each user.

Like say adding the date and time to the temp table, but I would create a random number generator for it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB