Remote File Upload Api

23 views
Skip to first unread message

cj

unread,
Apr 10, 2008, 7:22:20 PM4/10/08
to web2py Web Framework
Hey,

I have a desktop application that needs to send multiple files to my
server and obviously I don't want it to have direct access to the
server. So I'm trying to think of the best way of building an api in
web2py. Has anyone else done this before ?

Many thanks,

CJ

Massimo Di Pierro

unread,
Apr 10, 2008, 10:12:40 PM4/10/08
to web...@googlegroups.com
do have only one desktop app or many apps?

cj

unread,
Apr 10, 2008, 11:02:13 PM4/10/08
to web2py Web Framework
There are many desktop apps, each user has one.

Massimo Di Pierro

unread,
Apr 10, 2008, 11:28:01 PM4/10/08
to web...@googlegroups.com
You can run any service you want using the web2py -R option. The
question is how to secure the communication and authenticate the users.
Since the point of your question is not to use https, I do not know.
There are too many variables. If you app includes openssl I would use
tunnels, certificates and xmp-rpc over the tunnel.

Massimo

cj

unread,
Apr 11, 2008, 12:02:15 AM4/11/08
to web2py Web Framework
What i was meaning in my first post is I don't want to give the
desktop app ftp details to the server. I was thinking xml-rpc....I
don't mind doing it as a post using https, but It's going to be
multiple uploads.
Message has been deleted

Michael Wills

unread,
Apr 16, 2008, 12:34:16 PM4/16/08
to web...@googlegroups.com
Just note that Chilkat seems to only run on Windows. chilkat.py imports _chilkat which is a .pyd file which apparently only works on Windows.

On Thu, Apr 10, 2008 at 9:08 PM, cj <cjla...@googlemail.com> wrote:

I did find something interesting http://www.example-code.com/python/upload_asynchHttps.asp
/ http://chilkatsoft.com/

cj

unread,
Apr 16, 2008, 12:58:58 PM4/16/08
to web2py Web Framework
Hi Michael,

I noticed that, I found http://blog.vixiom.com/2006/09/08/multiple-file-upload-with-flash-and-ruby-on-rails/
which is perfect, just trying to convert the RoR bit into web2py.

On Apr 16, 9:34 am, "Michael Wills" <mcwi...@gmail.com> wrote:
> Just note that Chilkat seems to only run on Windows. chilkat.py imports
> _chilkat which is a .pyd file which apparently only works on
> Windows<http://www.python.org/doc/2.4.4/dist/python-terms.html>
> .
>
> On Thu, Apr 10, 2008 at 9:08 PM, cj <cjlaz...@googlemail.com> wrote:
>
> > I did find something interesting
> >http://www.example-code.com/python/upload_asynchHttps.asp
> > /http://chilkatsoft.com/

Massimo Di Pierro

unread,
Apr 16, 2008, 1:12:53 PM4/16/08
to web...@googlegroups.com
Hi CJ,

the ruby code from the web page below

class DataFile < ActiveRecord::Base
  def self.save(data, name, directory)
    # create the file path
    path = File.join(directory, name)
    # write the file
    File.open(path,‘wb’) do |file|
      file.puts data.read
    end
  end
end
class UploadController < ApplicationController
  def index
    # capture incoming file params from flash
    data = params[:Filedata]
    name = params[:Filename]
    # the directory in which to save the file
    directory = ‘public/uploads’
    # save the file
    @data_file = DataFile.save(data, name, directory)
    # there’s no view so render nothing
    render :nothing => true
  end
end

is already in web2py. So if you just have to do something like

     db.define_table('DataFile',SQLField('Filename'),SQLField('Filedata','upload'))
     def index(): return SQLFORM(db.DataFile).accepts(request.vars,formname=None)

you get exactly the same functionality as the above ruby code + definition of the table + built-in security (the ruby code above is very insecure)!

Massimo

Michael Wills

unread,
Apr 16, 2008, 1:42:10 PM4/16/08
to web...@googlegroups.com
I am looking forward to developing with web2py again soon! :-)
Reply all
Reply to author
Forward
0 new messages