当前位置: 首页>>代码示例>>C#>>正文


C# AmazonS3.UploadFileWithKey方法代码示例

本文整理汇总了C#中AmazonS3.UploadFileWithKey方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3.UploadFileWithKey方法的具体用法?C# AmazonS3.UploadFileWithKey怎么用?C# AmazonS3.UploadFileWithKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AmazonS3的用法示例。


在下文中一共展示了AmazonS3.UploadFileWithKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayMode_Click

    protected void DisplayMode_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        if (State["SelectedApp"] == null || State["SelectedApp"].ToString().Contains("->"))
            return;

        int index = DisplayModeButton.SelectedToggleStateIndex;

        if (index == 0)//design mode
        {
             State["WebAppMode"] = null;//design mode is the default
            canvas.Attributes["src"] = "canvas.aspx";
            DesignMessage.Text = "";
            QRCode.Src = "";
            QRCode.Style.Value = "display:none";
            QRCodeLabel.Style.Value = "display:none";
            CurrentAppContainer.Style.Value = CurrentAppContainerStyle;
            TestAppURL.Text = "";
            ShowAppControls();
        }
        else //preview mode
        {
            //save Page first
            if (SavedCanvasHtml.Text.Length > 0)
                SavePage();

            HideAppControls();
            DisplayModeButton.Style.Value = "";//don't hide the toggle button
            CurrentAppContainer.Style.Value = "display:none";

            State["WebAppMode"] = "preview";
            WebAppsUtil web_util = new WebAppsUtil();
            AmazonS3 s3 = new AmazonS3();
            State["IsProduction"] = false;
            string file_name =  State["SelectedApp"].ToString().Replace(" ", "_") + Constants.WEB_APP_TEST_SUFFIX +"/index.html";

            string save_file_path =  HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name.Replace(Constants.WEB_APP_TEST_SUFFIX + "/index.html", ".html");

            string ret = web_util.GetWebApp(State, util.GetStagingAppXml(State), 1.0D,1.0D);
            if (ret.StartsWith("Error:"))
            {
                Message.Text = ret;
                DisplayMode_Click(null, null);
                return;
            }
            File.WriteAllText(save_file_path, ret);

            if ( State["UrlAccountIdentifier"] == null)
            {
                Message.Text = "The Account Identifier has not been set.";
                return;
            }
            string key =  State["UrlAccountIdentifier"].ToString() + "/" + file_name;
            s3.UploadFileWithKey(State, file_name, save_file_path,key);
            string url = "http://viziapps.s3-website-us-east-1.amazonaws.com/" +  State["UrlAccountIdentifier"].ToString() + "/" +  State["SelectedApp"].ToString().Replace(" ", "_") + Constants.WEB_APP_TEST_SUFFIX;
            canvas.Attributes["src"] = url;

            if (File.Exists(save_file_path))
                File.Delete(save_file_path);

            BitlyData.LoginName = ConfigurationManager.AppSettings["BitlyLoginName"];
            BitlyData.APIKEY = ConfigurationManager.AppSettings["BitlyAPIKey"];
            String bitly_url = Bitly.ShortURL(url, Bitly.Format.TXT);
            QRCode.Src = Bitly.GetQRCodeURL(bitly_url);

            TestAppURL.Text = "Test App URL: " + bitly_url;
            QRCode.Style.Value = "";
            QRCodeLabel.Style.Value = "";
            QRCodeLabel.Text = "QR Code for Test Web App: " +  State["SelectedApp"].ToString() + ". Capture the URL from this image with any app that reads QR codes and you will see your app on your device in seconds." ;
            DisplayModeValue.Text = "";
            SavedCanvasHtml.Text = "";
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:76,代码来源:TabDesignWeb.aspx.cs

示例2: ShowPublishedWebApp

    protected void ShowPublishedWebApp()
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        if (State["SelectedApp"] == null || State["SelectedApp"].ToString().Contains("->"))
            return;

        WebAppsUtil web_util = new WebAppsUtil();
        AmazonS3 s3 = new AmazonS3();
        State["IsProduction"] = true;

        string file_name = State["SelectedApp"].ToString().Replace(" ", "_") + Constants.WEB_APP_TEST_SUFFIX + "/index.html";
        string save_file_path =  HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name.Replace(Constants.WEB_APP_TEST_SUFFIX + "/index.html", ".html");

        string ret = web_util.GetWebApp(State, util.GetStagingAppXml(State),1.0D, 1.0D);
        if (ret.StartsWith("Error:"))
        {
            PublishMessage.Text = ret;
             return;
        }
        File.WriteAllText(save_file_path, ret);

        if (State["UrlAccountIdentifier"] == null)
        {
            PublishMessage.Text = "The Account Identifier has not been set.";
            return;
        }
        string key = State["UrlAccountIdentifier"].ToString() + "/" + file_name;
        s3.UploadFileWithKey(State, file_name, save_file_path, key);
        string url = "http://viziapps.s3-website-us-east-1.amazonaws.com/" + State["UrlAccountIdentifier"].ToString() + "/" + State["SelectedApp"].ToString().Replace(" ", "_") ;

        if (File.Exists(save_file_path))
            File.Delete(save_file_path);

        BitlyData.LoginName = ConfigurationManager.AppSettings["BitlyLoginName"];
        BitlyData.APIKEY = ConfigurationManager.AppSettings["BitlyAPIKey"];
        String bitly_url = Bitly.ShortURL(url, Bitly.Format.TXT);
        QRCode.Src = Bitly.GetQRCodeURL(bitly_url);

        PublishedAppURL.Text = "Published App URL: " + bitly_url;
        QRCode.Style.Value = "";
        QRCodeLabel.Style.Value = "";
        QRCodeLabel.Text = "QR Code for Published Web App: " + State["SelectedApp"].ToString() + ". Capture the URL from this image with any app that reads QR codes and you will see your app on your device in seconds.";
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:46,代码来源:PublishingFormWebApps.aspx.cs

示例3: SaveProductionAppInfo

    public void SaveProductionAppInfo(Hashtable State, string app_name, XmlDocument Design)
    {
        //save design in a file
        DynamoDB ddb = new DynamoDB();
        string file_name = app_name.Replace(" ", "_") + ".xml";
        string file_path =  HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name;
        Design.Save(file_path);

        //save design in S3
        string key = State["Username"].ToString() + "/" + app_name.Replace(" ", "_") + "/" + file_name;
        AmazonS3 s3 = new AmazonS3();
        State["AppDesignURL"] = s3.UploadFileWithKey(State, file_name, file_path, key);
        try
        {
            File.Delete(file_path);
        }
        catch (Exception ex) { }//in case there is a problem with deleting the file

        Document DDBDoc = new Document();
        DDBDoc["username"] = State["Username"].ToString();
        DDBDoc["appname"] = app_name;
        DDBDoc["app_id"] = State["AppID"].ToString();
        DDBDoc["is_production_app_paid"] = State["IsProductionAppPaid"].ToString();
        if (State["FreeProductionExpirationDateTime"] != null && State["FreeProductionExpirationDateTime"].ToString().Length > 0)
            DDBDoc["free_production_expiration_date_time"] = State["FreeProductionExpirationDateTime"].ToString();
        DDBDoc["use_1_user_credential"] = State["Use1UserCredential"].ToString();
        DDBDoc["app_design_url"] = State["AppDesignURL"].ToString();
        DDBDoc["date_time_modified"] = State["DateTimeModified"].ToString();
        DDBDoc["has_unlimited_users"] = State["HasUnlimitedUsers"].ToString();
        ddb.PutItem(State, "apps", DDBDoc);
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:31,代码来源:Util.cs

示例4: Publish_Click

    protected void Publish_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "../../Default.aspx")) return;

        //check if entries were set
        DB db = new DB();
        StringBuilder b_sql = new StringBuilder("SELECT * FROM applications ");
        b_sql.Append("WHERE application_name='" + State["SelectedApp"].ToString() + "'");
        b_sql.Append(" AND customer_id='" +  State["CustomerID"].ToString() + "'");
        DataRow[] rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
        DataRow row = rows[0];
         if (row["production_app_name"] == DBNull.Value || row["production_app_name"].ToString().Length == 0)
         {
             PublishMessage.Text = "The Published App Name needs to be set and saved";
            return;
         }
         if (row["production_app_xml"] == DBNull.Value)
         {
             PublishMessage.Text = "The Publish Design needs to be saved";
            return;
         }

        string icon_url = util.GetApplicationLargeIcon(State,  State["ApplicationID"].ToString());
        if (icon_url == null || icon_url.Length == 0)
        {
            PublishMessage.Text = "The Icon image needs to be uploaded";
            return;
        }
        string splash_url = util.GetApplicationSplashImage(State,  State["ApplicationID"].ToString());
        if (splash_url == null || splash_url.Length == 0)
        {
            PublishMessage.Text = "The splash image needs to be uploaded";
            return;
        }

        //check on paid service
        //is payment current
        XmlUtil x_util = new XmlUtil();
        Hashtable features = util.IsProductionAppPaid(State);
        if (features == null)
        {
            PublishMessage.Text = "A production service needs to be paid for your app.";
            return;
        }
        else //check number of pages
        {
            int page_count = x_util.GetProductionAppPageCount(State);
            int sku_page_count = (int)features["max_pages"];
            if (page_count > sku_page_count)
            {
                PublishMessage.Text = "Your production app of " + page_count.ToString() + " pages exceeds the page limit of " + sku_page_count .ToString() + " for the production service you paid for.";
                return;
            }
        }

        State["UrlAccountIdentifier"] = util.GetUrlAccountIdentifier(State);
        if (State["UrlAccountIdentifier"].ToString().Length == 0)
        {
            PublishMessage.Text = "The Account Identifier has not been set. Go the Design Page and set the Account Identifier in the app properties";
            return;
        }

        WebAppsUtil web_util = new WebAppsUtil();
        AmazonS3 s3 = new AmazonS3();
        State["IsProduction"] = true;

        string file_name = State["SelectedApp"].ToString() + "/index.html";
        file_name = file_name.Replace(" ", "_");
        string save_file_path =  HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name.Replace("/index.html", ".html");

        if (File.Exists(save_file_path))
            File.Delete(save_file_path);

        string html = web_util.GetWebApp(State,util.GetStagingAppXml(State),1.0D,1.0D);
        File.WriteAllText(save_file_path, html);
         string key =  State["UrlAccountIdentifier"].ToString() + "/" + file_name;
        s3.UploadFileWithKey(State, file_name, save_file_path, key);

        if (File.Exists(save_file_path))
            File.Delete(save_file_path);

        string filename =  State["SelectedApp"].ToString().Replace(" ", "_") + "_qrcode.png";

        string url = "http://viziapps.s3-website-us-east-1.amazonaws.com/" +  State["UrlAccountIdentifier"].ToString() + "/" +  State["SelectedApp"].ToString().Replace(" ", "_");
        PublishMessage.Text = "Pulished App URL: " + url;

        BitlyData.LoginName = ConfigurationManager.AppSettings["BitlyLoginName"];
        BitlyData.APIKEY = ConfigurationManager.AppSettings["BitlyAPIKey"];
        String bitly_url = Bitly.ShortURL(url, Bitly.Format.TXT);
        QRCode.Src = Bitly.GetQRCodeURL(bitly_url);
        PublishedAppURL.Text = "Short-length published App URL: " + bitly_url;

        QRCode.Style.Value = "";
        QRCodeLabel.Style.Value = "";
        QRCodeLabel.Text = "QR Code for Published Web App: " + State["SelectedApp"].ToString() + ". Capture the URL from this image with any app that reads QR codes and you will see your app on your device in seconds.";
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:98,代码来源:PublishingFormWebApps.aspx.cs

