如何将图像从一个域保存到另一个域
我刚刚负责将网站的管理部分抽象到单独(共享)托管计划上自己的单独域。管理部分的部分工作是上传产品图片。现在该管理部分不再是主域的一部分,如何将产品从管理域上传到主域?
我正在使用 ASP.NET/VB.NET。
谢谢
编辑让我补充一下,两个系统都采用共享托管计划,因此我实际上没有任何映射驱动器或任何内容的能力。我一直在寻找一种编程方式。有没有一种方法可以让一个站点“调用”另一个站点并告诉它要将哪些文件保存到服务器上?
I've just been tasked with abstracting the admin section of a website to its own separate domain on a separate (shared) hosting plan. Part of what the admin section does is upload pictures for products. Now that this admin section is no longer a part of the main domain, how can I upload products onto the main domain from the admin domain?
I'm using ASP.NET/VB.NET.
Thanks
EDIT Let me add that both systems are on shared hosting plans, so I don't really have any sort of ability to map drives or anything. I was looking for a programmatic way. Is there a way to have one site "call" the other and tell it which files to save onto the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果它们位于同一机器上,您可以让一个站点写入另一站点的文件系统(给予正确的权限)。但这听起来好像它在您的共享托管环境中不起作用。
否则,您可以为主应用程序提供一个 URL,以从管理应用程序加载图像,只需确保将图像保存到公众可以访问的位置即可。
If they're on the same box, you can have one site write to the other site's file system (given the right permissions). But this sounds like it won't work in your shared hosting environment, though.
Otherwise, you could provide a URL for the main app to load images from the admin app, just make sure the images are saved to a place where they're accessible to the public.
您可以在非管理域上设置将由管理域调用的 Web 服务。因此,当您在管理中上传新图像时,您:
它远没有共享文件夹那么容易,但它会起作用的。
在共享服务器上节省的钱值得花时间实现这个吗?谁知道...
You can setup a webservice on the non-admin domain that will be called by the admin domain. So when you upload a new image in admin you:
It is far from being as easy as sharing a folder, but it would work.
Is the money saved on a shared server worth the time of implementing this? Who knows...
我还没有找到更优雅的解决方案,所以我希望你能得到比我更好的答案。我也不确定根据您的设置这是否可能。
在这种情况下,我通常会选择两个选项之一。两者都涉及从图像上传到的服务器映射网络驱动器,然后将文件从管理站点复制到主站点。
要么我在文件上传后立即复制它们,要么编写一个单独的脚本来复制文件。可能,在管理站点上,我会列出需要复制的文件,并通过单击按钮进行复制。
编辑 - 事后添加
这是我经常遇到的挑战之一。由于涉及额外的开销,我几乎从未将管理站点放在与主站点不同的服务器上。上述方法仅在我绝对需要这样做的情况下使用。
I have not yet found a more elegant solution, so I'm hoping you'll get a better answer than mine. I'm also not sure if this is even possible based on your setup.
What I normally do in this case is to do one of two options. Both involve mapping a network drive from the server where the images are uploaded to and then copying the files from the admin site to the main site.
Either I copy the files as soon as they are uploaded, or I write a separate script to copy the files. Possibly, on the Admin site, I would list the files that need to be copied and do the copy on a button click.
EDIT - added after the fact
This is one of those challenges that comes up regularly for me. Due to the extra overhead involved, I almost never put my admin site on a different server than the main site. The above methods are used only where I absolutely need to do this.