def sample_get_file_url(filename): user = api.current_user() if user: oid = api.oid_by_name(user, filename) if oid: return api.url_for(user, oid) return ''
def link_to_file(key, oid): user = api.user_by_key(key) if not user: abort(404) url = api.url_for(user, oid) if url: return url abort(404)
def sample_save_from_filesystem(filename): user = api.current_user() if user: try: fileHandle = api.File(filename) oid = api.save_file(user, fileHandle) return api.url_for(user, oid) except IOError: pass return ''