web2py version 2.16.1 and this may be related to this 
bug: https://github.com/web2py/pydal/issues/502

I am trying to use S3 as my file repository for uploads. Here is my code 
and error I get:
*CODE*

from fs_s3 import S3FS
import datetime

bucket = "pobook",
region = 'ca-central-1',
aws_akey = "##############",
aws_skey = "########################"

myfs = S3FS(
            bucket,
            aws_access_key_id=aws_akey,
            aws_secret_access_key=aws_skey,
            region=region
            )

db.define_table('attachments',
                Field('name', 'string', requires=IS_NOT_EMPTY()),
                Field('files', 'upload', uploadfs = myfs, autodelete=True)
                )


*ERROR:*
Ticket ID

184.67.247.98.2018-06-07.00-48-22.78e916af-82ac-4c9e-8c9a-289ee71d06eb
<type 'exceptions.TypeError'> paths must be unicode (not str)Version
web2py™ Version 2.16.1-stable+timestamp.2017.11.14.05.54.25
Python Python 2.7.6: /usr/local/bin/uwsgi (prefix: /usr)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.

Traceback (most recent call last):
  File "/home/watr/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/home/watr/web2py/applications/dev/controllers/attachments.py" 
<https://www.pobook.ca/admin/edit/dev/controllers/attachments.py>, line 179, in 
<module>
  File "/home/watr/web2py/gluon/globals.py", line 419, in <lambda>
    self._caller = lambda f: f()
  File "/home/watr/web2py/gluon/tools.py", line 3982, in f
    return action(*a, **b)
  File "/home/watr/web2py/applications/dev/controllers/attachments.py" 
<https://www.pobook.ca/admin/edit/dev/controllers/attachments.py>, line 112, in 
add
    if form.process().accepted:
  File "/home/watr/web2py/gluon/html.py", line 2300, in process
    self.validate(**kwargs)
  File "/home/watr/web2py/gluon/html.py", line 2238, in validate
    if self.accepts(**kwargs):
  File "/home/watr/web2py/gluon/sqlhtml.py", line 1881, in accepts
    field.uploadfolder)
  File "/home/watr/web2py/gluon/packages/dal/pydal/objects.py", line 1728, in 
store
    dest_file = self.uploadfs.open(newfilename, 'wb')
  File "/home/watr/.local/lib/python2.7/site-packages/fs/base.py", line 1129, 
in open
    bin_file = self.openbin(path, mode=bin_mode, buffering=buffering)
  File "applications/dev/modules/fs_s3/_s3fs.py", line 545, in openbin
    _path = self.validatepath(path)
  File "/home/watr/.local/lib/python2.7/site-packages/fs/base.py", line 1445, 
in validatepath
    'paths must be str (not bytes)'
TypeError: paths must be unicode (not str)


*fs/base.py is erroring here:*


        if isinstance(path, bytes):
            raise TypeError(
                'paths must be unicode (not str)'
                if six.PY2 else
                'paths must be str (not bytes)'

            )

        meta = self.getmeta()


(self=S3FS(('#####',), region=('ca-central-1',)), 
path='attachments.files.ad112b05475e6e3e.4c61632045766...e7669746174696f6e2028456e676c697368292e706466.pdf')

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to