Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 使用URL请求发送Base64编码数据_Apache Flex_Base64 - Fatal编程技术网

Apache flex 使用URL请求发送Base64编码数据

Apache flex 使用URL请求发送Base64编码数据,apache-flex,base64,Apache Flex,Base64,我正在编写一个功能,将一个图像和一些元数据一起上传到一个服务,该服务需要使用base64编码的图像进行POST操作。但是,图像数据在发布到服务器时似乎会被破坏,并且不会生成有效的图像。我选择使用URLRequest框架而不是HTTPService,因为该服务返回用户希望保存的内联下载 在这个URLRequest调用中是否有我处理编码错误的地方 public function imageExportHandler():void { trace(this);

我正在编写一个功能,将一个图像和一些元数据一起上传到一个服务,该服务需要使用base64编码的图像进行POST操作。但是,图像数据在发布到服务器时似乎会被破坏,并且不会生成有效的图像。我选择使用URLRequest框架而不是HTTPService,因为该服务返回用户希望保存的内联下载

在这个URLRequest调用中是否有我处理编码错误的地方

    public function imageExportHandler():void
    {
        trace(this);
        var request:URLRequest = new URLRequest();
        request.method = URLRequestMethod.POST;
        request.url = imageExportServiceUrl;

        var params:Object = {
            image: encodeImageBase64(imageData),
            name: StringUtil.substitute("map-{xmin},{ymin}-{xmax},ymax}", imageExtent),
            format: Model.instance.imageExportModel.selectedFormat
        };
        request.data = new URLVariables(StringUtil.substitute("image={image}&format={format}&name={name}", params));
        navigateToURL(request, "_blank");
    }

    private function encodeImageBase64(toEncode:BitmapData):String
    {
        var pngEncoder:PNGEncoder = new PNGEncoder();
        var data:ByteArray = pngEncoder.encode(toEncode);
        var base64Encoder:Base64Encoder = new Base64Encoder();
        base64Encoder.encodeBytes(data);
        return base64Encoder.flush();
    }

事实证明base64Encoder.flush没有正确终止编码字符串-正确使用的函数是base64Encoder.toString。

您使用的Base64编码器是否将其编码为可安全通过web传输的字符串?如果Base64字符串包含+、=、和/字符,则会导致问题。@Ren可能就是这样。编码器与HTTPService库一起工作可靠,但这可能是在幕后处理url编码问题。我假设您在问题中提到的服务不在您的控制之下。他们是否有任何文件可以为您指明正确的方向?也许他们提到你应该把这些符号改成什么字符?通常是“+”='%2B'、“/”='%2F'和“='='%3D'