我使用VichUploaderBundle上传图片到AmazonS3 symfony中-2。
I am using VichUploaderBundle to upload images to AmazonS3 in symfony-2.
我按照本文档的 https://github.com /dustin10/VichUploaderBundle/blob/master/Resources/doc/index.md 并建立了我的实体类。
I have followed this documentation https://github.com/dustin10/VichUploaderBundle/blob/master/Resources/doc/index.md and created my entity class.
所以我在实体有一个setter方法
So I have a setter method in the entity
/**
* @param UploadedFile $file
*/
public function setFile(File $file = null)
{
$this->file = $file;
$this->updated = new \DateTime();
}
客户端(这是一个Web应用程序)将发送的图像base_64格式。 所以,我不知道我将如何得到一个文件对象从该字符串的? (由于setter方法的参数是FILE)
The client (This is a web application) will be sending the image in base_64 format. So I dont understand how will i get a FILE object out of that string? (Since the parameter of setter method is FILE)
好了,所以你首先需要将图像保存到一个临时文件 - 这里是一个解决方案:How保存PNG图像服务器端,从一个base64数据串
Ok so first you need to save the image to a temporary file - here is a solution for that: How to save a PNG image server-side, from a base64 data string
然后,你需要使用该文件创建UploadedFile的实例,有点像这个例子: https://github.com/dustin10/VichUploaderBundle/issues/203
Then you need to create an instance of an UploadedFile using that file, kind of like this example: https://github.com/dustin10/VichUploaderBundle/issues/203
然后发送这UploadedFile的给您setFile()方法。
And then send this UploadedFile to your setFile() method.
上一篇:腐败/截断MP4上传到S3存储使用NodeJS和AWS S3腐败、NodeJS、AWS
下一篇:致命错误:类'AWS \ ElasticTrans codeR \ ElasticTrans coderClient'没有发现在C:\瓦帕\的www \ sep24 \等