简体   繁体   English

编辑 Azure 存储中的文件

[英]Editing a file in Azure storage

I am using the Azure Storage File Shares client library for .NET in order to save files in the cloud, read them and so on.我正在使用适用于 .NET 的 Azure 存储文件共享客户端库,以便将文件保存在云中、读取它们等等。 I got a file saved in the storage which is supposed to be updated after every time I'm doing a specific action in my code.我在存储中保存了一个文件,每次我在代码中执行特定操作后都会更新该文件。

The way I'm doing it now is by downloading the file from the storage using我现在这样做的方式是使用从存储中下载文件

ShareFileDownloadInfo download = file.Download();

And then I edit the file locally and uploading it back to the storage.然后我在本地编辑文件并将其上传回存储。

The problem is that the file can be updated frequently which means lots of downloads and uploads of the file which increases in size.问题是文件可以经常更新,这意味着文件的大量下载和上传会增加文件的大小。

Is there a better way of editing a file on Azure storage?是否有更好的方式在 Azure 存储上编辑文件? Maybe some way to edit the file directly in the storage without the need to download it before editing?也许某种方式可以直接在存储中编辑文件而无需在编辑前下载它?

Downloading and uploading the file is the correct way to make edits with the way you currently handling the data.下载和上传文件是使用您当前处理数据的方式进行编辑的正确方法。 If you are finding yourself doing this often, there are some strategies you could use to reduce traffic:如果您发现自己经常这样做,可以使用一些策略来减少流量:

  1. If you are the only one editing the file you could cache a copy of it locally and upload the updates to that copy instead of downloading it each time.如果您是唯一编辑该文件的人,您可以在本地缓存它的副本并将更新上传到该副本,而不是每次都下载它。
  2. Cache pending updates and only update the file at regular intervals instead of with each change.缓存挂起的更新并且只定期更新文件而不是每次更改时更新。
  3. Break the single file up into multiple time-boxed files, say one per hour.将单个文件分解为多个按时间限制的文件,例如每小时一个。 This wouldn't help with frequency but it can with size.这对频率没有帮助,但对大小有帮助。

FYI, when pushing logs to storage, many Azure services use a combination of #2 and #3 to minimize traffic.仅供参考,在将日志推送到存储时,许多 Azure 服务使用 #2 和 #3 的组合来最小化流量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM