Hello sir,
I have used your google drive api code, it is working fine for single document but i want to upload document as well without size restriction and without asking for access everytime to upload docs.
I have attached my code for your reference.
kindly reply for that.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPSnippets.GoogleAPI;
using System.Web.Script.Serialization;
public partial class Upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GoogleConnect.ClientId = "988940200336-8klssk61lg30a19i20dbkovg6n3v3u8c.apps.googleusercontent.com";
GoogleConnect.ClientSecret = "JlxVnVuv-Cc5_uir7HZokSe_";
GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0];
GoogleConnect.API = EnumAPI.Drive;
if (!string.IsNullOrEmpty(Request.QueryString["code"]))
{
string code = Request.QueryString["code"];
string json = GoogleConnect.PostFile(code, (HttpPostedFile)Session["File"], Session["Description"].ToString());
GoogleDriveFile file = (new JavaScriptSerializer()).Deserialize<GoogleDriveFile>(json);
tblFileDetails.Visible = true;
lblTitle.Text = file.Title;
lblId.Text = file.Id;
imgIcon.ImageUrl = file.IconLink;
lblCreatedDate.Text = file.CreatedDate.ToString();
lnkDownload.NavigateUrl = file.WebContentLink;
if (!string.IsNullOrEmpty(file.ThumbnailLink))
{
rowThumbnail.Visible = true;
imgThumbnail.ImageUrl = file.ThumbnailLink;
}
}
if (Request.QueryString["error"] == "access_denied")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
}
}
protected void btnUpload_Click(object sender, EventArgs e)
{
foreach (var file in FileUpload1.PostedFiles)
{
Session["File"] = file;
Session["Description"] = txtDescription.Text;
GoogleConnect.Authorize("https://www.googleapis.com/auth/drive.file");
}
}
public class GoogleDriveFile
{
public string Id { get; set; }
public string Title { get; set; }
public string OriginalFilename { get; set; }
public string ThumbnailLink { get; set; }
public string IconLink { get; set; }
public string WebContentLink { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime ModifiedDate { get; set; }
}
}