I have implemented load balancing between two server. My project is hosted on both server. All works fine.
A problem is whenever file is uploaded it will be upload one of that server. So when I reference a path for that file in application then there may be chance that file is missing since that file is not uploaded in another server. That mean image is required on both server at a time.
But I don't want to upload file on both server because it is total waste of storage.
So I want if file is not found on one server then it should take from other automatically.
How can I achieve this ??
Thanks
you can create a single shared network folder where all files are uploaded. That will place all the files to a single location. You can then create a new web site called static.yourdomain.com which will serve this files. This is a kind of CDN for your static\shared files.
Related
I have an asp.net website that create some xml files on the fly. I succeed to run this on my pc. but when I upload the project to the hosting (Godaddy) the file xml files can't be created. I already fixed the permission to the destination folder, but nothing change. still can't create the xml files.
Are there any solutions to my problem ? thanks
I think the problem is trust level.GoDaddy's trust level medium.Thus you can not create xml file due to security reasons.You should find another hosting company which allow full trust level.
I am trying to upload very big files greater than 1gb. I am using MultipartConfig and HttpServletRequest.getPart(String) from servlet api. I deployed in my server and tried uploading a file and its working like a charm.
Then I went on reading about MultipartConfig here. I understood that when large files are uploaded it writes parts of the file to a temporary location when the threshold is reached. And later on we have to delete the temporary files using part.delete().
What if I don't want to mention the temporary location? Will something bad happen to my application while uploading big files? I don't want to mention a temporary location becasue we cant gurantee about the production environment.
I don't think there will any problem without specifying any temporary location. Servlet specification 3.0 says every servlet context should have a temporary working directory. So by default all parts are saved to a temporary working directory which is vendor specific.
The default location is handled differently by every Application Server.
In Tomcat temporary files exceeding the threshold are saved in a subfolder of the CATALINA_HOME directory (tried with Tomcat 9.0.21).
I found the temporary files to be created here: CATALINA_HOME/work/Tomcat/localhost/MYWEBAPP/upload_3440d3f3_8d15_43ad_bb1d_349599450616_00000005.tmp
I have a web application with a page. The page has a functionality to upload a file.
I have deployed the application on two different servers in IIS7. Both these hosting have a virtual directory pointing to the same physical directory.
Here I am unable to save the posted file in the virtual directory using Server.MapPath.
Is there any sophisticated technique to handle such situation to achieve this functionality?
Well I'd suggest you 2 scenarios:
Share a folder/resource beetween those servers (assuming that
those servers are in the same LAN), then create app key in the
web.config and this key will contain the path of your shared
resource something like //Server/Folder, use this value instead of server.mappath at the time you
save the file in the server
If you have a load balancer share a folder of your main node and
then use the that path in your secondary node something like
//server/folder that route will save the image in the main node, then
set up a replication rule from your main node and the secondary the
configuration of this rule could vary depending on your needs it
could be an update to the seconday node every 5 minutes for example.
you may create a virtual directory but the purpose for this will be only for displaying the images.
that worked for for me some time ago, it's not a fancy solution but it does the job.
We have hosted some downloadable files on our different server due to bandwidth problem.
Now we want to download those files using an ASP script from our current server.
But how could we know the absolute path of that particular server using ASP script ?
regards
sk
Not 100% sure of what you're asking...
If the remote files are within a website on the remote server, you van reference them directly. If they are managed within your application, you may need to build some additional web service/httphandler or "asp" page that retrieves and serves the image (binary write, setting mime type etc)
Users of my web site will be able to upload a picture. This picture will land in /images/folder/picture.jpg. The question I have is: When running under VS2008, a form will insert a full row in a database column (sql server)and the picture will be uploaded to the folder. The result page will show the image. But when running the web server again later, the database will be ok but the image won't be there anymore since I guess that the local server each timer starts freshly with no content in the folder. I am new to uploading so I am wondering how you do to test this kind of thing.
Also, must the folder for the images be under /Content ? I am not sure where to put it and how it will transition when running under IIS ?
Thx
The ASP.NET development server does not clear the directory each time it starts. Have you verified the files are actually being written where you think they are? Seems like you've probably got some path issues and the files are possibly being written to the ASP.NET Temporary Files folder which may change from instance to instance.
I've have to test this with my local server to see exactly what it's doing with regard to the image that's being uploaded locally... but one thought is that instead of storing the picture on the file system, store it in the database itself.