Esempio n. 1
0
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (FileUploadControl.HasFile)
            {
                try
                {
                    if (FileUploadControl.PostedFile.ContentType == "image/jpeg")
                    {
                        if (FileUploadControl.PostedFile.ContentLength < 1024000)
                        {
                            if (Session["offSiteMySpace"] != null)
                            {
                                MySpace myspaceClient = (MySpace)Session["offSiteMySpace"];
                                if (Session["UserID"] != null)
                                {
                                    string userId = Convert.ToString(Session["UserID"]);
                                    MySpaceID.SDK.Models.RoaApi.UserAlbums albums = (MySpaceID.SDK.Models.RoaApi.UserAlbums)JsonConvert.Import(typeof(MySpaceID.SDK.Models.RoaApi.UserAlbums), myspaceClient.GetAlbums(userId));
                                    if (albums != null)
                                    {
                                        string albumid = albums.entry[0].album.id;

                                        myspaceClient.AddPhoto(userId, albumid, "Test Photo From App", FileUploadControl.FileBytes);

                                        StatusLabel.Text = "Upload status: File uploaded!";
                                    }
                                }
                            }
                        }
                        else
                        {
                            StatusLabel.Text = "Upload status: The file has to be less than 1000 kb!";
                        }
                    }
                    else
                    {
                        StatusLabel.Text = "Upload status: Only JPEG files are accepted!";
                    }
                }
                catch (Exception ex)
                {
                    StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
        }