[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

[TypeScript] Processing to upload images with ionic2 [Transfer]

This is Hase from the development team!

This time I would like to write about the process of uploading images (files) with ionic2.
I use a plugin called cordova-plugin-file-transfer

Install plugin

First install the plugin.

$ ionic plugin add cordova-plugin-file-transfer

Usage example

import { Transfer } from 'ionic-native'; @Component({omitted}) export class FileUpload{ fileTransfer = new Transfer(); constructor({omitted}){ } upload(){ let options: any; options = { fileKey : 'file', fileName: 'name.jpg', headers: {} ..... } this.fileTransfer.upload( "file path", "server path", options, false ) .then((data) = > { // success }, (err) => { // error }) }

explanation

Line 22 of the above source is the process of actually uploading the image.

upload(file path, server path, options, trustAllHosts)

upload is a method for sending files to the server.
Explaining each argument

argument type detail
file path string Specify image path
server path string Specify the server path to save the image
options FileUploadOptions
fileKey Specify form element (default: file)
fileName Specify the name when saving the file on the server (default: image.jpg)
httpMethod Specify HTTP method as PUT or POST (default: POST)
mimeType Specify MIME type (default: image/jpeg)
trustAllHosts boolean Basically false is OK

It becomes.
There is a detailed explanation on
the official website I have explained the image upload process above.

At the end

The Transfer plugin can process not only image uploads but also downloads.
This time I only explained the upload process, but if there is a demand, I would like to explain the download process as well, so
please let me know.

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
728
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Tatsuya Hase

Joined Beyond Co., Ltd. as a new graduate.

We develop web systems (development of services and systems that run on browsers, such as web services, digital content, and business management systems) and game APIs (development of programs that communicate with application games).

We also develop private/custom apps for Shopify.

Originally worked at the Osaka office, but transferred to the Yokohama office in 2019.
His hobbies are baseball/karaoke/anime