将文件上传到Google网站 [英] upload a file to google site
本文介绍了将文件上传到Google网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将文件上传到google site? (vb.net)
i尝试使用此代码但不起作用
How can I upload a file to "google site" ? (vb.net)
i tried this code but it doesn't work
Dim DirectoryName As String = "/temp"
Dim wClient As New Net.WebClient
wClient.Credentials = New Net.NetworkCredential("username", "password")
For Each file As String In IO.Directory.GetFiles("C:\temp")
wClient.UploadFile("https://sites.google.com/site/mysite/files", "c:\temp\database1.mdb")
Next
推荐答案
您需要使用Google网站数据API。请阅读以下链接中与上传文件相关的API文档
ploadingFiles [ ^ ]
此外,您还可以找到 Google数据API示例 [ ^ ]并查看你可以调用API。
特别检查 Sites API演示代码 [ ^ ]
You need to use Google Sites Data API. please read the API documentation related to upload files in below link
ploadingFiles[^]
And Also you can find Google Data API Samples[^] and check how you can call the API.
Specially check the Sites API Demo Code[^]
public AtomEntry updloadAttachment(String filename, String contentType, AtomEntry parent, String title, String description)
{
SiteEntry entry = new SiteEntry();
AtomCategory category = new AtomCategory(SitesService.ATTACHMENT_TERM, SitesService.KIND_SCHEME);
category.Label = "attachment";
entry.Categories.Add(category);
AtomLink parentLink = new AtomLink(AtomLink.ATOM_TYPE, SitesService.PARENT_REL);
parentLink.HRef = parent.SelfUri;
entry.Links.Add(parentLink);
entry.MediaSource = new MediaFileSource(filename, contentType);
entry.Content.Type = contentType;
if (title == "")
{
entry.Title.Text = entry.MediaSource.Name;
}
else
{
entry.Title.Text = title;
}
entry.Summary.Text = description;
AtomEntry newEntry = null;
try
{
newEntry = service.Insert(new Uri(makeFeedUri("content")), entry);
}
catch (GDataRequestException e)
{
Console.WriteLine(e.ResponseString);
}
return newEntry;
}
这篇关于将文件上传到Google网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文