Problems updating a file url via api


I just wrote a script to migrate all files from a “files” column to seafile right before updating the url to the seafile-connector url. My goal is to store files on a remote seafile and don’t blow up the seatable storage.
When debugging it works as expected, except that the new url is not saved. When I call context.current_row before and after the base.update_row() I can see that everything is in place. It is just not working.

One thing to note is that I don’t want to use the script to store config like API tokens. On the first run the script creates a table where you can create the config. The script creates the table only if it does not exist already.
Other than that it uses only modules that are built into the python runner. It is running in the cloud environment as well, unfortunately with the same behaviour.

Maybe @daniel.pan has an idea?

This is the code: seatable-python-snippets/ at main · vquie/seatable-python-snippets · GitHub

Do you mean the URL like (seafile-connector://{seafile_library_api_token}/{seafile_upload_dir}/{item_name}) is already stored in the file column cell, but in the web interface, you can’t see the file?

If so, maybe you have a wrong data format for the cell.

When I update the main() function to print some more output like this:

def main():
    # Get the current row data from SeaTable
    row = context.current_row
    print(context.current_row)             # output 1
    if not row:
        raise ValueError("Row not found")


    # Update the row in SeaTable with the new URLs
    if updated_row_data:
        response = base.update_row(table_name, row["_id"], updated_row_data)
        print(response)                     # output 2
        print(context.current_row)          # output 3
        raise ValueError("No 'file' columns found in the row")

This is what I get:

{'_id': 'RW7fJ-GCQlG4nYebc5dESQ', '_mtime': '2023-05-05T06:44:54.725+00:00', '_ctime': '2023-05-05T06:43:06.232+00:00', 'Name': 'test', 'Files 1': [{'name': 'Bildschirmfoto 2023-05-05 um 08.43.12.png', 'size': 4521, 'type': 'file', 'url': ''}]}
{'success': True}
{'_id': 'RW7fJ-GCQlG4nYebc5dESQ', '_mtime': '2023-05-05T06:44:54.725+00:00', '_ctime': '2023-05-05T06:43:06.232+00:00', 'Name': 'test', 'Files 1': [{'name': 'Bildschirmfoto 2023-05-05 um 08.43.12.png', 'size': 4521, 'type': 'file', 'url': 'seafile-connector://seafile-library-token/.seatable_uploads/2023/05/05/Bildschirmfoto 2023-05-05 um 08.43.12.png'}]}

In the beginning context.current_row is exactly what it is supposed to be and has the local file.
After updating it with base.update_row() the API returns {'success': True} and the new context.current_row has the new content. But these three outputs are the same everytime I run this. The row is never actually updated.

I also tried base.append_row() to create a new row, but that row is created with an empty cell. My assumtion is, that you don’t allow setting a “seafile-connecter” url via API.

context.current_row always has the same content when your script begin. If you want to fetch the new content, you should call base.get_row() with row id.

base.update_row() updated the content on the server directly. Your local copy context.current_row is not updated.

Thats exactly the opposite of what is happening.