Angular - 如何在没有后端的情况下测试Internet上传速度? [英] Angular - how to test Internet upload speed without backend?

查看:111
本文介绍了Angular - 如何在没有后端的情况下测试Internet上传速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在localhost上运行时将文件上传到我的Angular应用程序服务器的文件夹中。我不能在不使用后端的情况下找到任何解决方案。

I want to upload file into folder from which my Angular app is served while running on localhost. I'm not able to find any solution without using backend.

例如我只想上传一个图像文件,该文件应该复制到项目的指定文件夹中。这应该只使用Angular而不使用任何后端脚本或命中任何API端点。

For example I just want to upload an image file and that file should copy in specified folder of the project. This should be done only with Angular without using any Backend script or hitting any API endpoint.

推荐答案

根据您的webhost,您可以通过FTP访问您的资产文件夹。
从javascript(angular is javascript)进行FTP调用并不困难。互联网上有很多关于它的例子和问题(比如这个

Depending on your webhost, you can make your assets-folder accessible via FTP. Making a FTP-call from javascript (angular is javascript) isn't that difficult. And there are plenty of example and questions about it on the internet (like this)

为什么你不这样做:


  • ftp-connection的凭据将在编译的javascript代码中访问。只需稍加努力,每个人都可以找到它。

  • 您通过webhosts防火墙打开的每个门都是一个额外的漏洞。这就是为什么每个人都会建议你添加一个API端点来上传文件,这样你就可以保留可以上传的字符串。

编辑:

当我再次阅读您的问题和所有子答案时,我(想)发现您正在构建一个原生代码 - 像没有后端的应用程序,只是一个角度单页前端应用程序。我可以理解为什么(你可以在支持javascript的应用程序的每个平台上运行它),但你遇到的问题只是整个系列中的第一个。

As I read your question again and all the sub-answers, I (think) figured out that you are building an native-like app with no back-end, just an angular-single page front-end application. An I can understand why (you can run this on every platform in an application that supports javascript), but the problem you are encountering is only the first of a whole series.

如果是这种情况,我不会把它称为上传,就像你在本地存储一样。

If this is the case, I wouldn't call it uploadingas you would store it locally.

但是好消息是您有 localstorage 供您在客户端硬盘上存储临时数据。它不是一个非常大型空间,但它是......

But the good news is that you have localstoragefor your use to store temporary data on the HDD of the client. It isn't a very large space but it is something...

这篇关于Angular - 如何在没有后端的情况下测试Internet上传速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