Copy Data activity in ADF creates strange temporary filenames - azure

I am using a Copy Data activity to upload the contents of a database table as .csv files to an SFTP server using a self-hosted Integration Runtime.
The "owners" of the FTP site have pointed out that they are seeing "strange" filenames, i.e. a guid appended to the designated filename. When I look at the uploaded files, however, that suffix is gone.
It appears therefore that the Copy Data activity
(a) creates the file with a guid in the name,
(b) streams the content into the file, and
(c) renames the file at the end.
Can somebody confirm or deny this? Has anybody else seen this behaviour?
(The problem with this is obviously that step (a) triggers some processing in another system, which is a problem for me).
Any help is greatly appreciated.
Thank, Martin

The behavior you are describing indicates you have "Upload with temp file" checked (which I believe is the default) in your SFTP source:
You may uncheck this box if you don't want it or if the server doesn't support it.

Related

Check share point if file exists in a shared document folder with power automate

I am trying to get the attachments of some emails and check if that attachment already exists in SharePoint. However, since the flow may have already run over some attachments that have already been received, they may or may not already be in SharePoint, so I first have to check SharePoint if the attachment exists and if they don't, create the file using the email attachment content.
So what I have so far is replicating a process that was described here
The problem that quickly arises is that under "Get file content using path" action, the File Path input box(circled below) won't let me append a file path that isn't currently already in a document folder.
Not sure if this is still a valid way to accomplish it or if there's another way. I have checked all over the place and still haven't been able to find a solution. If there's anybody that can help it would be greatly appreciated!!
To tackle this what you can do is to create a variable using Initialize variable action and compose the path e.g. '/DocumentLibrary/file.ext' that you want to check if exists. then you can refer to that variable in your folder path box for Get file content using path action. Please see the screenshot:
Next you can configure run afterfor file creation action and create file if Get file content using path action has failed, otherwise do other stuff that is required. I have tested this for sending different emails based upon file found or not found and it works well.
Hope this solves your issue.

Is there a solution to choose how my file is renamed if a file with the same name already exist?

In SharePoint online when my flow moves the file (PDF, ZIP...) named "U000" in a folder where is a file with the same name it renames the file in "U0001".
How can I customize this to be renamed like "U000-Rev.1" or "U000_copy(1)" instead of "U0001"?
I know this is the default SharePoint behavior and there is no option for renaming format but maybe I can change or add a code in "definition.json" file from exported ZIP flow (or somewhere else).
(I'm not a software developer so any answer/idea is welcomed.)
Thank you!
Add an if statement to check the file name you just uploaded. If it contains (1) at the end of the name then rename the file. This is probably the least convoluted fast approach but it's not 100% robust.
You can add more logic or change the approach to make it fully robust but you can look into that after you've got something working imo, baby steps.

getting info from an MS SQL .bak file

I am writing an Electron app that, among many other things, restores an unknown .bak file to a MS SQL server and then extracts more information. In order to do this successfully, I need to extract some info from that .bak file programmatically (so SSMS cannot be used). I will be using sqlcmd, since that can be run by Electron's node.js backend. Unfortunately, I have a bit of a chicken and egg problem, because it seems I cannot restore a .bak file without knowing things about the paths for the .mdf files specified within the .bak file (that cannot be found without first restoring it). There is a RESTORE WITH MOVE option, though this seems to also require knowledge of the paths inside the .bak, which cannot be determined from the .bak itself. How might I get this information, or is it impossible?
Read about RESTORE FILELISTONLY.
At this link you'll find further statements one can use together with RESTORE in order to fetch meta data.
The returned resultset of FILELISTONLY will give you the LogicalName, the file's type (Data or Log), information about the file group and much more.
The other statements provide other meta data. Just check it out...

APEX: Read uploaded excel file with as_read_xlsx

As far as I understand, APEX 5.1 does not support Excel files to be loaded into tables.
I found this package that seems to make it possible to SELECT from Excel files, but it does not show how to use it with, for example, files loaded via the "File Browse" Item.
Now, I am very new to this environment, so please explain it from the beginning.
What I did is I upload the package script to the SQL workshop and executed it, without errors. But now?
APEX 5.1 doesn't support it out of the box, but you can use the EXCEL2COLLECTION plugin (available here).
It is very straightforward, just create a file browse page item with an upload button which calls an onsubmit process (e.g. CreateCollection) of type Excel2Collection[Plug In] - specify the file browse item, a collection name and the CSV separator, then you can do as you please with the data (e.g. you may want to run some validations on the data then insert it into a table where you can access it as normal).

Retrieve contents of a ZIP file on SharePoint without downloading it

I have written a bit of automated code that checks a SharePoint site and looks for a ZIP file (lets call it doc.zip). If doc.zip is found, it downloads it, and then checks for a file (say target.docx). doc.zip is about 300MB, and so I want to only download where necessary.
What I would like to know is that given SharePoint has some ZIP search capability, is it possible to write code using CSOM (c#) to find doc.zip, and then run some code to retrieve the contents of doc.zip without downloading it.
Just to re-iterate, I am comfortable with searching for files in a folder on SP, downloading the file, and unpacking zip entries. What I need is to retrieve a ZIP files content on SP without downloading it.
E.g. is there a SP command:
cxt.Load(SomeZipFileQuery);
cxt.ExecuteQuery();
Thanks in advance.
This capability is not available. I do like the idea. Having the ability to "parse" zip files on the server side and then download the relevant bits would be ideal. Perhaps raise this on uservoice to see if others also find this us https://sharepoint.uservoice.com
Ok, I have proven yet again that stubbornness will prevail.
I have figured out that if I use the /_api/search?query='myfile.zip' web REST API to search for my file, this search will also match ZIP files that contain the file I need. And it works perfectly.
Of course there is added (pain) of parsing an XML response, but it works very nicely for my code example.
At least if someone is looking for this solution here it is. I wont bore anyone with code, as the /_api/search has probably been done to death already on other threads.

Resources