Custom Deployment server resources

One, caused by :

  Yesterday there needs need to save pictures and upload pdf and other file resources, but also available for download and display. The idea was to get a resource server, upload the archive to resources on the server resources, when needed resources are also available on the server.

Second, the resource server:

  Why add a custom title? Because at that time did not watch too much time on this kind of information, the idea is very simple, so I get out of this the following resource server may be wrong, but I can solve the problem (of course, I got behind this useless resources server, said the reason below).

Resources will certainly be put on a disk, my approach is as follows:

  IIS server is deployed on a site, the site is the physical path of a file on your server (Resouces), yes, resources must be uploaded into this folder inside. That's it, that's where I'm confused storage resources, ha ha, calling the resource server.

Three , why then useless this resource customized server?

  1, over time, more and more resources, space is often very large, maintenance will be very troublesome.

  2, the main reason is that there is Ali cloud OSS, why do it.

Fourth, look below and paste method to upload (back-end only)

  Upload the front end assembly has a lot of resources, I wrote a resource interface used to save upload. The front end needs to pass parameters there are two, one is the name of the file upload the file to include suffixes format (uploadFile.name), a string is base64 file upload (uploadFile.raw), below this interface supports all formats file, whether it is pictures or word or PDF.

    public static void UploadPreview(UploadFile uploadFile, out string errorMessage)
        {
            try
            {
                errorMessage = "";
                if (!Directory.Exists(Config.ImageResourceServerUrl)) Directory.CreateDirectory(Config.ImageResourceServerUrl);
                string path = $"{Config.ImageResourceServerUrl}//{ uploadFile.name}";
                byte[] buffer = Convert.FromBase64String(uploadFile.raw);
                FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                fs.Write(buffer, 0, buffer.Length);
                fs.Flush();
                buffer = null;
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }
        }

 

There would be good time to learn about knowledge service side, the general trend. There is something wrong wish to make progress together

Guess you like

Origin www.cnblogs.com/qtiger/p/12143667.html