Skip to content

Commit

Permalink
build filenames for non-database upload fields (#695)
Browse files Browse the repository at this point in the history
Field names aren't built correctly for upload fields if they aren't tied to a database field.  This builds the field name.
  • Loading branch information
jpsteil authored Aug 3, 2022
1 parent 1c16b7b commit 6899de6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pydal/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2069,10 +2069,10 @@ def store(self, file, filename=None, path=None):
filename = os.path.basename(filename.replace("/", os.sep).replace("\\", os.sep))
m = re.search(REGEX_UPLOAD_EXTENSION, filename)
extension = m and m.group(1) or "txt"
uuid_key = self._db.uuid().replace("-", "")[-16:]
uuid_key = self._db.uuid().replace("-", "")[-16:] if self._db else uuidstr()
encoded_filename = to_native(base64.urlsafe_b64encode(to_bytes(filename)))
newfilename = "%s.%s.%s.%s" % (
self._tablename,
self._tablename if '_tablename' in self.__dir__() and self._tablename else 'no_table',
self.name,
uuid_key,
encoded_filename,
Expand Down

0 comments on commit 6899de6

Please sign in to comment.