Technical Question -->

IEI

Administrator
Staff member
Nov 10, 2002
14,505
3,340
#1
I don't have any experiment in internet-related technology and would appreciate if anyone could give me some guideline on how to do this.

Let's say I have software that compresses the image in C/C++. I want the user to enter the uncompressed data from his/her browser and see the result as a link on the web-browser after processing. I also want to save the result on a database so
someone can use it later on.

Something like
http://www.ps2pdf.com/convert.htm
user can put the ps file there and download the pdf file after conversion.

In order to do this, I guess I need MySql/Apache and I guess this is server-side scripting. So how would I call the application on the server? PHP / Perl ?
and how would the result be saved in a database ?

Thanks in advance
 

Javeed

National Team Player
Nov 12, 2002
4,060
0
#2
I cannot answer your question fully. For one thing, I don't know how to send a file from the client machine to the server to be compressed.

You don't need database unless if you want is to deliver the file. You need a program, in the OS of the server, that takes to argument. One is uncompressed file and one is the compressed file. Then you need an exec in your PHP. Something like

<?php
exec("myProgram uncompessedFile compressedFile");
?>

The path of compressed file is a virtual direcotry. The name you can generate randomly. You need something to clean the both file after a while or when the use leaves the page.

I know this is not much help but it can be a starting point.
 

Arian

Elite Member
Oct 28, 2004
9,621
2
Seattle
#3
perl and apache would do the job for you.
Perl can be used for compressing, executing jobs, and file manupilation.. and apache is your web-server :)

If you have users with accounts, and private files associated with users, then you need a datbaase (MySQL is free and good enough)
 

IEI

Administrator
Staff member
Nov 10, 2002
14,505
3,340
#4
perl and apache would do the job for you.
Perl can be used for compressing, executing jobs, and file manupilation.. and apache is your web-server :)

If you have users with accounts, and private files associated with users, then you need a datbaase (MySQL is free and good enough)
Thanks a lot Arian (my inter friend :)) and Javeed -->
I want the result of the C code to be saved on the database so that later on someone can do query on the results. So could I add a folder so that MySQL updates itself anytime there is a file added to that folder /?
 

Arian

Elite Member
Oct 28, 2004
9,621
2
Seattle
#5
why would u put code inside the database. That's dangerous.

what I suggest is, you put the path to the file that contains the code into the db.

once you use perl to generate the file and save it on disk, then using perl you insert the link of the file just generated into the db
 

ChaharMahal

Elite Member
Oct 18, 2002
16,563
261
#6
Thanks a lot Arian (my inter friend :)) and Javeed -->
I want the result of the C code to be saved on the database so that later on someone can do query on the results. So could I add a folder so that MySQL updates itself anytime there is a file added to that folder /?

here is two ways to do it?
databases like sqlserver,oracle and postgres have a concept of a job. you can create a job that goes and look in such and such directories if it finds certains files with certain patterns then it would pick it up and insert in a blob directory.

by the way i would really discourage you from putting large amounts of bianry data in a database from self experience. it helps you in certain aspects because when you move the database file all the data moves. but it introduces a problem and that is the fact that the database grows up really crazy and transporting that datafile it's backups become really expensive.

Most people save the file some where that is accessible via a unc path and then put the path in the database.


The other thing you could do is on your system:
whether it is windows or linux you can set up scheulded job (so say every thirty second?)
run a script or a program you have written that geos and look in a directory to see if any files are there if yes then it would pick them up and insert them in the database. VB scripts would be really good for this.


I would remind you of one thing. just because a file apears it doesnt mean that the program is done with it (it doest mean it has flusehd all the data into it and closed it). so i recommend that you check for example to see that the file has not been modified say in last 30 seconds. in that case it is safe to say that the program is done with it.
 

IEI

Administrator
Staff member
Nov 10, 2002
14,505
3,340
#7
here is two ways to do it?
databases like sqlserver,oracle and postgres have a concept of a job. you can create a job that goes and look in such and such directories if it finds certains files with certain patterns then it would pick it up and insert in a blob directory.

by the way i would really discourage you from putting large amounts of bianry data in a database from self experience. it helps you in certain aspects because when you move the database file all the data moves. but it introduces a problem and that is the fact that the database grows up really crazy and transporting that datafile it's backups become really expensive.

Most people save the file some where that is accessible via a unc path and then put the path in the database.


The other thing you could do is on your system:
whether it is windows or linux you can set up scheulded job (so say every thirty second?)
run a script or a program you have written that geos and look in a directory to see if any files are there if yes then it would pick them up and insert them in the database. VB scripts would be really good for this.


I would remind you of one thing. just because a file apears it doesnt mean that the program is done with it (it doest mean it has flusehd all the data into it and closed it). so i recommend that you check for example to see that the file has not been modified say in last 30 seconds. in that case it is safe to say that the program is done with it.
Thanks a lot ... (Everyone) -- I really appreciate your help
Is there any way to inform the database that the processing is done ?
like sending a signal or something (under linux)
 

Arian

