Transfering files through github API - github-api

I am trying to transfer files using the GitHub API by curl. The files may have any extension (eg: .java, .jar, .jpg, etc). I have found no solutions in the net. Is there a way I can do this? Or is it even possible?

What do you mean by transfer file?
there is an option of uploading a blob files through the github api /repos/git/blobs.
you should add a parameter of the content of the file in base64 format.
if you want to use them later on you can create new tree with the returned SHA.
base64 online converter: https://www.base64decode.org/

Related

What is the best way to retrieve a single folder from a github repository in a python script?

I need to download a single folder from a github repository in a Python 3 script.
Listing all raw file URLs to download is tedious and eventual new files would need to be added manually
Downloading the whole repository as zip takes rather long; there are lots of unneeded files. [This how I do at the moment]
I have read about web services that do what I would need, such as downgit.github.io, but the problem is that generating the relevant URL and fetching it via urllib.request.urlretrive() downloads the website rather than the actual file.
What can I do? Is there a web service that provides raw file links that I can download as described above?
I just found a solution: The ffspec library may be used to download a single folder from a GitHub repository using Python. See https://sebastianwallkoetter.wordpress.com/2022/01/30/copy-github-folders-using-python/

Unable to encode an asset with two videos in azure media services v3

I am capturing multiple videos and trying to store them all in one media asset and later encode them. But I always get the below error. There are no issues however if I upload one file to asset and run the encoding job.
Output 'BuiltInStandardEncoderPreset_0', Error : Microsoft.Azure.Management.Media.Models.JobError : While trying to download the input files, the files were not accessible, please check the availability of the source.
Do I need to use one media asset for each upload? Is having multiple files in one asset not the right approach?
FYI: I tried all thesew steps on media servicer explorer desktop app. So please be sure I didn't write any code for this.
You would indeed need to use a separate Asset for each video. We'll follow up with a service update to improve the error message in this situation.
I think the problem here is not the upload of multiple files in one asset, but the fact that the encoding job will not pick each blob of the asset and encoding them. That's why you need to use one asset per video file to be encoded.

What is the best way to extract .zip file/folder structure then commit to Github using Github API?

I'm trying to place some config files under version control using Github. The ONLY way to get these particular config files is via a GET request to the hosting server. Server responds with a .zip file.
.zip file structure looks similar to:
|-Folder1
--|-File1.json
--|-File2.json
--|-Pic1.jpg
|-Folder2
--|-File3.json
--|Folder3
----|Pic2.jpg
|-File4.json
|-File5.json
As you can see, its a mix of text and binary files. Also has a nested folder structure.
I need to:
Commit this .zip file to Github using the Github REST API (no problem there)
But BEFORE committing, how can I programmatically extract the folders and files (LEAVING THE FOLDER STRUCTURE IN PLACE)
Commit the results to Github
I've checked the question/solutions mentioned here, but they don't quite match/are a few years old.
Anyone have a workflow for doing this? I have to imagine SOMEONE has come across similar requirements.
I ended up using Power Automate to handle this.
Basically,
GET .zip file
Add it to OneDrive for Business
Extract it there (folder structure is "flattened", but luckily OneDrive "keeps" it by renaming each file)
Example: Folder1/File1.json in the .zip becomes Folder1_File1.json once extracted
When committing to Github via api, I just did a replace for the filename; INCLUDING the / as part of the path.
Example URL: https://api.github.com/repos/SeaDude/replace(items('FOR_EACH_app')?['properties']?['DisplayName'], ' ', '-')/contents/replace(items('FOR_EACH_source_file_2')?['Name'],'_','/')
Apparently, you can specify an empty (or non-empty) path as part of an API commit. If the directory is empty, Github will create it!

SmartDL for ftp

I need a python code which can download files from a ftp server. I need a built in multi-part download managing package which can help me to retrieve files faster. I tried SmartDL but the problem is I don't know how to retrieve files in a ftp server. Also I used the add_basic_authentication to ensure that, I am passing the right credentials. Please help me with a solution.
I have no problem using any other solution/package which uses Multipart download.
P.S:- I need to save the Downloaded files on to an Object storage on Cloud. The size of each file may be 300MB and I need to download 20TB of data.
Thanks in anticipation.
Take a look at ftplib, it's a simple FTP library which will permit you to download files from a FTP server.

How can you upload directory using node.js?

I'm new to node and want to upload directory using node.js. Can anybody please help? Thank You
If it's possible how? and if not then why?
you can upload only files.
however there are workarounds,you can
covert the folder to a zip file (client side), it really depends here on your case.
upload the zip file
then unzip it in the server
you can use google to find out how to do every step of those.
You can use use any Folder uploading library like https://github.com/blueimp/jQuery-File-Upload or https://dropzonejs.com which allows you to Drag and Drop whole directory using HTML5 features.

Resources