Ejemplo n.º 1
0
 public JsonModels.UploadReponse AddAudioElement(int projectId, string description, Stream fileStream, string fileName)
 {
     Project p = pa.GetProject(projectId);
     BlobStorageAccessor ba = new BlobStorageAccessor();
     string location = null;
     string[] s2 = fileName.Split('.');
     string extention = s2[s2.Count() - 1].ToLower();
     if (extention.ToLower() == "mp3")
     {
         location = ba.uploadMP3(fileStream, false).ToString();
     }
     else if (extention.ToLower() == "ogg")
     {
         location = ba.uploadOGG(fileStream, false).ToString();
     }
     else if (extention.ToLower() == "wav")
     {
         location = ba.uploadWAV(fileStream, false).ToString();
     }
     else if (extention.ToLower() == "m4a")
     {
         location = ba.uploadM4A(fileStream, false).ToString();
     }
     else
     {
         //upload unknown file type. do this or display message
         Uri result = ba.uploadUnknown(fileStream, false, extention);
         if (result == null)
         {
             return null;
         }
         else
         {
             location = result.ToString();
         }
     }
     ProjectElement_Audio pe = new ProjectElement_Audio
     {
         description = description,
         audioLocation = location,
         title = fileName,
     };
     int pID = pa.AddProjectElement(p, pe);
     return new JsonModels.UploadReponse { id = pID, fileURL = location, name = fileName };
 }