Uploading zip file to sharepoint using REST is not saving the file contents - sharepoint

Uploading zip file to sharepoint using REST is not saving the file contents. The operation is sucessful. But when the file is downloaded from site to local machine, its failing to open the zip and showing 0 bytes

Did you follow:
https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/upload-a-file-by-using-the-rest-api-and-jquery
Creating the item (with the meta data) in the library and upload the file (binary) are two seperate actions you have to handle to complete the upload. I think you only add an item to the library and not uploading the binary data?

Related

exceljs error when reading csv file uploaded from windows

When uploading csv file created by windows; an error is generated when trying to parse the file using exceljs.
Here is the error message:
message: "Can't find end of central directory : is this a zip file ?
If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"
It happens because of the uploading stage, you haven't uploaded the file successfully so that can not reading later. Please double check whether you uploading or having the file on cloud storage successfully or not

Download xlsx file (or any formats that cannot be read by notepad) from Google Storage and store it locally

I currently have a node.js server running where I can grab a csv file stored in storage bucket and store that to a local file.
However, when I try to do the same thing with a xlsx file, it seems to mess up the file and cannot be read when I download it to a local directory.
Here is my code for getting the file to a stream:
async function getFileFromBucket(fileName) {
var fileTemp = await storage.bucket(bucketName).file(fileName);
return await fileTemp.download()
}
and with the data returned from above code, I store it into local directory by doing the following:
fs.promises.writeFile('local_directory', DataFromAboveCode)
It seems to work fine with .csv file but does not work with .xlsx file where I can open the csv file but xlsx file gets corrupted and cannot be opened.
I tried downloading the xlsx file directly from the storage bucket on google cloud console but it seems to work fine, meaning that somethings gone wrong in the downloading / saving process
Could someone guide me to what I am doing wrong here?
Thank you

Sharepoint nodejs upload file

I'm trying to upload a file to the SharePoint shared folder.
I am able to upload a file using spsave but its uploading to the Files location. I would like to upload to the Shared location instead of Files location. Doing it in this way:
const fileOptions = {
folder: '/Documents/testing',
fileName: 'test.txt',
fileContent: 'hello world'
};
it's uploading to the Files location under testing folder I can see the file text.txt. Can't figure it out how to upload to the Shared folder. Is this possible? Can't find the related path for the shared destination. For Files it's Documents but what would be for the Shared??? Anyone have any knowledge about sharepoint onedrive and could help me with this?
I don't think you can upload to OneDrive with spsave. It is for native SharePoint only afaik. If you want to share a file in OneDrive using a rest api I suggest to look at office graph.

How to validate file to be uploaded?

I am working on liferay project. I have to put file upload functionality. For which I have used
<bridge:inputFile/>
But my upload method is not called when I try to upload a blank file of 0 bytes. Actually my validation for blank file is inside my upload method.

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