【发布时间】:2016-05-13 06:58:28
【问题描述】:
一步一步地解决我的问题。我现在有一个原始图像数据,最后一步是将其发送到我的数据库,在这种情况下我使用 Parse。这是到目前为止的代码:
具有 Selectpicture 功能的视图模型以及我如何获取原始图像(有效):
public async Task SelectPicture()
{
Setup ();
ImageSource = null;
try
{
var mediaFile = await _Mediapicker.SelectPhotoAsync(new CameraMediaStorageOptions
{
DefaultCamera = CameraDevice.Front,
MaxPixelDimension = 400
});
VideoInfo = mediaFile.Path;
ImageSource = ImageSource.FromStream(() => mediaFile.Source);
imageData = ReadStream(mediaFile.Source);
}
catch (System.Exception ex)
{
Status = ex.Message;
}
}
我尝试将图片发送到我的数据库的页面以及用户可以看到他们选择的图片的页面,这就是我卡住的地方:
private async void btnPickPicture_Clicked (object sender, EventArgs e)
{
await MyViewModel.SelectPicture ();
imgPicked.Source = MyViewModel.ImageSource; //my image x:name in xaml
System.Diagnostics.Debug.WriteLine (imgPicked.Source);
}
//Below I send it to my parse and in parse they save it as a "File". This is the part where I am not sure how to get it right. I have to pass it as a byte but Iam not sure how to execute it.
async void SendDataClick (object sender, EventArgs args)
{
var createResult = await parseAPI.createInfo
( MyViewModel.ImageData );
}
要解析的代码:
static public async Task<bool> createInfo (byte [] thePicture)
【问题讨论】:
-
旁注:如果您没有听说过,Facebook 正在关闭 Parse,因此对于新的开发,您可能需要考虑其他服务...blog.parse.com/announcements/moving-on
-
是的,我知道。但由于我现在主要是在努力学习,所以我将它用于我的锻炼项目。