A
A
apiwi2020-04-22 12:17:59
Python
apiwi, 2020-04-22 12:17:59

What free hosting to use for uploading files? And how to do it?

I have a code, it should download a file from the hosting, and unpack it into a specific directory. Where can I get a direct link tried getfile, but not everyone works. I don't know much about this, I hope you can help, thanks.
If anyone can, explain in more detail in VK: @xx69x69xx

import tempfile, os, zipfile
import requests
response = requests.get('https://dropfiles.ru/files/2828181a9b881cebd0fef825618a085a.zip')
file = tempfile.TemporaryFile()
file.write(response.content)
fzip = zipfile.ZipFile(file)
fzip.extractall('C:\\Users\\{0}\\Documents\\Rockstar Games\\GTA V\\User Music'.format(getuser()))
file.close()
fzip.close()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Pankov, 2020-04-22
@apiwi

he must download the file from the hosting

Where can I get a direct link

All file storages are different and for the most part they do not want to be used for mass distribution of files. That is why most of them are reluctant or do not allow you to form a direct link to download files at all.
Yandex disk, drop box, google drive - they all provide you with a service "as it were" for free, but as we know, if you get something for free, then the product is actually you, your content, your statistics, your wallet and your attention (advertising). Free cheese you know where it happens.
Of course, all these stores are not interested in having warez, porn, unlicensed content, prohibited content, and so on, distributed to a huge audience through them. And this is inevitable if it is possible to form a permanent direct link and let it be downloaded by an indefinite circle of people without authorization.
Hosting is different. They charge money for the opportunity to publish something online. There you can get permanent links, and white IPs, and good speed, and acceptable traffic limits.
It is quite possible to programmatically download files from free storages, but each storage implements everything in its own way and provides its own API, makes its own protection against abnormal use.
Your first mistake - you needlessly generalize too different tasks. Try to look for either a free storage with acceptable limits and direct links, or focus on one without direct links and look for a way to download data from it programmatically. For example, Yandex, as I recall, seemed to implement the web-dav protocol. It is somewhat similar to ftp in fact.
Your second mistake is not understanding how the store makes archives. The archive can, of course, be put on the storage as a file, but some storages allow you to download a directory with files as an archive. In this case, the files are stored separately and are collected in the archive only upon your request. That is, by making an http request, you start downloading a file, and at this time it is immediately formed on the fly. For storage, this is not a very cheap operation in terms of processor, so you are even less likely to get a direct permalink to this kind of archive than to just a single file.
Ask questions correctly, specify and describe what you really need, and not how you think this world works.

N
Nikolay, 2020-04-22
@SODINNER

In general, you can just open the page with a request and parse the link using the download button, then the site will generate a link, and it is not permanent, but if you parse it yourself, you will get a working one every time. Look at the parsing through beautifulsoup4.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question