/api/delete

This commit is contained in:
Kyle Drake 2014-04-11 14:17:27 -07:00
parent 2c2ef2d015
commit 7cd7973144
2 changed files with 29 additions and 8 deletions

View file

@ -44,6 +44,11 @@ describe 'api delete' do
@site.store_file 't$st.jpg', Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
post '/api/delete', filenames: ['t$st.jpg']
res[:error_type].must_equal 'bad_filename'
create_site
basic_authorize @user, @pass
post '/api/delete', filenames: ['./config.yml']
res[:error_type].must_equal 'bad_filename'
end
it 'fails with missing files' do
@ -67,7 +72,6 @@ describe 'api delete' do
end
describe 'api upload' do
it 'fails with no auth' do
post '/api/upload'
res[:result].must_equal 'error'

View file

@ -63,4 +63,21 @@ api.uploadFile('newfile.html', './local.html', function(resp) {
console.log(resp)
})
</pre>
<h3>POST /api/delete</h3>
<p>
Deletes files from your site. Provide a <strong>filenames</strong> argument with an array of filenames you wish to delete. You can delete any files except index.html.
</p>
<p>
<strong>Be careful with this API call.</strong> There is no way to undo a delete!
</p>
<h4>Examples</h4>
<h6>Using cURL</h6>
<p>
Delete <strong>img1.jpg</strong> and <strong>img2.jpg</strong> from your site:
</p>
<code>
curl -d "filenames[]=img1.jpg" -d "filenames[]=img2.jpg" \<br> https://YOURUSER:YOURPASS@neocities.org/api/delete
</code>
</div> <!-- end .content -->