Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot attach files to an updated record #3989

Open
lallulli opened this issue Jan 16, 2020 · 2 comments
Open

Cannot attach files to an updated record #3989

lallulli opened this issue Jan 16, 2020 · 2 comments
Assignees

Comments

@lallulli
Copy link
Contributor

lallulli commented Jan 16, 2020

I'm using Invenio 3.2. I create a new record using the REST API, POST method:

POST https://127.0.0.1:5000/api/records/

Say the new record gets id 1. Now I can attach files to the new record:

PUT https://127.0.0.1:5000/api/records/1/files/my_file.txt

The new file gets attached correctly. Later, I update my record using the PUT method:

PUT https://127.0.0.1:5000/api/records/1

Update is successful, but attached files disappear. If I try again to attach a file, I get a 404 error:

PUT https://127.0.0.1:5000/api/records/1/files/my_file_2.txt
{'message': 'The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.', 'status': 404}
@topless topless self-assigned this May 7, 2020
@topless
Copy link
Member

topless commented May 14, 2020

This is because the record is getting cleared in the PUT endpoint

So the record with a file from this form

{
    "$schema": "https://my-site.com/schemas/records/record-v1.0.0.json",
    "id": "11",
    "title": "Sponge",
    "contributors": [{"name": "Bob"}],
    "_bucket": "dc6a4c08-0a18-48e8-90d1-3a4a3cb0958c",
    "_files": [
        {
            "key": "file.txt",
            "size": 13,
            "bucket": "dc6a4c08-0a18-48e8-90d1-3a4a3cb0958c",
            "file_id": "75f4058c-0347-427e-a398-6b62aa3e602f",
            "checksum": "md5:59ca0efa9f5633cb0371bbc0355478d8",
            "version_id": "7602c2ff-f318-48d4-8f55-b278ebfeb051"
        }
    ]
}

when we update our record with a new payload it becomes

{
    "$schema": "https://my-site.com/schemas/records/record-v1.0.0.json",
    "id": "11",
    "title": "Updated",
    "contributors": [{"name": "Name"}]
}

@ppanero
Copy link
Member

ppanero commented May 14, 2020

update: This will get fixed with the new core modules flask-resources and invenio-resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants