Сервер A (Сервер получает файл с Сервера B)
models.py
class TestModel(models.Model):
# Other fields you are interested in saving
file_data = models.FileField()
serializers.py
class TestModelSerializer(serializers.ModelSerializer):
class Meta:
model = TestModel
fields = '__all__'
view.py
class TestModelViewSet(viewsets.ModelViewSet):
queryset = TestModel.objects.all()
parser_classes = (MultiPartParser, FormParser,)
serializer_class = TestModelSerializer
urls.py
router = routers.DefaultRouter()
router.register(r'test', views.TestModelViewSet)
urlpatters = [
url(r'^api/', include(router.urls))
]
Сервер B (192.168.5.5) (Отправить файл на сервер A)
file_generator.py
with open('file.txt', 'rb') as f:
r = requests.post('http://192.168.5.5/api/test', files={'file.txt': f})