【问题标题】:How can I limit the storage I give each user on an iOS(swift)/Firebase app?如何限制我在 iOS(swift)/Firebase 应用程序上为每个用户提供的存储空间?
【发布时间】:2017-06-16 08:04:29
【问题描述】:

我正在制作一个照片库应用,希望用户拥有 2GB 存储空间,然后为更多存储空间付费

我已经完成了相当多的应用程序,但我在如何分配 2GB 和允许用户解锁额外空间的方法上遇到困难

如果有人能给出基本的指导,那就太好了

【问题讨论】:

    标签: ios swift firebase storage firebase-storage


    【解决方案1】:

    解决方法:您应该有一个变量名称,例如:“used_storage”,将其保存在您想要的任何位置。 (不要让用户轻易改变它)

    max_storage = 2 * 2^20
    

    当您将大小为 x KB 的图库保存到应用程序文件夹时:

    if used_storage + x < max_storage {
      used_storage += x
      // update used_storage
      // save your image
    } else {
      // alert to user that they used to much and must charge for more space ... 
    }
    

    【讨论】:

    • 谢谢,真的很有帮助
    猜你喜欢
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2021-11-09
    • 2023-04-01
    • 2015-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多