Elite Member
Oct 28, 2004
9,621
2
Seattle
#8
esamani.. since this is a small web app... there is no need to create cron jobs.
again, Perl is your best bet... once your Perl application is done with the file flushing, the next step in your program could be an insert statement into the DB (with the file's location).

I think esamani's approach is way too complicated for a small web app with a simple task of keeping track of created files. On the other hand, as mentioned in my previous post, I agree with esamani on the fact that you shouldn't have BLOBs (or large data) in your db, and that's why I recommended keeping track of a link to the file, rather than the binary data itself.
 

IEI

Administrator
Staff member
Nov 10, 2002
14,505
3,340
#9
esamani.. since this is a small web app... there is no need to create cron jobs.
again, Perl is your best bet... once your Perl application is done with the file flushing, the next step in your program could be an insert statement into the DB (with the file's location).

I think esamani's approach is way too complicated for a small web app with a simple task of keeping track of created files. On the other hand, as mentioned in my previous post, I agree with esamani on the fact that you shouldn't have BLOBs (or large data) in your db, and that's why I recommended keeping track of a link to the file, rather than the binary data itself.
I was looking on the web and there is something called MySQL++ which I can use
to access MySQL from C/C++. So could the perl script run the my c-code and
after the output file is created, the C code will automatically connect to database and
put a link there ?
http://tangentsoft.net/mysql++/
 

ChaharMahal

Elite Member
Oct 18, 2002
16,563
261
#10
arian jan I dont understand how you can avoid the complexity by using any kind of perl or other scripting language?

He has a c++ program that is gone spit out a file when given another file as input. something (a program, a periodical script task) needs to sit and poll for this c++ program to get done.

now idealy the c++ program would do all this dirty work itself. but i assume that he does not like modifying his existing program.
 

ChaharMahal

Elite Member
Oct 18, 2002
16,563
261
#11
I was looking on the web and there is something called MySQL++ which I can use
to access MySQL from C/C++. So could the perl script run the my c-code and
after the output file is created, the C code will automatically connect to database and
put a link there ?
http://tangentsoft.net/mysql++/

aziz again the easiest way is to do polling (god i hate polling)

your webcode (what ever it is ) posts a task it expects the resuts to show up in the database.

so i guess the best way is for your webserver to then start polling the DB once in a while to see if that file that it posted for processing has been processed.

if yes then it can send an email to the user with a link or what ever else is it that it needs to do.


by the way by signal files i dont what you mean? if you mean an operating system event ? nope only advance database like oracle and sqlserver would have features that lets you put code in them to signal others.

if you mean from singal thsoe crappy sginal fiels to stop or start services in linux. well no the database is not gone automatically do anything for you. all the database does is it hides the compleixy of storing the data for you. it is then your job to and write scripts in the database to make it do things.
 

ChaharMahal

Elite Member
Oct 18, 2002
16,563
261
#12
esamani.. since this is a small web app... there is no need to create cron jobs.
again, Perl is your best bet... once your Perl application is done with the file flushing, the next step in your program could be an insert statement into the DB (with the file's location).

I think esamani's approach is way too complicated for a small web app with a simple task of keeping track of created files. On the other hand, as mentioned in my previous post, I agree with esamani on the fact that you shouldn't have BLOBs (or large data) in your db, and that's why I recommended keeping track of a link to the file, rather than the binary data itself.

never mind my last post. arian jan. i understood what you are saying now.

I was thinkg of the operation as sort of asyncronous. you start the task and worry about the task when it is done. you are saying have this script file that lanuches the program and watis for the program to spit out data.

yes that would complety work if there is not a huge on the machine.
 

IEI

Administrator
Staff member
Nov 10, 2002
14,505
3,340
#13
aziz again the easiest way is to do polling (god i hate polling)

your webcode (what ever it is ) posts a task it expects the resuts to show up in the database.

so i guess the best way is for your webserver to then start polling the DB once in a while to see if that file that it posted for processing has been processed.

if yes then it can send an email to the user with a link or what ever else is it that it needs to do.


by the way by signal files i dont what you mean? if you mean an operating system event ? nope only advance database like oracle and sqlserver would have features that lets you put code in them to signal others.

if you mean from singal thsoe crappy sginal fiels to stop or start services in linux. well no the database is not gone automatically do anything for you. all the database does is it hides the compleixy of storing the data for you. it is then your job to and write scripts in the database to make it do things.
I meant OS event (like linux signal to another process)
 

Arian

Elite Member
Oct 28, 2004
9,621
2
Seattle
#14
yep.. so a sample scenario would be:

- user uploads data
- perl script kicks in, executes the c++ code on the uploaded date
- perl script flushes the result into a file on disk
- perl script inserts a record for the flushed file's location into the db
- returns success to user
 

IEI

Administrator
Staff member
Nov 10, 2002
14,505
3,340
#15
yep.. so a sample scenario would be:

- user uploads data
- perl script kicks in, executes the c++ code on the uploaded date
- perl script flushes the result into a file on disk
- perl script inserts a record for the flushed file's location into the db
- returns success to user
Thanks immensely --> Now time for doing this :)