예제 #1
0
 /// <summary>
 /// Creates the PNG identicon image corresponding to userId and saves it to a blob
 /// </summary>
 /// <param name="userId">We expect a random value from 1073741823 to 2147483646</param>
 /// <param name="size">The size of icon in pixels. Total 5 blocks pattern + 2 x 1.5 margin = 8 blocks of pixels. Notice, the block size should be an even number to produce equal margins.</param>
 /// <param name="containerName"></param>
 public static async Task CreateAndSaveIdenticonAsync(int userId, int size, string containerName)
 {
     using (var stream = new MemoryStream())
     {
         CreateIdenticon(userId, stream, size);
         var blobName = KeyUtils.IntToKey(userId);
         await AzureStorageUtils.UploadBlobAsync(stream, containerName, blobName, "image/png");
     }
 }
예제 #2
0
        /// <summary>
        /// Saves audio recording.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="userId"></param>
        /// <param name="displayName"></param>
        /// <param name="artifactType"></param>
        /// <param name="duration"></param>
        /// <param name="recordingTitle">May come with Skype recording.</param>
        /// <param name="recorderId">Comes from Audior. It is the recorderId and will be used to update Title with the real title after upload is done.</param>
        /// <returns>Exercise Id</returns>
        public static async Task <int> SaveRecording(Stream stream, int userId, string artifactType, string serviceType, decimal duration, string recordingTitle = null, string recorderId = null)
        {
            var contentType = artifactType == ArtifactType.Mp3 ? MediaType.Mp3 : MediaType.Octet;
            var blobName    = UploadUtils.ConstractBlobName(recorderId, userId, contentType);
            await AzureStorageUtils.UploadBlobAsync(stream, AzureStorageUtils.ContainerNames.Recordings, blobName, contentType);

            var exerciseId = await CreateExercise(blobName, userId, serviceType, artifactType, duration, recordingTitle);

            return(exerciseId);
        }