Changing file type - typeerror

My code is below. How do I change filename to fileURL?
function listRecord(vendorname, filename)
{
var url = 'https://docs.google.com/spreadsheets/d/"";
var ss= SpreadsheetApp.openByUrl(url);
var recordsSheet =ss.getSheetByName("Records");recordsSheet.appendRow([vendorname, filename, Date()]);
}
I tried many ways but nothing work. Clueless.
type here

Related

download file in telegram.bot api using mvc c#

I am using this code to download file from my bot.
this work in local but does'nt work in server.
i'm using webhook. please help me.
thanks
private async Task SaveFileAsync(Update update, TelegramBotClient bot)
{
string fs = AppDomain.CurrentDomain.BaseDirectory+ #"Uploads\";
var FileId = update.Message.Document.FileId;
var fileInfo = await bot.GetFileAsync(FileId);
var filename = fileInfo.FileId + "." + fileInfo.FilePath.Split('.').Last();
string strFilePath = fs + filename;
FileStream saveImageStream = System.IO.File.Open(strFilePath, System.IO.FileMode.Create, FileAccess.ReadWrite);
await bot.DownloadFileAsync(fileInfo.FilePath, saveImageStream, CancellationToken.None);
saveImageStream.Dispose();
}
enter image description here
I solved the problem.
this method should be void and without async.
and then we must remove await before bot.DownloadFileAsync

working with excel files in uwp

my question is - I can't read data from excel file. I'm using spreadsheetgear library. I'm writing for uwp platfom (I need to show user data from excel file). may someone help?
(gv1 = gridview). or I should use other library? May be anyone already worked with spreadsheetgear and can help.
Public Async Function open_excel() As Task
Dim Values As String()
Dim filepicker As New FileOpenPicker With {.ViewMode = PickerViewMode.List, .SuggestedStartLocation = PickerLocationId.Downloads}
filepicker.FileTypeFilter.Add(".xls")
filepicker.FileTypeFilter.Add(".xlsx")
Dim storefile As StorageFile = Await filepicker.PickSingleFileAsync
Dim workbook As IWorkbook = Factory.GetWorkbook(storefile.Path)
Dim worksheet As IWorksheet = workbook.Worksheets(0)
gv1.ItemsSource = worksheet.Cells
From spreadsheetgear document, if you want to open Excel from a file you need to create workbookSet then invoke OpenFromStream method. I have tested, it works in my side.
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
using (var steam = await file.OpenAsync(FileAccessMode.ReadWrite))
{
var workbookSet = Factory.GetWorkbookSet(CultureInfo.CurrentUICulture);
var workbook = workbookSet.Workbooks.OpenFromStream(steam.AsStream());
var worksheet = workbook.Worksheets[0];
var Used = worksheet.UsedRange;
var items = Used.Value;
}
}
else
{
return;
}
I have a question, I use the code to open the excel, and if I want to save it, what is it the code?.
I use the code of open the excel. If you dont want open a windows dialog, and you prefer to give de path directly, you can use the following code:
var folder = await StorageFolder.GetFolderFromPathAsync(#"C:\Excel_Modelo");
var file = await folder.GetFileAsync("Modelo.xlsx");
if (file != null)
{
var workbookSet = Factory.GetWorkbookSet(CultureInfo.CurrentUICulture);
IWorkbook workbook = workbookSet.Workbooks.OpenFromStream(steam.AsStream());
var worksheet = workbook.Worksheets[0];
var Used = worksheet.UsedRange;
var items = Used.Value;
}

How to get value from then in javascript

i have maybe stupid question.
I m trying to save XML file which i load through xml2js with readfile function.
I want to store file content string to global variable but i dont know how to get from promise then a value.
var myval;
var simpleStore = function(value){
myval = value;
}
var myvariable = RNFS.readFile(APPLICATION_HISTORY_DIRECTORY, 'utf8').then(simpleStore);

<p:media display pdf from folder dynamically

I have several pdf files saved in ...WebContent/Manuals/filename.pdf that I am trying to display on my page. I am getting "Failed to Load PDF document" message in Chrome.
My Jsf:
<p:media value="#{reviewBean.manual}" player="pdf" height="600px" width="1000px" />
My #SessionScoped Bean:
public StreamedContent getManual() throws IOException {
String type = "application/pdf";
String path = "";
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
path = "C:\\.....\\WebContent\\Manuals\\filename.pdf";
InputStream is = new ByteArrayInputStream(path.getBytes());
return new DefaultStreamedContent(is, type);
}
}
There is additional logic that i have left out for clarity which decides which pdf is displayed.
I have also tried the file path of /Manuals/filename.pdf as path
I tried following the below example:
How to bind dynamic content using <p:media>?
In my case I do not need to retrieve a value using <f:param
Is my file path incorrect to display the image? Or am I building the Stream incorrectly? Any guidance is much appreciated.
I solved this by merely returning the url as a String.
public String getManual() {
return user.getManuals().get(user.getLData().getDepart());
}
Where the returned value is the file path of the pdf: Manuals/filename.pdf

Renaming a file in as3 AIR - how to do it if you have file's native path in a var?

The following code is great for renaming a file if you know the file is in applicationStorageDirectory
var sourceFile:File = File.applicationStorageDirectory;
sourceFile = sourceFile.resolvePath("Kalimba.snd");
var destination:File = File.applicationStorageDirectory;
destination = destination.resolvePath("test.snd");
try
{
sourceFile.moveTo(destination, true);
}
catch (error:Error)
{
trace("Error:" + error.message);
}
How do you set the sourceFile if all you have is the file's native path in a string? Like this:
D:\Software\files\testList.db
This throws errors:
sourceFile = sourceFile.resolvePath("D:\Software\files\testList.db");
The idea is I want to rename a file I had previously loaded into a var. I figured I'd extract the native path to a String var, null the File var (so the OS doesn't tell me it can't be renamed while the file is opened in flash), resolve that nativePath as the sourceFile, and use moveTo to rename the file on the hard drive.
Cheers for taking a look.
EDIT:
I've set up a test AIR app with only the following in it:
import flash.events.*;
import flash.filesystem.*;
var original = File.documentsDirectory;
original = original.resolvePath("D:\\Software\\test\\October.db");
var destination:File = File.documentsDirectory;
destination = destination.resolvePath("copy.db");
original.addEventListener(Event.COMPLETE, fileMoveCompleteHandler);
original.addEventListener(IOErrorEvent.IO_ERROR, fileMoveIOErrorEventHandler);
original.moveToAsync(destination);
function fileMoveCompleteHandler(event:Event):void {
trace(event.target); // [object File]
}
function fileMoveIOErrorEventHandler(event:IOErrorEvent):void {
trace("I/O Error.");
}
This fails, as does using D:\Software\test\October.db
I guess what I want to know it - how do you do the resolvePath thing if you already know the full path?
I guess what I want to know it - how do you do the resolvePath thing if you already know the full path?
You don't AFAIK. If your path is actually d:\software\test\october.db you can set a File ref like:
var original:File = new File();
original.nativePath = "d:\software\test\october.db";