示例5: Util

    /* protected void GoToWebAppDesign_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        if (SavedCanvasHtml.Text.Length > 0)
            SavePage();
        if (State["SelectedApp"] != null &&
            !State["SelectedApp"].ToString().Contains("->") &&
            SaveBeforeChangingAppType.Text.Length > 0)
        {
            SaveBeforeChangingAppType.Text = "";
           // util.SetAppType(State, Constants.WEB_APP_TYPE);
        }
        else
        {
            InitCurrentApp("->");
        }
        Response.Redirect("TabDesignWeb.aspx", false);
    }*/
    protected void DisplayMode_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        if (State["SelectedApp"] == null || State["SelectedApp"].ToString().Contains("->"))
            return;

        int index = DisplayModeButton.SelectedToggleStateIndex;

        if (index == 0)//design mode
        {
             State["WebAppMode"] = null;//design mode is the default
            canvas.Attributes["src"] = "canvas.aspx";
            DesignMessage.Text = "";
            CurrentAppContainer.Style.Value = CurrentAppContainerStyle;
            PreviewNote.Text = "";
            ShowAppControls();
        }
        else //preview mode
        {
            //save Page first
            if (SavedCanvasHtml.Text.Length > 0)
                SavePage();

            HideAppControls();
            DisplayModeButton.Style.Value = "";//don't hide the toggle button
            CurrentAppContainer.Style.Value = "display:none";
            State["WebAppMode"] = "preview";

            //validate fields next
            XmlUtil x_util = new XmlUtil();
            Message.Text = "";
            x_util.ValidateFieldNames(State, Message);
            if (Message.Text != "All fields have been validated")
            {
                PreviewNote.Text = "There were errors in generating your app. Return to design mode to fix the errors.";
                DisplayModeValue.Text = "";
                SavedCanvasHtml.Text = "";
                return;
            }
            Message.Text = "";
            WebAppsUtil web_util = new WebAppsUtil();
            AmazonS3 s3 = new AmazonS3();

            State["IsProduction"] = false;
            string file_name =  State["SelectedApp"].ToString().Replace(" ", "_") + Constants.WEB_APP_TEST_SUFFIX +"/index.html";
            string save_file_path =  HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name.Replace(Constants.WEB_APP_TEST_SUFFIX + "/index.html", ".html");

            if (State["UrlAccountIdentifier"] == null)
            {
                Message.Text = "The Account Identifier has not been set.";
                return;
            }

            string html = web_util.GetWebApp(State,util.GetStagingAppXml(State),1.0D, 1.0D);
            if (html.StartsWith("Error:"))
            {
                Message.Text = html;
                DisplayMode_Click(null, null);
                return;
            }
            File.WriteAllText(save_file_path, html);

            string key =  State["UrlAccountIdentifier"].ToString() + "/" + file_name;
            s3.UploadFileWithKey(State, file_name, save_file_path,key);
            string url = "http://viziapps.s3-website-us-east-1.amazonaws.com/" +  State["UrlAccountIdentifier"].ToString() + "/" +  State["SelectedApp"].ToString().Replace(" ", "_") + Constants.WEB_APP_TEST_SUFFIX;
            canvas.Attributes["src"] = url;

            if (File.Exists(save_file_path))
                File.Delete(save_file_path);

            PreviewNote.Text = "This preview cannot show actions with native device resources. To test those actions, go to design mode and select this app for testing on your device.";
            DisplayModeValue.Text = "";
            SavedCanvasHtml.Text = "";
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:99,代码来源:TabDesignHybrid.aspx.cs


注:本文中的AmazonS3.UploadFileWithKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。