You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AI2应用通过S3预签名POST URL上传CSV失败求助

Trouble Uploading CSV to S3 via Presigned POST URL in MIT App Inventor 2

Hey everyone, I've been banging my head against this issue for a few days now. I've dug through Google Groups, Stack Overflow threads, and even AWS Support Center docs, but haven't found anything that fixes my problem—so I'm hoping someone here can point me in the right direction.

Here's the setup: I built a web service that generates presigned POST URLs for an S3 bucket. When I test this with Python's requests.post module, uploading a simple CSV string like "a,1,b,2,c,3" works perfectly fine. No errors, the file shows up in S3 exactly as expected.

But when I try to do the same upload from a super basic MIT App Inventor 2 (AI2) app—seriously, it only has a button to trigger the upload, a web component to handle the request, and an output label to show status—I keep getting errors every single time.

I've messed around with the fields and conditions in the presigned POST configuration: I've set Content-Type to both multipart/form-data and text/csv, adjusted content length ranges, and double-checked all the S3 bucket permissions. Nothing seems to make a difference.

I've attached my relevant configuration code and screenshots of the AI2 app setup and error messages below. If anyone has ideas about what might be going wrong, or has run into a similar issue with AI2 and S3 presigned POSTs, I'd be really grateful for your help!

Relevant Python Configuration Code

import boto3
from botocore.exceptions import ClientError
import logging

logging.basicConfig(level=logging.INFO)

def generate_s3_presigned_post(bucket_name, object_key, expiration=3600):
    s3_client = boto3.client('s3')
    try:
        # Tried both text/csv and multipart/form-data here
        fields = {"Content-Type": "text/csv"}
        conditions = [
            ["content-length-range", 1, 10000],
            {"Content-Type": "text/csv"}
        ]
        response = s3_client.generate_presigned_post(
            bucket_name,
            object_key,
            Fields=fields,
            Conditions=conditions,
            ExpiresIn=expiration
        )
    except ClientError as e:
        logging.error(f"Error generating presigned POST: {e}")
        return None
    return response

# Example call
presigned_data = generate_s3_presigned_post("my-test-bucket", "uploaded.csv")

AI2 App Setup Screenshot

AI2 Component Layout and Block Configuration

Error Message Screenshot

AI2 Upload Error

内容的提问来源于stack exchange,提问作者S4nd33p

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:56:03