What better way to work/store files in Base64 C# + Sqlserver

Asked

Viewed 308 times

0

I am consuming an external API, and in return I have a PDF file in format base64, would like to know how best to work/store this kind of data in the database SqlServer + C#.

My question is:

1 - I must store the return in base64 creating a text field in the sql-server (I know it is not the best way, because text fields is expensive for the database).

2 - I must create a field in the format varbinary(max) and convert that string base64 for byte[] ?

  • My dear fellow, the other question I asked you marked as pending, so I reopened another very detailed one. What can I do to publish a question or two?

  • I guess you want to know what the best practice is for that, huh? Look I’ve done something similar to picture, and it didn’t work out the bank got too big! Depending on the size of the file the text will be huge, so I advise you to read the Base64 returned by the api and save on the server disk or in a cloud and in the database you save only the location and name of the file!

  • @Lodi, what if I turn this Base64 into an array of bytes and persist into a varbinary(max) field? because so, I need to at the moment save for a while this in Base64 and after my registration is fully completed I will save in a Log and delete these records from the database leaving only the reference of the file path.

  • Now it is no longer a doubt, because it could be done in several ways, including the forms mentioned by you! For me the best way to do this is by reading the local disk file, in the database only the path and file information! I believe this would be less costly for the application, but it is up to you...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.