小编Ahm*_*med的帖子

为什么我的图片上传到 s3 存储桶时大小增加了 4 倍

我目前正在使用 POST 预签名 url 将图像上传到我的 s3 存储桶。我的图像扩展名为 png,大小为 5.6Mb。当上传到 s3 存储桶时,图像将存储为 base64 编码字符串。s3 上图像的大小从 5.6MB 变为 23.3Mb。有没有对此有解释。我知道编码后图像大小变为原始大小的1.37倍。

base64 png amazon-s3 amazon-web-services

5
推荐指数
0
解决办法
729
查看次数

使用 jquery 更改占位符文本字体和颜色

我有以下形式的输入标签

<input type="text" name="firstname" id="firstname" placeholder="First name">
Run Code Online (Sandbox Code Playgroud)

首先,我使用 jquery 检查该字段是否为空

 $("#submitreg").click(function(e){
     if ($.trim($("#firstname").val())=='')
         {
             $("#firstname").attr('placeholder',"first name can't be empty");
             e.preventDefault();
         }
 });
Run Code Online (Sandbox Code Playgroud)

现在,如果输入字段为空,我将占位符更改为“名字不能为空”。是否也可以将占位符颜色更改为红色并使用 jquery 将字体设为 85%。

谢谢

html forms jquery input

4
推荐指数
1
解决办法
3686
查看次数

IOS中app启动时如何区分通知是本地通知还是远程通知

以前我使用以下代码来区分应用程序启动时我的通知是本地还是远程

    func application(_ application: UIApplication, 
    didFinishLaunchingWithOptions launchOptions: 
    [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    if (launchOptions?[UIApplication.LaunchOptionsKey.localNotification] != nil)
    {


    }
    if (launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] != nil)
    {


    }
    }
Run Code Online (Sandbox Code Playgroud)

条件是我的应用程序被杀死,我正在从通知中打开它。

问题是这个方法

if (launchOptions?[UIApplication.LaunchOptionsKey.localNotification] != nil)
{


}
Run Code Online (Sandbox Code Playgroud)

已弃用,从通知中心打开应用程序时不会调用以下方法

 func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {}
Run Code Online (Sandbox Code Playgroud)

ios localnotification swift

4
推荐指数
1
解决办法
1612
查看次数

互联网连接状态快速可达

我有以下代码来确定是否有互联网连接。这段代码工作正常。我如何知道我是否突然失去连接

  var reachability:Reachability?
  reachability = Reachability()
  self.reachability  = Reachability.init()
    if((self.reachability!.connection) != .none)
    {
        print("Internet available")
    }
Run Code Online (Sandbox Code Playgroud)

可达性类是否具有报告连接是否断开的功能。如果无法解决可达性问题,其他选择是什么

connection reachability ios swift reachability-swift

3
推荐指数
1
解决办法
2790
查看次数

如何在条带中的付款意图示例中自定义付款方式

我正在尝试按照以下链接https://stripe.com/docs/payments/accept-a-payment 中显示的示例进行操作

我在客户端有以下代码

 var cardNumber = elements.create('cardNumber', {
    placeholder:'',
    style: style
});
var cardexpiry = elements.create('cardExpiry',{
    placeholder:'',
    style:style
});
var cardCVV = elements.create('cardCvc',{
    placeholder:'',
    style:style
});


// Add an instance of the card Element into the `card-element` <div>.
cardNumber.mount('#card-element');
cardexpiry.mount("#card-expiry")
cardCVV.mount("#card-cvv")
Run Code Online (Sandbox Code Playgroud)

而不是这个

var card = elements.create("card", { style: style });
card.mount("#card-element");
Run Code Online (Sandbox Code Playgroud)

因为我想要一些 UI 操作。根据链接中发布的代码,我应该执行以下操作

var submitButton = document.getElementById('submit');

submitButton.addEventListener('click', function(ev) {
 stripe.confirmCardPayment(clientSecret, {
   payment_method: {card: card}
 }).then(function(result) {
 if (result.error) {
  // Show error to your customer …
Run Code Online (Sandbox Code Playgroud)

node.js stripe-payments

3
推荐指数
1
解决办法
845
查看次数

快速访问相机和照片库4

我正在尝试使用以下代码在swift4中访问相机和照片库

let imagePickerController = UIImagePickerController()
    imagePickerController.delegate = self
    let alert = UIAlertController(title: "", message: "", preferredStyle: .actionSheet)
    alert.addAction(UIAlertAction(title: "Camera", style: .default, handler: {(action: UIAlertAction) in
        imagePickerController.sourceType = .camera
        print(1)
    }))
    alert.addAction(UIAlertAction(title: "Photo Album", style: .default, handler: {(action: UIAlertAction) in
        imagePickerController.sourceType = .photoLibrary
    }))
    alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil))
    self.present(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

但它不起作用。即使我确保plist具有相机和照片库的授权,也没有收到访问授权请求。我对以下代码进行了一些操作

AVCaptureDevice.requestAccess(for: AVMediaType.video) { response in
    }
    let photos = PHPhotoLibrary.authorizationStatus()
    if photos == .notDetermined {
        PHPhotoLibrary.requestAuthorization({status in
        })
    }

    let imagePickerController = UIImagePickerController()
    imagePickerController.delegate = …
Run Code Online (Sandbox Code Playgroud)

camera photolibrary ios swift phphotolibrary

2
推荐指数
2
解决办法
1万
查看次数

格式说明符C++有什么问题

我有以下代码:

#include <cstdio>

int main()
{
    float b = 323.23f;
    std::scanf("%6.3f\n", &b);  // <-- Warning
    std::printf("%6.3f\n", b);
}
Run Code Online (Sandbox Code Playgroud)

有一个警告scanf()说:

转换说明符无效 '.'

这里有什么我想念的吗?

c++ scanf format-specifiers

2
推荐指数
1
解决办法
118
查看次数

当应用程序被杀死而不在IOS后台运行时如何获取通知有效负载

我有个问题。即使应用程序没有在后台运行,当您从通知打开应用程序时是否可以获取通知正文。它被彻底杀死了。

ios uilocalnotification swift

2
推荐指数
1
解决办法
4632
查看次数

如何在 Google Cloud Firestore 中强制执行文档字段属性的唯一性

我有以下数据,如图所示。我想确保用户名字段是唯一的。我怎样才能强制执行呢?请记住,我的文档 ID 已经是唯一的,我不想使用我的用户名作为文档 ID

在此输入图像描述

unique firebase google-cloud-firestore

2
推荐指数
1
解决办法
1804
查看次数

如何在 s3 私有存储桶中公开 s3 对象而不使用预签名 URL

我有一个具有以下策略的 s3 存储桶

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "VisualEditor0",
        "Effect": "Allow",
        "Action": [
            "s3:PutObject",
            "s3:GetObject",
            "s3:ListBucket",
            "s3:DeleteObject"
        ],
        "Resource": [
            "arn:aws:s3:::bucket",
            "arn:aws:s3:::bucket/*"
        ]
    }
]
Run Code Online (Sandbox Code Playgroud)

}

存储桶的公共访问也被阻止。这是存储桶策略的快照

在此输入图像描述

基本上,我希望存储桶是私有的,以防止未经授权的用户上传文件,但我想向任何用户授予对存储桶内对象的公共读取访问权限

policy amazon-s3 bucket amazon-web-services

1
推荐指数
1
解决办法
4559
查看次数