A
A
AspMaster2019-09-19 09:07:43
API
AspMaster, 2019-09-19 09:07:43

How to properly write file service on asp.net core web api?

The task is to write a microservice that accepts files of any size, saves them to the hard drive, and then returns a link to this file. Faced two problems:
1) asp does not allow to upload a file larger than 2048 kb. I tried to disable this restriction in various ways from Google (both by an attribute that disables the file size limit, and in a startup by setting the maximum volume)
2) security. How to secure the service from intruders
3) performance. I read that when downloading large files at the same time, the service may crash.
How can I get around these problems?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MrDywar Pichugin, 2019-09-19
@AspMaster

1) You can use the database for everything. There is a file and a link to it.
+ all in one place.
+ Easy to back up.
+ transaction for the entire operation.
- the base will be very large.
2) You can use the database only to store links to the file.
+ The database is small.
+ storage separately.
- backup of the database and file storage is carried out separately.
- no transactions, the file can be written, but there will be no link, and vice versa.
DB - SQL or NoSQL.
Because there are no links, then NoSQL is better.
Security - Authorization, tokens or cookies. Nothing else.
There is either a service on the internal network, and nothing is needed. Or the service is available outside, and authorization is needed.
You can google how Azure Blob storage works, get ideas from there.
The problem with the size is solved, google more.

I
Ivan Shumov, 2019-09-19
@inoise

I'm not aware of asp, so I'll answer the last questions
2. solve by token access. typical solutions for this are a separate identity server, jwt tokens, Oauth2/OpenId. You can play around with others
3. do not write a bicycle, but use a ready-made storage s3-compatible, horizontally scalable. By the way, "any size" is wildness and on this one can already say "impossible"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question