That only sets the default behavior. Only on systems that do not have a 
writable filesystem (like on GAE and couchdb) files go in blob by default.

On relational databases, uploads are stored in files, not in blobs (by 
default).



On Friday, 6 July 2012 16:22:36 UTC-5, RCTYCO wrote:
>
> I believe i found my problem. The problem is with MySQL. I noticed in the 
> MySQL._db._adapter.uploads_in_blob = FALSE.
>
> The database adapter doesn't allow uploads_in_blob. MySQLAdapter* *inherents 
> the uploads_in_blob of FALSE from BaseAdapter. 
> Do you know why the uploads_in_blob isn't set to true?
>
>
>
> On Friday, July 6, 2012 12:27:41 PM UTC-7, Massimo Di Pierro wrote:
>>
>> Notice that these two lines:
>>
>> Field('image_file','blob'),
>> Field('image_upload','upload',uploadfield= Field('image_file','blob'))
>>
>> should be
>>
>> Field('image_file','blob'),
>> Field('image_upload','upload',uploadfield= 'image_file'),
>>
>> or simply
>>
>> Field('image_upload','upload',uploadfield= Field('image_file','blob')) 
>>
>> The blob should be created automatically.
>>
>>
>> On Thursday, 5 July 2012 06:23:31 UTC-5, RCTYCO wrote:
>>>
>>>
>>> I am trying to save an image from another database into my 
>>> database, essentially i am caching the a copy into my database so I don't 
>>> have to query the external site. 
>>>
>>> I have a link 
>>> http://eandata.com/image/products/004/900/000/0049000000443.jpg. 
>>>
>>> I want to save the jpg into a blob in my database.
>>>
>>> Model
>>> db.define_table('image',
>>>                 Field('url','string'),
>>>                 Field('image_upload','upload',uploadfield='image_file'),
>>>                 Field('image_file','blob'))
>>>
>>> Function. I have this running a module and called when I need to 
>>> download the external image.
>>>
>>> def getImage(url,db): 
>>>     
>>>     user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
>>>     headers = {'User-Agent': user_agent}
>>>     
>>>     req = urllib2.Request(url,"",headers)
>>>     
>>>     try:
>>>         response = urllib2.urlopen(req)
>>>     except urllib2.URLError, e:
>>>         if hasattr(e, 'reason'):
>>>             print 'We failed to reach a server.'
>>>             print 'Reason: ', e.reason
>>>         elif hasattr(e, 'code'):
>>>             print 'The server couldn\'t fulfill the request.'
>>>             print 'Error code: ', e.code
>>>     else:
>>>         pass # everything is fine
>>>     
>>>     print response.geturl()
>>>     print response.info()
>>>     print response.read()
>>>     f = open(response.read(),'rb')
>>>     #stream = open(response,'rb')
>>>     
>>>     return 
>>> db.image.insert(url=url,image=db.image.image_upload.store(f,url))
>>>
>>>
>>> *I am having a problem with my insert statement. I can't seem to figure 
>>> out how to save the image into database.* urllib2.urlopen(req) will 
>>> download the file and provide a file object. But I don't know if i can just 
>>> save the file or do i need to read the file object within 
>>> the urllib2.urlopen(req).
>>>
>>> I would like the image to be available to be via 
>>> http://mydomain.com/myapp/imageLookup?id=2 
>>> <http://mydomain.com/myapp/imageLookup?id=2>
>>>
>>> Controller
>>> def imageLookup():
>>>     id = request.vars.id
>>>     #response.headers['Content-Type']='image/jpeg' 
>>>     
>>>     return db.image[id].image_file
>>>
>>>
>>> Do you have any suggestions? The code abo
>>>
>>

Reply via email to