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
Create Route to Put Assets #23678
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
shared/middleware/files_api.rb
Outdated
@@ -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> |
There was a problem hiding this comment.
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.
shared/test/test_assets.rb
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional test ideas:
- 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.
- PUT to a second filename and verify the API can handle different files being uploaded (would catch accidentally hard-coded filename values, etc).
How are we moderating these new file types? |
@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. |
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!