| Reply | « Previous Thread | Next Thread » |
|
Dear All
I have tried the mobilenin code for uploading an image to URL as per his example .It works great while uploading to image to mobilenin site. but when i tried to upload on my site it gives some forbidden 403 and sometime some eror 503. when i checked to error log on server it showed no such directory(actually directories are there which i have written in my python code) and the second error is of gnuncompress(): error...what is this? can anyone help me. ![]() ||Kiran || Nokia E-65 Nokia 7610 Nokia N95 8GB Nokia E90 Nokia 5110 !! Nokia 6110i !! |
|
Hi
Quote:
Quote:
LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
Dear LFD
thanks for your quick reply. i have added required MIME types for gzip and ya i have created same path and directories like beijing, php, etc on my server too..i what to do yaar? kiran ||Kiran || Nokia E-65 Nokia 7610 Nokia N95 8GB Nokia E90 Nokia 5110 !! Nokia 6110i !! |
|
Dear all,
When I enter the Images Directory, I got the following error: IOError:[Error13] Permission denied: 'e:/Images' Anyone? Thx. |
| elbarto Simpsons |
| View Public Profile |
| Find all posts by elbarto Simpsons |
|
Hi elbarto Simpsons and welcome to the forum
Quote:
LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
Hi folks,
Since it is not the first time one ask for help with image upload I made a python and server script for you. So far it has worked everywhere I tried it. My method is different than Jurgen's. I use base64 encoding instead of zlib. You can find it at http://students.oamk.fi/~dlefevre/th...d-image-to-url B.R LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
Dear LFD
Thanks a million for your kind and instant support. I wish you next Forum Nokia champion form this stage .....You are great man! I am really happy to have a person like you in the forum... Thanks again ...it really works on any server... Kiran ||Kiran || Nokia E-65 Nokia 7610 Nokia N95 8GB Nokia E90 Nokia 5110 !! Nokia 6110i !! |
|
Quote:
e:/ or e:\\ got the same error .. Any clue ![]() I am new to deal with 'path' in such... ![]() |
| elbarto Simpsons |
| View Public Profile |
| Find all posts by elbarto Simpsons |
|
Quote:
![]() base64, zlib compression, u bet. N73 - 1st Symbian OS X user |
| elbarto Simpsons |
| View Public Profile |
| Find all posts by elbarto Simpsons |
|
Quote:
It work fine with a picture size under 100k, but it does not work with picture with the size over 500K, any idea? ![]() N73 - 1st Symbian OS X user |
| elbarto Simpsons |
| View Public Profile |
| Find all posts by elbarto Simpsons |
|
Hi elbarto Simpsons,
You might have limitations on your server. Running the same script on my desktop machine I managed to upload a 5Mb mp3 file to my server. I have don't a S60 phone with me tonight to confirm but it should be the same since it's only Python. LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
Quote:
Same method in 6630 fails if POST size is 30 kB. Here is the function (simplified version): Code:
def _send_request(self, operation, params):
"""
Send HTTP-request to the server using httplib.
"""
params['rpc_op'] = operation
params = urllib.urlencode(params)
headers = {"Content-type": "application/x-www-form-urlencoded",
"User-Agent": self.ua,
}
conn = httplib.HTTPConnection(self.host)
conn.request("POST", self.script, params, headers)
response = conn.getresponse()
data = response.read()
conn.close()
return data
|
|
Quote:
I got the code (below) from uploadr, but that author cites it originally coming from here: http://www.voidspace.org.uk/atlantib...thonutils.html. I can't find where specifically on this site it came from, but there's a lot of modules. I'll just post the two functions below and if there's more questions about them, I can provide some more code or poke about on that voidspace site some more. Code:
def build_request(self, theurl, fields, files, txheaders=None):
"""
Given the fields to set and the files to encode it returns a fully formed urllib2.Request object.
You can optionally pass in additional headers to encode into the opject. (Content-type and Content-length will be overridden if they are set).
fields is a sequence of (name, value) elements for regular form fields - or a dictionary.
files is a sequence of (name, filename, value) elements for data to be uploaded as files.
"""
content_type, body = self.encode_multipart_formdata(fields, files)
if not txheaders: txheaders = {}
txheaders['Content-type'] = content_type
txheaders['Content-length'] = str(len(body))
return urllib2.Request(theurl, body, txheaders)
def encode_multipart_formdata(self,fields, files, BOUNDARY = '-----192.168.1.110.501.356.1163842081.537.1-----'):
""" Encodes fields and files for uploading.
fields is a sequence of (name, value) elements for regular form fields - or a dictionary.
files is a sequence of (name, filename, value) elements for data to be uploaded as files.
Return (content_type, body) ready for urllib2.Request instance
You can optionally pass in a boundary string to use or we'll let mimetools provide one.
"""
CRLF = '\r\n'
L = []
if isinstance(fields, dict):
fields = fields.items()
for (key, value) in fields:
L.append('--' + BOUNDARY)
L.append('Content-Disposition: form-data; name="%s"' % key)
L.append('')
L.append(value)
for (key, filename, value) in files:
filetype = 'application/octet-stream'
L.append('--' + BOUNDARY)
L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, filename))
L.append('Content-Type: %s' % filetype)
L.append('')
L.append(value)
L.append('--' + BOUNDARY + '--')
L.append('')
body = CRLF.join(L)
content_type = 'multipart/form-data; boundary=%s' % BOUNDARY # XXX what if no files are encoded
return content_type, body
|
|
Quote:
But in my example where Content-type: application/x-www-form-urlencoded and params = urllib.urlencode(params) request fails if the the size of params (in bytes) exceeds about 20-30kB. Here is the end of the traceback. AssertionError? Code:
result, rinfo = self._send_request(self.rpc_name(), params) File "C:\System\Apps\PlokIn\Comm.py", line 136, in _send_request data = response.read() File "E:\system\libs\httplib.py", line 238, in read s = self.fp.read() File "E:\system\libs\httplib.py", line 794, in read assert not self._line_consumed and self._line_left AssertionError |
|
Hi fellows,
It just came to my mind that I actually used already multipart/form-data upload with a different project. I found a library HTTPFileUploader long time ago and I'm sorry that I can't tell you who wrote it. So here comes a good library to add in your tool box. Download it HTTPFileUploader.txt and rename HTTPFileUploader.txt to HTTPFileUploader.py. Then simply push it on your phone and install it as a library (2nd edition) or create an installation package with ensymble to simplify the task (3rd edition) ![]() Usage: Code:
import os
from HTTPFileUploader import * # uploader class
# path of the file to download
filePath = "001.jpg"
# new HTTPFileUploader instance
uploader = HTTPFileUploader('yourServer.xxx', port = 80) # port optional if 80
# set page
uploader.setPage('/uploaderFolder/file_uploader.php')
# Add fields in HTTP: ex file name for or past example
uploader.setField("fileName", os.path.split(filePath)[1])
# upload file - returns True or False.
if not uploader.uploadFile(filePath, "picture"):
print uploader.getResult()
PHP Code:
LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Opening a JPEG Image | ummarbhutta | Mobile Java Media (Graphics & Sounds) | 8 | 2007-02-15 07:34 |
| how to cut some part of Image | mshouab | Mobile Java Media (Graphics & Sounds) | 2 | 2006-08-04 10:05 |
| HELP: Mutable Image to Immutable Image? | rj_cybersilver | Mobile Java Media (Graphics & Sounds) | 1 | 2005-03-26 10:58 |
| Upload Image Problem!!! | ckeddie | General Browsing | 4 | 2005-01-26 07:58 |
| Nokia Image Converter | davidpurdie | General Discussion | 0 | 2004-02-18 16:31 |