#πŸ”’ Uploading files to nginx

33 messages Β· Page 1 of 1 (latest)

plush pebble
#

I need to upload my mp4 files that my bot generates to nginx and my domain so there downloadable from domain, How do i start?

winter sluiceBOT
#

@plush pebble

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

obtuse roost
#

With Python?

cosmic sundial
#

nginx != python

plush pebble
cosmic sundial
#

Is python on the client or server?

plush pebble
cosmic sundial
#

So with a python script uploading the files, you would probably use the requests module.

plush pebble
cosmic sundial
#

ex: ```py
import requests

requests.post("https://example.com/upload", files={
"file1": ("filename.txt", b"file contents goes here")
})

plush pebble
plush pebble
cosmic sundial
#

You have a host?

#

it's your hostname

plush pebble
#

Its a ipv4

#

I would like to use my domain tho

cosmic sundial
#

you can use an ip

plush pebble
#

but if I send the user there video file link wouldnt it be the ip and not a domain?

cosmic sundial
#

"http://10.0.0.1/upload"

plush pebble
#

So what url would the file be saved to?

plush pebble
cosmic sundial
#

upload is the endpoint. You specify the filename in the files argument.

cosmic sundial
plush pebble
#

yes but how would you download it?

#

I need a shareable link that people can download the file from that link

cosmic sundial
#

you'd have to add the upload folder as a static folder in nginx

#

You may consider making a flask endpoint for it instead of using nginx

hot holly
#

On the server side I think you will need to write a little Python WSGI application. You can't just "upload" a file to a web server -- something on the server has to catch the HTTP requests and store them as a file.

#

Read up on Python Flask applications. You need one on the server side.

winter sluiceBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.