diff --git a/app.rb b/app.rb index c0686d1a..43c623c8 100644 --- a/app.rb +++ b/app.rb @@ -565,7 +565,7 @@ post '/api/upload' do files = [] params.each do |k,v| - next unless v[:tempfile] + next unless v.is_a?(Hash) && v[:tempfile] files << {filename: k.to_s, tempfile: v[:tempfile]} end diff --git a/views/_header.erb b/views/_header.erb index 36e60853..72598eaf 100644 --- a/views/_header.erb +++ b/views/_header.erb @@ -16,6 +16,9 @@
Using cURL to upload a single local file (local.html), which will be index.html on the server:
-$ curl -F index.html=@local.html https://USER:PASS@neocities.org/api/upload
+ Upload a single local file (local.html), which will be named hello.html on your site:
+$ curl -F hello.html=@local.html https://USER:PASS@neocities.org/api/upload
+ This example uses the neocities module, which works for node.js and web browsers (via browserify). You can install it by running npm install neocities --global in your terminal.
++var NeoCities = require('neocities') + +var api = new NeoCities('YOURUSERNAME', 'YOURPASSWORD') + +// Upload a file called local.html from your computer, +// which will be named newfile.html on the site. + +api.uploadFile('newfile.html', './local.html', function(resp) { + if(resp.result == 'error') + throw new Error(resp.error_type+' - '+resp.message) + + // Display response from API + console.log(resp) +}) +diff --git a/views/index.erb b/views/index.erb index c25e655e..3efc7933 100644 --- a/views/index.erb +++ b/views/index.erb @@ -66,6 +66,9 @@