Я новичок в разработке Xamarin. Я использую ведро Azure для загрузки файлов в мобильное приложение Android. Для целей тестирования я создал консольное приложение, которое успешно загружает файл на лазурное ведро без прерывания. Но когда я пытаюсь создать токен доступа из мобильной разработки, он застревает и дает мне исключение тайм-аута. Если я создаю токен из консольного приложения и использую этот токен для загрузки файлов, он дает мне другое исключение, например «владелец места не найден». Как и ожидалось, мне нужна мобильная услуга для генерации токенов. Если у вас есть какие-либо идеи, поделитесь своими мнениями со мной, что было бы очень полезно. Я также загружаю код, который я использую для разработки Android.Синхронизация файла Azure в Xamarin
[Activity(Label = "WedAndroidApp", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
//string sas = "https://supplypark.blob.core.windows.net/transaction-images?sv=2015-04-05&sr=c&sig=iJ8CZOi%2BktarlmrbZVHK7rYLdMOnKCeBjuPqjrrkGnM%3D&se=2016-06-09T14%3A21%3A49Z&sp=rwdl";
string sas_token = "https://supplypark.blob.core.windows.net/transaction-images?sv=2015-04-05&sr=c&sig=AeWe8rghAlKz77Xh%2BUM6S46AuUQzAaD2djqhaW9wdN8%3D&se=2016-06-09T14%3A21%3A49Z&sp=rwdl";
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
//button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
button.Click += async delegate {
button.Text = string.Format("{0} clicks!", count++);
await UseContainerSAS(sas_token);
};
}
static async Task UseContainerSAS(string sas)
{
//Try performing container operations with the SAS provided.
//Return a reference to the container using the SAS URI.
CloudBlobContainer container = new CloudBlobContainer(new Uri(sas));
string date = DateTime.Now.ToString();
try
{
//Write operation: write a new blob to the container.
CloudBlockBlob blob = container.GetBlockBlobReference("tdi" + date + ".txt");
string blobContent = "This blob was created with a shared access signature granting write permissions to the container. ";
MemoryStream msWrite = new
MemoryStream(Encoding.UTF8.GetBytes(blobContent));
msWrite.Position = 0;
using (msWrite)
{
await blob.UploadFromStreamAsync(msWrite);
}
Console.WriteLine("Write operation succeeded for SAS " + sas);
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("Write operation failed for SAS " + sas);
Console.WriteLine("Additional error information: " + e.Message);
Console.WriteLine();
}
}
}
Я следую за этим https://azure.microsoft.com/en-in/documentation/articles/storage-xamarin-blob-storage/ для разработки azure mobile. Но зависимости Azure от хранилища не загружаются из пакета neget. –
Привет, ребята, я решил проблему. Если у вас возникли проблемы с установкой зависимостей, используйте менеджер пакетов Console для установки зависимостей. Пожалуйста, следуйте приведенным ниже: - «Install-Package WindowsAzure.Storage -Version 4.4.1-preview -Pre» –