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

Create Route to Put Assets #23678

Merged
merged 5 commits into from Jul 16, 2018
Merged

Create Route to Put Assets #23678

merged 5 commits into from Jul 16, 2018

Conversation

epeach
Copy link

@epeach epeach commented Jul 12, 2018

Includes test.

This route is being added to handle audio that is recorded by the student in the browser and then sent to the assets in S3.

I went back and forth quite a bit deciding whether this route should be a 'put' or 'post' and would love input on whether using a 'put' makes sense in this situation.

Additionally, any feedback on additional tests I should include to ensure full coverage would be appreciated. Thanks!

@epeach epeach requested a review from islemaster July 12, 2018 23:53
Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Awesome!

@@ -374,11 +374,11 @@ def copy_file(endpoint, encrypted_channel_id, filename, source_filename)
end

#
# PUT /v3/sources/<channel-id>/<filename>?version=<version-id>
# PUT /v3/(sources|assets)/<channel-id>/<filename>?version=<version-id>
Copy link
Contributor

Choose a reason for hiding this comment

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

Passing a version parameter with to the assets API might not go well - I'd consider breaking this comment into two lines, so the assets case clearly doesn't support the version parameter, and also adding a unit test for trying to pass a version when uploading an asset. I think the ideal behavior would be to just ignore the parameter in that case.

response = @api.put_object(sound_filename, sound_body, {'CONTENT_TYPE' => 'json'})
actual_sound_info = JSON.parse(response)
expected_sound_info = {'filename' => sound_filename, 'category' => 'audio', 'size' => sound_body.length}
assert_fileinfo_equal(expected_sound_info, actual_sound_info)
Copy link
Contributor

Choose a reason for hiding this comment

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

Additional test ideas:

  1. PUT to the same filename again and verify that the object is replaced (rather than failing or making a second object), to show the appropriate idempotent behavior.
  2. PUT to a second filename and verify the API can handle different files being uploaded (would catch accidentally hard-coded filename values, etc).

@joshlory
Copy link
Contributor

How are we moderating these new file types?

@epeach
Copy link
Author

epeach commented Jul 13, 2018

@joshlory I'm not sure I understand what you are asking, can you explain what you mean? If you are asking about content moderation, then according to the spec, we are limiting audio recording to 1 minute in length as a means of moderation.

@epeach epeach merged commit 57dd054 into staging Jul 16, 2018
@epeach epeach deleted the record-audio-put-asset branch July 17, 2018 00:00
@epeach epeach mentioned this pull request Aug 2, 2018
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