API : specify filename when uploading a file

Hi,

When uploading a file using the upload-file API, can you specifiy the original name of the file ?
Something similar to this (see the original_name part I added):

requests.post(
        url = "http://vision.axe.lan:3001/api/user-files/upload-file/",
        headers = {"Authorization": f"Token {token}"},
        files =  {'file': data, 'original_name': 'toto.jpg'}
)

I’m asking because, the file I’m trying to upload comes from a portal in base64 format. I’m just trying to transfer it to baserow without having to save it localy. Just passing the binary data…

Hi,

You cannot specify the original file name, but if you pass a file through the API with the following code, the response should be a json object containing the original file name as one of its properties.

# Upload the file to the baserow instance
file_url = 'http://vision.axe.lan:3001/api/user-files/upload-file/'  
# Select the file
csv_file_path = 'demo.csv'  

# Prepare the file for multipart upload
with open(csv_file_path, 'rb') as file:
    file_response = requests.post(file_url, headers=auth_header, files={'file': ('demo.csv', file, 'text/csv')})

# Store the uploaded file name
original_filename = file_response.json().get('original_name')
print(original_filename)