mirror of
https://github.com/neocities/neocities.git
synced 2025-07-22 10:36:07 +02:00
api: add upload_hash for checking file hash before uploading
This commit is contained in:
parent
7d17202f39
commit
4a2926508e
3 changed files with 55 additions and 0 deletions
16
app/api.rb
16
app/api.rb
|
@ -5,6 +5,22 @@ get '/api' do
|
|||
erb :'api'
|
||||
end
|
||||
|
||||
post '/api/upload_hash' do
|
||||
require_api_credentials
|
||||
|
||||
res = {}
|
||||
|
||||
if params[:files].blank? || !params[:files].is_a?(Hash)
|
||||
api_error 400, 'no_file_hashes_provided', 'no file hashes provided'
|
||||
end
|
||||
|
||||
params[:files].each do |k,v|
|
||||
res[k] = current_site.sha1_hash_match? k, v
|
||||
end
|
||||
|
||||
api_success files: res
|
||||
end
|
||||
|
||||
get '/api/list' do
|
||||
require_api_credentials
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue