Can Gitlab API upload file to repo? - gitlab

https://docs.gitlab.com/ee/api/projects.html#upload-a-file
After upload image, I got the url, but didn't added to my repo files?
Can we upload image to repo files?

The /projects/:id/uploads doesn't add anything to your project's repository. The description says:
Uploads a file to the specified project to be used in an issue or merge request description, or a comment.
To upload a file to the actual repo you need to use the /projects/:id/repository/files/:file_path endpoint.
To upload an image specifically, you'll need to:
Set the encoding parameter to base64
Convert your image to base64
Remove the data:image/png;base64, part at the beginning
Set the content parameter to the remaining part of the base64

Related

Don't overwrite existing file nodejs express-fileupload

I tried out the express-fileupload sample project, to test uploading files. However, if I upload a file with a name that is already uploaded e.g. test.jpg (uploaded) test.jpg (to be uploaded) it just overwrites the old file. Is there an easy way to prevent this or do I have to code something that checks if that file already exists.
Sample Project: https://github.com/richardgirges/express-fileupload/tree/master/example

How to upload text file (.txt) in cloudinary using nodejs?

I have a text file with extension ".txt" that needs to be uploaded on Cloudinary. Cloudinary is not allowing me to do that.
Any help on this will be appreciated.
What do you mean upload ".txt"?
I googled it and first few seconds into the research I found this:
[![enter image description here][1]][1]
[![enter image description here][2]][2]
It's a image/video hosting service not a cloud storage service.
But there are tons of such services that allow uploading
[1]: https://i.stack.imgur.com/b09yV.png
[2]: https://i.stack.imgur.com/aGbyO.png
You didn't specify what error you're receiving, but Cloudinary does support non-image, non-video uploads, which are called 'raw' files: https://cloudinary.com/documentation/upload_images#uploading_non_media_files_as_raw_files
A possible error you may encounter is if you haven't set the resource_type to raw in your API call, or if you've set resource_type to auto but the filename of the uploaded file wasn't sent on the upload API call. In that case, it's likely that Cloudinary was expecting an image file, and didn't detect that you sent a .txt file.
If so, you'll receive an 'invalid image file' error if the file was treated as an image - specifying the resource type explicitly should resolve that

Can't create .zip file with Azure Logic Apps' SharePoint Create File action

I'm trying to create a .zip file by passing the returned body of an HTTP GET request to SharePoint's Create File.
Body is:
{
"$content-type": "application/zip",
"$content": "UEsDBBQACA...="
}
Shouldn't this just work? The docs only define the Create File field as "Content of the file." but that's not super informative...
I believe I've done this before with a file that was application/pdf and it worked. Unfortunately, I can't find that Logic App (I think it may have been an experiment I've since deleted).
I should note that the Create File action does create a valid .zip file, in that it's not corrupt, but archive is empty. It's supposed to contain a single .csv file.
I tried decoding the Base64 content and it's definitely binary data.
Any idea where I'm going wrong?
I test with Postman and when I use the form-data way to POST the request, I found the .zip file couldn't be open. Then I check the Logic App run history and I find the problem is if just use the triggerbody() as the file content it will fail.
This is because the triggerbody() not just have the $content, so I change the expression to triggerBody()['$multipart'][0]['body'] then it works and the .zip file is full.

How to retrieve the content of a pull request patch file from a private repo?

I have a private repo and I need to get the patch file contents from a pull request.
I am using this nodejs api.
github.pullRequests.get(msg,function(err,p){
//[...]
console.log(p.patch_url); //I get the patch url something like: https://github.com/:user/:repo/pull/1.patch
//[...]
})
How can I get the content of that file either using the API or some other method (curl, etc)?
github.repos.getContent doesn't seem to help (or I might sending the wrong path for this file).
It seems that I missed this:
Alternative Response Formats
Pass the appropriate media type to fetch diff and patch formats.
from the GitHub API documentation.
Info regarding the format: Media:
application/vnd.github.VERSION.patch

CodeIgniter - Directory Traversal - sanitize_filename()

If I use the CodeIgniter File Upload Class and rename the image being uploaded using:
$config['file_name']
do I still have to use
$this->security->sanitize_filename()
on the image being uploaded by user?
just set $config['encrypt_name']; will automatically rename users uploaded file or image for more information check user guide of File uploading library
File Upload Library

Resources