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

examples: fix deposit creation #171

Closed
wants to merge 1 commit into from

Conversation

hachreak
Copy link
Member

  • Registers invenio-files-rest endpoints on example app.

  • Fixes url for creating the deposit, avoiding the HTTP redirection.

  • Disables JWT check on example app.

  • Adds bucket link on response after deposit creation.

Signed-off-by: Leonardo Rossi leonardo.r@cern.ch

@hachreak hachreak self-assigned this Jul 10, 2017
@hachreak hachreak requested review from lnielsen and drjova July 10, 2017 09:09
return super(Deposit, cls).create(data, id_=id_)
deposit = super(Deposit, cls).create(data, id_=id_)
# FIXME create the bucket!
deposit.files.bucket
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☺️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know... I put the FIXME to point out the problem. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a suggestion for where to add it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in the FilesMixin?
The problem appeared when I tried to use the "vanilla" /deposit/new to create a new deposit.
These are the steps followed by the UI:

  1. Create the deposit with POST
  2. Read from the links the bucket endpoint
  3. Push the file to the bucket endpoint with PUT.

Without this "hack", the bucket is created when the deposit is serialized in JSON, i.e. after the session commit().
It means that the bucket doesn't exist anymore when the file is uploaded.

Maybe we should force the creation on deposit creation?
Something like:

class FilesMixin(object):
   def create(self, *args, **kwargs):
      self._create_bucket()
      super(FilesMixin, self).create(*args, **kwargs)

* Registers invenio-files-rest endpoints on example app.

* Fixes url for creating the deposit, avoiding the HTTP redirection.

* Disables JWT check on example app.

* Adds bucket link on response after deposit creation.

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
@lnielsen
Copy link
Member

Closing PR because it's been stale for a long time.

@lnielsen lnielsen closed this Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants