colloqi / pisignage-server

Local Server to manage piSignage players based on node.js
http://www.pisignage.com
MIT License
372 stars 153 forks source link

POST to /files API not working #85

Open mortomanos opened 4 years ago

mortomanos commented 4 years ago

I cannot get the POST to /files (asset file upload) working on the open source server. I tried to use the swagger API "try out" feature as well as the curl command line, but both did not work. I also looked at the code, but found nothing useful why it is not working.

I only get a 500 server error with no specific error message (Internal error occured!).

mortomanos commented 4 years ago

Found it myself: the swagger API documentation is wrong, it states that the form data field needs to be named "Upload file", but instead it needs to be "assets" Could you please change the documentation?

rafagf1 commented 3 years ago

Thanks for the info.

Example in ruby:

` require 'net/http' require 'json'

@user = 'pi' @pass = 'pi' @url_files = 'http://192.168.0.2:3000/api/files'

def upload_file(file)

uri = URI(@url_files)

Net::HTTP.start(uri.host, uri.port) do |http| request = Net::HTTP::Post.new(uri.request_uri) request.basic_auth(@user, @pass) form_data = [["assets", File.open('/tmp/' + file)]] request.set_form(form_data, 'multipart/form-data') response = http.request(request) puts response.body end end

upload_file('file.jpg') `